-
Notifications
You must be signed in to change notification settings - Fork 805
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: allow extending BasicTracerProvider
with custom registered components
#3023
feat: allow extending BasicTracerProvider
with custom registered components
#3023
Conversation
Codecov Report
@@ Coverage Diff @@
## main #3023 +/- ##
==========================================
+ Coverage 93.06% 93.08% +0.01%
==========================================
Files 188 188
Lines 6248 6246 -2
Branches 1313 1313
==========================================
- Hits 5815 5814 -1
+ Misses 433 432 -1
|
8592c41
to
1dfe5a4
Compare
I'm not sure to understand your use case, you should be able to add your exporters/propagators in |
That's exactly the idea, yes. |
Okay but that's exactly what the current implementation allows, i don't see why you need to change anything ^^ |
Well, why does Because of the hardcoded usage of |
04517e9
to
3ed5527
Compare
db47c18
to
3c59d9f
Compare
49305d5
to
032a9b6
Compare
032a9b6
to
6c9b998
Compare
Because i though it was fine to override two both at the time, i agree that it's possible to simplify and only have to override |
My bad - The implementation did technically work, but required overrides in two locations which was the point for my confusion. Unfortunately the simplification did require more work than I expected to ensure the backwards compatibility. Hopefully we can remove that trickery at some point. |
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 % one nit
packages/opentelemetry-sdk-trace-node/src/NodeTracerProvider.ts
Outdated
Show resolved
Hide resolved
packages/opentelemetry-sdk-trace-node/src/NodeTracerProvider.ts
Outdated
Show resolved
Hide resolved
packages/opentelemetry-sdk-trace-base/test/common/BasicTracerProvider.test.ts
Outdated
Show resolved
Hide resolved
packages/opentelemetry-sdk-trace-base/test/common/BasicTracerProvider.test.ts
Show resolved
Hide resolved
@rauno56 friendly ping -- any updates on this? |
Thanks for the reminder! Addressed all the comments, good to go once the CI is green. |
@blumamir since you had comments on this could you check it again and merge if it looks good to you ? |
Which problem is this PR solving?
Extending
BasicTracerProvider
still takes registered propagators and exporters from the static members ofBasicTracerProvider
, not the child class.Typing is not ideal, TS doesn't support this usecase afaik, but I think it's safe to assume the types will stay the same in the hierarchy tree so I'm casting it to whatever the respective
BasicTracerProvider
member is.Short description of the changes
Fix by dynamically referencing
_registeredPropagators
and_registeredExporters
from the class. Extender might still want to override the getter, but only if they actually want to change the logic which is used, and not when they only change the Map.Also tidied up some of the tests while I was at it and added tests for the old use-case to make sure that extending works for people whichever way they do it.
Type of change
Please delete options that are not relevant.
Checklist: