Skip to content

Conversation

@maryliag
Copy link
Contributor

Fixes #5822

Note: Still need to add tests, but can be reviewed otherwise

@maryliag maryliag requested a review from a team as a code owner November 22, 2025 00:15
} else if (config.node_resource_detectors) {
resourceDetectors = getResourceDetectorsFromConfiguration(config);
} else {
resourceDetectors = [
Copy link
Contributor Author

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
Copy link

codecov bot commented Nov 22, 2025

Codecov Report

❌ Patch coverage is 46.75325% with 41 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.01%. Comparing base (169223d) to head (3aee374).

Files with missing lines Patch % Lines
...ental/packages/opentelemetry-sdk-node/src/start.ts 54.68% 29 Missing ⚠️
...ental/packages/opentelemetry-sdk-node/src/utils.ts 7.69% 12 Missing ⚠️
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     
Files with missing lines Coverage Δ
...ental/packages/opentelemetry-sdk-node/src/utils.ts 87.50% <7.69%> (-6.37%) ⬇️
...ental/packages/opentelemetry-sdk-node/src/start.ts 66.29% <54.68%> (-29.71%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@JamieDanielson JamieDanielson left a 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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
): LoggerProvider | undefined {
): LoggerProvider {

Is there a scenario where setupLoggerProvider would be undefined? setupResource only returns a Resource not undefined

Copy link
Contributor Author

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(
Copy link
Member

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.

Copy link
Member

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.

Copy link
Contributor Author

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.`);
Copy link
Member

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.

Copy link
Contributor Author

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'];
Copy link
Member

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.

Copy link
Contributor Author

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

@maryliag
Copy link
Contributor Author

Note: tests will get fixed when this gets merged #6162

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The Create operation returns LoggerProvider

2 participants