-
Notifications
You must be signed in to change notification settings - Fork 538
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
feat(auto-instrumentations-node): enabling instrumentations via env #1953
feat(auto-instrumentations-node): enabling instrumentations via env #1953
Conversation
I thought I'll share the investigation results that motivated this PR: SummaryAuto-instrumentation is much slower compared to instrumentation after application has loaded dependencies:
When performing instrumentation after loading application bootstrap import modules, application startup took just 1.5 seconds. Auto-instrumentation (with
Disabling resource detectors didn’t have a visible effect on startup time with instrumentation agentWhile disabling resource detectors could be uselful to store less information in each span, disabling all detectors (using In which startup phase the time is spent?
Profiling application startup locally revealed that almost all the time is wasted on loading node modules
|
3c4bc0a
to
e28a616
Compare
@obecny, could you take a look? |
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.
thx for this contribution, few suggestions with regards to naming so they are more descriptive, other than that would lgtm, thx
looking at the comment when this idea comes from, I would also think about adding |
3f547dd
to
c7393d9
Compare
@obecny, thanks for super-quick feedback. Adding another variable OTEL_DISABLED_NODE_INSTRUMENTATIONS sounds good, but i would leave it out of this PR, because
What do you think? |
definitely in next PR, that was just suggestions and some more info why having "enabled" in name would make possible to have 2 features and then user can set it much easier. |
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.
thx for changes, lgtm
@obecny, thanks for the feedback and approving the PR! It seems that I can't merge this PR myself and I need help from you regarding 2 topics:
Perhaps You'll mark CR comment threads also as resolved Yourself? (I could do it myself, but IMHO the reviewer should decide if it is resolved or not ;) )
@obecny, can you merge the PR yourself or should i do smth else myself to get it merged? |
c7393d9
to
14ba7da
Compare
@obecny, can you merge the PR yourself or should i do smth else myself to get it merged? |
unfortunately not, you will have to wait for someone with at least js approver privileges |
@open-telemetry/javascript-approvers, please approve this PR - @obecny, who is the component owner for auto-instrumentations-node, has already aproved it |
14ba7da
to
8d9db85
Compare
@pichlermarc , if i understood the note
under Your GH profile correctly, then you should be member of javascript-approvers whom i pined (after component owner approved this pr) without getting a response. Can you merge it and release it yourself or is there smth else I need to do? I'd really like to start using it in lots of our projects. |
8d9db85
to
46937b9
Compare
@blumamir, can you merge this PR? Looks like you have the merge permissions that the component-owner (who approved this PR doesn't have) |
46937b9
to
781e49d
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #1953 +/- ##
==========================================
- Coverage 90.97% 90.86% -0.12%
==========================================
Files 146 143 -3
Lines 7492 7379 -113
Branches 1502 1471 -31
==========================================
- Hits 6816 6705 -111
+ Misses 676 674 -2
|
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.
Sorry, was busy with other PRs and was not able to pick up a new feature to review yet.
Also it looks like this package was not owned by the maintainers so we did not get auto-assigned (opened #1996 to fix that)
Generally looks good % comments (env var naming and lint fixes) 👍
I agree with this. I think it's good to hold off on implementing this and would argue that a follow up to implement this is not necessary. Let's see if there's people who have a real need for it first. I think the here implemented option of explicitly opting-in to instrumentations will be preferred by most. |
74cb0d7
to
d257d02
Compare
d257d02
to
ac4e913
Compare
@pichlermarc, thanks for approving! |
I'm going to merge it now, but the release will only happen next week as I'd like to avoid releasing on a Friday. |
Hurray! Was waiting for this for so long! |
Which problem is this PR solving?
Allowing to speed up application startup time by allowing to disable instrumentations that are not needed via environment variable for use-cases where it isn't possible to disable instrumentations via
inputConfigs
object passed to getNodeAutoInstrumentations(inputConfigs) (like when using Kubernetes opentelemetry-operator - its instrumentation code can't be customized by applications running in the Kubernetes cluster). More information in this commentShort description of the changes
This PR allows enabling instrumentations selected via
OTEL_NODE_ENABLED_INSTRUMENTATIONS
environment variable while disabling others.To keep backwards compatibility, by default all instrumentations are still enabled when the environment variable isn't provided.
Usage example:
as documented in the README change:
To enable only
@opentelemetry/instrumentation-http
and @opentelemetry/instrumentation-nestjs-core
instrumentations:
Alternative approaches considered
In this comment I proposed two approaches how to enable/disable specific instrumentations via environment variables.
This PR implements the first approach. The benefits of this approach are:
This does not prevent implementing later also second approach backwards compatibly.
Could implement it for example so that globally only few instrumentations are enabled for all applications using
OTEL_NODE_ENABLED_INSTRUMENTATIONS
and each application could enable additional instrumentations with second approach based on additional environment variables for each instrumentation