-
Notifications
You must be signed in to change notification settings - Fork 804
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
Allow LoggerProvider to be specified in Instrumentations #4314
Allow LoggerProvider to be specified in Instrumentations #4314
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #4314 +/- ##
==========================================
+ Coverage 92.31% 92.35% +0.03%
==========================================
Files 108 328 +220
Lines 2213 9455 +7242
Branches 428 2011 +1583
==========================================
+ Hits 2043 8732 +6689
- Misses 170 723 +553
|
This functionality was discussed before in open-telemetry/opentelemetry-js-contrib#1713 (comment), thanks @trentm for letting me know about that, we can have different classes for Trace Instrumentations and Log Instrumenations, so we can have the definition of it and shared functionality in the same place avoiding different behaviors and duplication of code, @blumamir @pichlermarc thoughts? |
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. Can you please add tests for this functionality?
Note that in the earlier discussion, we had been leaning towards not adding a Other related comments from that issue: From open-telemetry/opentelemetry-js-contrib#1713 (comment)
open-telemetry/opentelemetry-js-contrib#1713 (comment)
|
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 think holding off on this feature for now is a better idea.
The Logs API is not stable yet, and while @opentelemetry/instrumentation
is also not stable I think we should start moving towards this. Also I think right now a very small percentage of instrumentations would make use of the logger for now.
I'm also not sure about the idea of having a separate class for Logging instrumentation, as that could make it difficult (it may encourage double wrapping libraries, for traces and for logs, and then there's a large potential of bugs where another instrumentation interferes with another one)
Just some thoughts, happy to be convinced otherwise though 🙂
@pichlermarc related to logs not being stable, I believe we should be pushing to stabilize both Log API and Instrumentation, Logs is quite important as well, we are working on adding more instrumentations including winston, bunyan and console to use the logger, so this will start to grow very soon, I'm more in favor of having Logger available for all instrumentations, would be similar to Meter, some instrumentations will use it and some other don't, what is preventing us to stabilize Logs API? |
But shouldn't the only instrumentations that would use a |
I agree, to my understanding this is the main idea of the Logs bridge. With events, I'd expect this to be a different story.
The API spec is stable so it's mainly a question of available bandwidth in the SIG. Anyone can pick up and drive the topic - in fact it would be highly appreciated. There has not been a lot of work after the initial prototyping so the first step would be to re-review the API based on spec compliance, then fix any issues - the same with the logs SDK. Then we would request a review from the Technical Committee, after that we integrate the API into the |
@pichlermarc great news, I would be more than happy to start the discussion of stabilizing Logs API, @trentm I understand logger would not be used by all instrumentations but what is the issue of logger being there?, instrumentations using the logger would be deviating from the common way and that is why I created this PR, without this the instrumentations will always use global loggerProvider and maybe that is ok but why having the options to specify providers in autoLoader in the first place then |
Ah, that is a good argument for this. https://github.com/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-instrumentation/README.md#selection-of-the-used-tracerprovidermeterprovider mentions "There might be usecase" for specifying providers other than the global ones for instrumentations. I haven't used this myself, so I don't know what use cases were in mind for that. I see a fair amount of I'm now okay with this change. |
^^ sorry for that self-assigning and unassigning. |
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 am now also in favor (we discussed this in a SIG meeting some time ago) and we came to the conclusion that adding it would be beneficial.
Looks good, thanks!
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.
LGTM, but nit about the changelog item now needing to move up.
@pichlermarc @dyladan looks like this PR is ready to merge, let me know if there is any additional feedback |
experimental/packages/opentelemetry-instrumentation/src/types.ts
Outdated
Show resolved
Hide resolved
…try#4314) * Allow LoggerProvider to be specified in Instrumentations * Update * Lint * Add test * npm i * Update changelog * npm i * marking setLoggerProvider as optional * Add check for possible undefined method * npm i
Which problem is this PR solving?
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
Allow LoggerProvider to be set for Instrumentations, so auto generation code for logs can use it, Bunyan, Winston, Pino, etc.
Fixes # (issue)
Short description of the changes
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Checklist: