-
Notifications
You must be signed in to change notification settings - Fork 552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[undici] No modules instrumentation has been defined for '@opentelemetry/[email protected]' #2237
[undici] No modules instrumentation has been defined for '@opentelemetry/[email protected]' #2237
Comments
I've been reading that instrumentation problems can sometimes be caused by ESM issues, so I re-implemented as CJS on a branch here with no benefit: https://github.com/digitalbazaar/otel-example/tree/commonJs |
Here's the place where the "No modules..." is logged: https://github.com/open-telemetry/opentelemetry-js/blob/860e5d57466dffba402fc6be8239f923e7569b97/experimental/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts#L71 Seems like maybe this code path is looking for imported modules to instrument which I believe is not applicable to the So if that message/warning is "normal", then the question is simply "why is it not working?" |
Thank you for providing the example code! It looks like you are using the Native |
The diag message is normal.
You are indeed using |
Hello, All, thanks for looking at this with me. With commit I still do not see any otel console logging related to the use of the |
Well, lets go all the way...Refering to: examples/esm-http-ts/index.ts as a baseline and doing slight modifications:
import { diag, DiagConsoleLogger, DiagLogLevel } from '@opentelemetry/api'
import { Resource } from '@opentelemetry/resources'
import { SEMRESATTRS_SERVICE_NAME } from '@opentelemetry/semantic-conventions'
import { ConsoleSpanExporter, SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base'
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node'
import { registerInstrumentations } from '@opentelemetry/instrumentation'
import { UndiciInstrumentation } from '@opentelemetry/instrumentation-undici'
// For troubleshooting, set the log level to DiagLogLevel.DEBUG / INFO
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.INFO)
const resource = new Resource({ [SEMRESATTRS_SERVICE_NAME]: 'otel-example' })
const exporter = new ConsoleSpanExporter()
const processor = new SimpleSpanProcessor(exporter)
const tracerProvider = new NodeTracerProvider({ resource })
tracerProvider.addSpanProcessor(processor)
tracerProvider.register()
registerInstrumentations({ instrumentations: [new UndiciInstrumentation()] }) This is needed because
const response = await fetch('https://github.com/')
const body = await response.text()
{
"scripts": {
"start": "node --import ./instrumentation.js index.js"
}
} Then, running {
resource: {
attributes: {
'service.name': 'otel-example',
'telemetry.sdk.language': 'nodejs',
'telemetry.sdk.name': 'opentelemetry',
'telemetry.sdk.version': '1.24.1'
}
},
traceId: 'ec3e159a030a29f6c87aa64ec0afc617',
parentId: undefined,
traceState: undefined,
name: 'GET',
id: '3579d06d1473d9bb',
kind: 2,
timestamp: 1717446317060000,
duration: 376098.959,
attributes: {
'http.request.method': 'GET',
'http.request.method_original': 'GET',
'url.full': 'https://github.com/',
'url.path': '/',
'url.query': '',
'url.scheme': 'https',
'server.address': 'github.com',
'server.port': 443,
'user_agent.original': 'node',
'network.peer.address': '140.82.121.3',
'network.peer.port': 443,
'http.response.status_code': 200
},
status: { code: 0 },
events: [],
links: []
} P.S.Look at: open-telemetry/opentelemetry-js#3698 |
@nhz-io Thank you! I'm getting traction. I understand why/how separating the I spent a few minutes trying unsuccessfully to adapt your example to using the |
For
|
I see the example in the readme for Undici is using CommonJS syntax and also not using the NodeSDK constructor. Is there guidance about what the preferred methods are for demonstration purposes? https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/instrumentation-undici |
IMHO, make 2 demos, for CJS and ESM respectively. Both are in use (And this status is to stay this way for indefinite amount of time - there are no deprecation plans for CJS and i doubt that there ever will be) |
^ I opened a PR to drop that diag.debug message. It isn't helpful and can cause confusion like this. As was stated in comments above, it is totally reasonable for instrumentation-undici to not ahve any modules to patch. |
What version of OpenTelemetry are you using?
"@opentelemetry/instrumentation-undici": "^0.2.0",
"@opentelemetry/sdk-node": "^0.51.1",
What version of Node are you using?
20.12.1
What did you do?
Running this minimal example: https://github.com/digitalbazaar/otel-example/blob/main/index.js
Which produces the following output with the message that:
No modules instrumentation has been defined for '@opentelemetry/[email protected]', nothing will be patched
I am not seeing any spans related to the use of undici(fetch) being produced which I assume is related to the above message.
What does one need to do to get this instrumentation package working properly?
Thank you,
Matt
The text was updated successfully, but these errors were encountered: