Skip to content

chore(sdk-node): migrate to the new sdk-trace package#6828

Merged
trentm merged 4 commits into
open-telemetry:mainfrom
trentm:trentm-use-sdk-trace-take1
Jun 19, 2026
Merged

chore(sdk-node): migrate to the new sdk-trace package#6828
trentm merged 4 commits into
open-telemetry:mainfrom
trentm:trentm-use-sdk-trace-take1

Conversation

@trentm

@trentm trentm commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

This deprecates the existing 'node' and 'tracing' re-exports of the sdk-trace-node and sdk-trace-base packages, which themselves will soon be deprecated.

We decided to not add a replacement re-export of the sdk-trace package.
The recommendation is now that users should export directly from the other packages.
See #6824 and #5461 for discussion.

Refs: #6775


This is the first of some changes to migrate all usages of sdk-trace-base, sdk-trace-node, and sdk-trace-web in the core and contrib repos over to sdk-trace. The usage in sdk-node was, I think, the big one. So it was helpful to do it in a separate PR.

There should be no functional change other than the added trace re-export (see src/index.ts).

This adds a new 'trace' export, which re-exports the sdk-trace package.
This is meant as a replacement for the existing 'node' and 'tracing'
re-exports of the sdk-trace-node and sdk-trace-base packages, which
will soon be deprecated.
@trentm trentm self-assigned this Jun 18, 2026
@trentm
trentm requested a review from a team as a code owner June 18, 2026 19:58
@codecov

codecov Bot commented Jun 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.71795% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 95.52%. Comparing base (e6e5e19) to head (16f091a).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
...s/opentelemetry-sdk-node/src/create-from-config.ts 93.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6828      +/-   ##
==========================================
+ Coverage   95.51%   95.52%   +0.01%     
==========================================
  Files         382      384       +2     
  Lines       12941    12974      +33     
  Branches     2967     2976       +9     
==========================================
+ Hits        12360    12394      +34     
+ Misses        581      580       -1     
Files with missing lines Coverage Δ
...ages/opentelemetry-sdk-node/src/create-from-env.ts 100.00% <100.00%> (ø)
...imental/packages/opentelemetry-sdk-node/src/sdk.ts 96.93% <100.00%> (+1.00%) ⬆️
...ental/packages/opentelemetry-sdk-node/src/start.ts 97.00% <100.00%> (-0.06%) ⬇️
...ental/packages/opentelemetry-sdk-node/src/utils.ts 96.41% <100.00%> (-0.09%) ⬇️
...s/opentelemetry-sdk-node/src/create-from-config.ts 93.33% <93.33%> (ø)
🚀 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.

} from '@opentelemetry/configuration';
import type { SpanLimits } from '@opentelemetry/sdk-trace';

export function createSpanLimitsFromConfig(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Note: This continues the create<SDK Thing>FromConfig() pattern started in #6785

I've also started moving "FromConfig"-specific things to this file, from the overly large "utils.ts".
I think it'll be helpful for maint and testing to separate the "FromEnv" handling and the "FromConfig" handling. Over a number of PRs I'll move/re-implement things in utils.ts over to "create-from-config.ts" and "create-from-env.ts".


const DEFAULT_RATIO = 1;

export function createSamplerFromEnv(): Sampler | undefined {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Note: Adapted from buildSamplerFromEnv in sdk-trace-base:

export function buildSamplerFromEnv(): Sampler {

return ratio;
}

export function createSpanLimitsFromEnv(): SpanLimits | undefined {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Note: Adapted from reconfigureLimits in sdk-trace-base:

export function reconfigureLimits(userConfig: TracerConfig): TracerConfig {

Comment on lines +23 to 27
export * as node from '@opentelemetry/sdk-trace-node';
/**
* @deprecated Use `trace` re-export from `@opentelemetry/sdk-trace` instead.
*/
export * as tracing from '@opentelemetry/sdk-trace-base';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Note: These existing re-exports are the only reason sdk-node cannot yet drop its dep on sdk-trace-node and sdk-trace-base. We'll drop these with SDK 3.0.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I see you opened #6824. If you're feeling adventurous, we could also try to remove it and see if anybody is unhappy with that. I'd be willing to bet that almost nobody is using these re-exports.

We don't need to do it in this PR though, let's keep this low-friction for now.

this._tracerProviderConfig = {
tracerConfig: tracerProviderConfig,
spanProcessors,
};

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Note: All of this handling of input config options for span processors is moved (and cleaned up) to and if-block in .start() below.

Comment on lines -212 to -220
if (configuration.sampler) {
tracerProviderConfig.sampler = configuration.sampler;
}
if (configuration.spanLimits) {
tracerProviderConfig.spanLimits = configuration.spanLimits;
}
if (configuration.idGenerator) {
tracerProviderConfig.idGenerator = configuration.idGenerator;
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Note: This tracerProviderConfig was never used.

@pichlermarc pichlermarc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Overall looks good, thanks for working on this 🙌
(just one comment about the re-exports; non-blocking)

Comment thread experimental/packages/opentelemetry-sdk-node/src/index.ts Outdated
@trentm
trentm enabled auto-merge June 19, 2026 18:09
@trentm
trentm disabled auto-merge June 19, 2026 18:09
@trentm trentm changed the title feat(sdk-node): migrate to the new sdk-trace package chore(sdk-node): migrate to the new sdk-trace package Jun 19, 2026
@trentm
trentm enabled auto-merge June 19, 2026 18:09
@trentm
trentm added this pull request to the merge queue Jun 19, 2026
Merged via the queue into open-telemetry:main with commit 9d7628f Jun 19, 2026
29 checks passed
@trentm
trentm deleted the trentm-use-sdk-trace-take1 branch June 19, 2026 18:17
@otelbot-js otelbot-js Bot mentioned this pull request Jul 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants