-
Notifications
You must be signed in to change notification settings - Fork 953
feat(opentelemetry-sdk-node): set resources and log provider for experimental start #6152
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
base: main
Are you sure you want to change the base?
Conversation
| } else if (config.node_resource_detectors) { | ||
| resourceDetectors = getResourceDetectorsFromConfiguration(config); | ||
| } else { | ||
| resourceDetectors = [ |
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.
Note for reviewers: this is the only thing that I changed compared to the "original".
Before we had only env, process and host, but if the value was all, or there was no value on env variable it was setting to all, and that included os and service instance id. We do say on our docs that the default is to have all detectors on.
We didn't add os and service instance id because we wanted to have them baking for awhile before adding, which I think we can do now.
But let me know if you don't think is a good idea to turn any of them by default
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6152 +/- ##
==========================================
- Coverage 95.40% 95.01% -0.40%
==========================================
Files 317 317
Lines 9433 9510 +77
Branches 2178 2206 +28
==========================================
+ Hits 9000 9036 +36
- Misses 433 474 +41
🚀 New features to boost your workflow:
|
JamieDanielson
left a 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.
Took a pass through this and added some notes.
| config: ConfigurationModel, | ||
| sdkOptions: SDKOptions, | ||
| resource: Resource | undefined | ||
| ): LoggerProvider | undefined { |
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.
| ): LoggerProvider | undefined { | |
| ): LoggerProvider { |
Is there a scenario where setupLoggerProvider would be undefined? setupResource only returns a Resource not undefined
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.
if you don't have any log provider on env variables or config file, there is no logger provider to be setup, so it will return undefined
| return undefined; | ||
| } | ||
|
|
||
| function getLogRecordExporter( |
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 this might be better to live in utils.ts for consistency. Then we can still do setupLoggerProvider in start.ts.
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.
Actually realizing we may want to move setupDefaultContextManager and setupPropagator into start.ts but that's a different PR. Then the config-reading utils are all in utils, and the setup functions are in start.
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.
Moved getLogRecordExporter to utils, setupDefaultContextManager to start (since no one else was using from there), but kept the setupPropagator on utils because the sdk.ts was using it
| } else if (exporter.console) { | ||
| return new ConsoleLogRecordExporter(); | ||
| } | ||
| diag.warn(`Unsupported Exporter value. Using OTLP http/protobuf.`); |
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.
🤔 If someone uses a config file but neglects to specify a valid exporter (otlp_http, otlp_grpc, otlp_file/development(soon), console)... should we default an exporter for them or should we consider it a noop because it's invalid? It's not clear to me.
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 believe I saw the default should be otlp_http in this case, so I kept at that.
| [RESOURCE_DETECTOR_PROCESS, processDetector], | ||
| ]); | ||
|
|
||
| const resourceDetectorsFromConfig = config.node_resource_detectors ?? ['all']; |
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 per config file spec this should be 'none' by default. This may differ from NodeSDK defaults today.
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.
are we okay with having this breaking change? we have our own docs saying the default is all
|
Note: tests will get fixed when this gets merged #6162 |
Fixes #5822
Note: Still need to add tests, but can be reviewed otherwise