-
Notifications
You must be signed in to change notification settings - Fork 825
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(sdk-node): configure trace exporter with environment variables #3143
feat(sdk-node): configure trace exporter with environment variables #3143
Conversation
Signed-off-by: Svetlana Brennan <[email protected]>
Signed-off-by: Svetlana Brennan <[email protected]>
Signed-off-by: Svetlana Brennan <[email protected]>
Signed-off-by: Svetlana Brennan <[email protected]>
Signed-off-by: Svetlana Brennan <[email protected]>
Signed-off-by: Svetlana Brennan <[email protected]>
Signed-off-by: Svetlana Brennan <[email protected]>
Signed-off-by: Svetlana Brennan <[email protected]>
Signed-off-by: Svetlana Brennan <[email protected]>
Signed-off-by: Svetlana Brennan <[email protected]>
Signed-off-by: Svetlana Brennan <[email protected]>
Signed-off-by: Svetlana Brennan <[email protected]>
Signed-off-by: Svetlana Brennan <[email protected]>
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #3143 +/- ##
==========================================
- Coverage 93.36% 92.63% -0.74%
==========================================
Files 240 130 -110
Lines 7177 3124 -4053
Branches 1487 656 -831
==========================================
- Hits 6701 2894 -3807
+ Misses 476 230 -246
|
Signed-off-by: Svetlana Brennan <[email protected]>
Signed-off-by: Svetlana Brennan <[email protected]>
Signed-off-by: Svetlana Brennan <[email protected]>
Signed-off-by: Svetlana Brennan <[email protected]>
Signed-off-by: Svetlana Brennan <[email protected]>
Signed-off-by: Svetlana Brennan <[email protected]>
Signed-off-by: Svetlana Brennan <[email protected]>
Signed-off-by: Svetlana Brennan <[email protected]>
I have a question I wanted to ask @open-telemetry/javascript-approvers and @open-telemetry/javascript-maintainers before I can change this draft pr to ready for review. I want to remove the following code since it looks like it was an older attempt at configuring exporters from env: But I'm not 100% sure if this code is necessary here (especially items 2 and 3 above) and if it'll cause breaking changes if I remove that code. Any info/details you can share with me would be much appreciated! |
The (2) is to build a common span processor implementation for spans to send their start/end events. I don't think it should be removed. (1) and (2) are built upon the registration map |
Adding on this, this is definitly for this use case that i implemented this back then so that would be cleaner. The way it was supposed to be used is that the sdk extends the node tracer provider with its own exporters/propagators that can then be configured by the env |
Signed-off-by: Svetlana Brennan <[email protected]>
Signed-off-by: Svetlana Brennan <[email protected]>
Signed-off-by: Svetlana Brennan <[email protected]>
Signed-off-by: Svetlana Brennan <[email protected]>
Signed-off-by: Svetlana Brennan <[email protected]>
…nan/opentelemetry-js into add-trace-exporter-from-env
Signed-off-by: Svetlana Brennan <[email protected]>
Sorry for the delay on this. I was traveling for work. I've refactored the code to set up the span processors in the However, I have a question regarding this code:
I'm trying to only call
|
I've been looking into the code in a bit more detail regarding your questions @svetlanabrennan 🙂 As far as I can see, we could override the // part of TracerProviderWithEnvExporters
override addSpanProcessor(spanProcessor: SpanProcessor) {
super.addSpanProcessor(spanProcessor);
this._hasSpanProcessors = true;
}
override register(config?: SDKRegistrationConfig) {
if (this._hasSpanProcessors) {
super.register(config);
}
} If I am not mistaken, this way it should be possible to call |
experimental/packages/opentelemetry-sdk-node/src/TracerProviderWithEnvExporter.ts
Outdated
Show resolved
Hide resolved
experimental/packages/opentelemetry-sdk-node/src/TracerProviderWithEnvExporter.ts
Outdated
Show resolved
Hide resolved
This is great feedback. This does remove the need to check for the I think just overriding the // in the TracerProviderWithEnvExporters
override register(config?: SDKRegistrationConfig) {
if (this._spanProcessors) {
super.register(config);
}
} |
Signed-off-by: Svetlana Brennan <[email protected]>
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.
Thank you for working on this and addressing the comments. 🙂
This is looking great. 🎉
} | ||
|
||
override register(config?: SDKRegistrationConfig) { | ||
if (this._spanProcessors) { |
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.
The original intent of suggesting to override the addSpanProcessor()
method too and keeping track of calls, was to future-proof this in case this class is ever exported from this package. 🙂 As addSpanProcessor()
is public
, it could be called outside of the constructor. Then registration would not take place when register()
is called. 🤔
This is non-blocking for me though 🙂
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.
That's fine with me. It's a simple change and future-proof like you said. :)
Signed-off-by: Svetlana Brennan <[email protected]>
…nan/opentelemetry-js into add-trace-exporter-from-env
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.
Overall LGTM. Thank you for working on this! Just a small nit.
Signed-off-by: Svetlana Brennan <[email protected]>
Which problem is this PR solving?
Spec says a user can set an exporter via environment variable with
OTEL_TRACES_EXPORTER
and specify otlp protocol withOTEL_EXPORTER_OTLP_PROTOCOL
or signal specific protocol.This exporter configuration has been added to the
sdk-node
package and only applies when the user hasn't set up an exporter or span processor with code (in theirtracing.js
file).If a user doesn't set up an exporter in code or a span processor in code or doesn't provide a custom exporter via env vars, the sdk-node will set up a default
otlp
exporter with ahttp/protobuf
protocol.Fixes #2873
Short description of the changes
environment.ts
filesdk-node
package insdk.ts
fileType 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:
ToDo
_buildExporterFromEnv()
in the BasicTracerProvider