-
Notifications
You must be signed in to change notification settings - Fork 489
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
update nodejs autoinstrumetation, fixes #2626 #3570
base: main
Are you sure you want to change the base?
update nodejs autoinstrumetation, fixes #2626 #3570
Conversation
@open-telemetry/javascript-approvers could you have a look? 🙏 |
0b6b81c
to
cf4ab32
Compare
a1389c9
to
04677de
Compare
Thank you @pavolloffay i fixed the build since getResourceDetectorsFromEnv is exported as getResourceDetectors |
Actually, I think since metrics auto-configuration is now implemented, you may not even need the |
Hi @pichlermarc, are you suggesting to remove autoinstrumentation.ts here and update the code in nodejs.go to something like:
Would this approach work when referenced like this? I haven’t tested it yet. Thank you PS @swiatekm, what’s your opinion on this? |
|
Something along these lines yes. I don't think you necessarily need to reference the full path - you may be able to just ref the entrypoint:
|
605e371
to
c6ed877
Compare
@pavolloffay @pichlermarc could you re-review this (I assume) final state of the change? @ElfoLiNk have you tested this with a real Node application? Our tests only check if the instrumented application starts, but not if it's actually emitting the right telemetry, so this should be verified manually with this kind of substantial change. |
pkg/instrumentation/nodejs.go
Outdated
@@ -22,7 +22,7 @@ import ( | |||
|
|||
const ( | |||
envNodeOptions = "NODE_OPTIONS" | |||
nodeRequireArgument = " --require /otel-auto-instrumentation-nodejs/autoinstrumentation.js" | |||
nodeRequireArgument = " --require /otel-auto-instrumentation-nodejs/node_modules/@opentelemetry/auto-instrumentations-node/build/src/register.js" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this work? That's the entrypoint we provide for these kinds of things.
nodeRequireArgument = " --require /otel-auto-instrumentation-nodejs/node_modules/@opentelemetry/auto-instrumentations-node/build/src/register.js" | |
nodeRequireArgument = " --require /otel-auto-instrumentation-nodejs/node_modules/@opentelemetry/auto-instrumentations-node/register" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried but i got
Error: Cannot find module '/otel-auto-instrumentation-nodejs/node_modules/@opentelemetry/auto-instrumentations-node/register'
I tested today, and everything seems to be working: OTEL_LOGS_EXPORTER is empty. Using default otlp exporter. I was testing it with this configuration:
The exporter endpoint was set to port 4317. The only issue I encountered was with the metrics exporter:
To resolve this, I explicitly added OTEL_EXPORTER_OTLP_PROTOCOL to the instrumentation configuration, which resolved the issue. Additionally, both the operator and instrumentation Docker images need to be updated simultaneously. If you update only the instrumentation, you encounter the following error:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me - @ElfoLiNk keep in mind that I only maintain the upstream OTel JS packages, I'm not a maintainer of this repo and I only have limited knowledge about the operator. The decision whether to merge this or not is fully in the hands of the operator maintainers.
The changes look good to me, but the following:
is a significant problem. We'd be breaking existing installations in a major way if the user sets their own nodejs instrumentation image. We might need a feature flag if we can't support both versions. @ElfoLiNk could we not support both older and newer images by keeping the NODE_OPTIONS as they are and symlinking |
Hi @swiatekm i added in the Dockerfile the old reference seems working |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ElfoLiNk we also need to make the new operator version compatible with older autoinstrumentation images. That would involve reverting your changes to nodejs.go
for now, and submitting a separate PR introducing a feature flag that will change the instrumentation require path. Does that make sense?
f041a32
to
6cbfc9f
Compare
6cbfc9f
to
b6e7636
Compare
Signed-off-by: matteo.gazzetta <[email protected]>
Signed-off-by: matteo.gazzetta <[email protected]>
Signed-off-by: matteo.gazzetta <[email protected]>
Signed-off-by: matteo.gazzetta <[email protected]>
@swiatekm looks good now? |
Thank you for the contribution, and your patience with the review process, @ElfoLiNk! I think this change is ready to be merged, but I'd like to wait for 0.119.0 to release first. |
Description:
Update nodejs autoinstrumentation like register.ts from auto-instrumentations-node metapackage
Link to tracking Issue(s):
OTEL_NODE_RESOURCE_DETECTORS
#2626Testing:
Not tested yet
Documentation: