Skip to content

refactor: Removed reliance on @opentelemetry/sdk-trace-base for hybrid agent - #4297

Open
bizob2828 wants to merge 1 commit into
newrelic:mainfrom
bizob2828:remove-otel-sdk-trace-base
Open

bizob2828 wants to merge 1 commit into
newrelic:mainfrom
bizob2828:remove-otel-sdk-trace-base

Conversation

@bizob2828

Copy link
Copy Markdown
Member

Description

This PR removes @opentelemetry/sdk-trace-base in lieu of building our own Span, TracerProvider and Tracer. I want to look into the options based into the old BasicTracerProvider to ensure we aren't missing anything. The span attribute limit is directly enforced on the span, but unsure of any hidden items.

Related Issues

Closes #4296

@codecov

codecov Bot commented Sep 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.70588% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 97.49%. Comparing base (8a83507) to head (967a430).

Files with missing lines Patch % Lines
lib/otel/traces/nr-span.js 99.41% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4297      +/-   ##
==========================================
- Coverage   97.56%   97.49%   -0.07%     
==========================================
  Files         529      532       +3     
  Lines       63765    64095     +330     
  Branches        1        1              
==========================================
+ Hits        62212    62490     +278     
- Misses       1553     1605      +52     
Flag Coverage Δ
integration-tests-cjs-22.x 73.82% <81.76%> (+0.07%) ⬆️
integration-tests-cjs-24.x 74.50% <81.76%> (+0.07%) ⬆️
integration-tests-cjs-26.x 74.50% <81.76%> (+0.07%) ⬆️
integration-tests-esm-22.x 54.66% <ø> (ø)
integration-tests-esm-24.x 56.27% <ø> (ø)
integration-tests-esm-26.x 56.27% <ø> (ø)
unit-tests-22.x 89.32% <99.70%> (+0.05%) ⬆️
unit-tests-24.x 89.27% <99.70%> (+0.05%) ⬆️
unit-tests-26.x 89.27% <99.70%> (+0.05%) ⬆️
versioned-tests-22.x 97.49% <99.70%> (-0.07%) ⬇️
versioned-tests-24.x 97.49% <99.70%> (-0.07%) ⬇️
versioned-tests-26.x 97.49% <99.70%> (-0.07%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 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.

}
if (links) {
this.links = links.map(truncateLink)
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

the otel implementation calls this.#processor.onStart(span, ctx), we do this in the tracer after the span is created, we should prob move it here ot be consistent

}

isRecording() {
return !this.#ended

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Suggested change
return !this.#ended
return this.#ended === false

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please 🙏

#sampler
#processor

constructor({ instrumentationScope, sampler, processor }) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this is prob fine but the otel Tracer allows options to be passed in. i'm trying to see if we need to consider them since this isn't controlled by user

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not sure about that. The options upstream accepts are quite minimal https://open-telemetry.github.io/opentelemetry-js/interfaces/_opentelemetry_api._opentelemetry_api.TracerOptions.html and seem irrelevant to us (I don't know. Their docs don't actually explain what anything is or does.).

@jsumners-nr jsumners-nr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd like to see at least one of the self-review comments addressed, but nothing in either review is a blocker for me. Everything seems reasonable.

Comment on lines +34 to +40
forceFlush() {
return Promise.resolve()
}

shutdown() {
return Promise.resolve()
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

These are methods on the baseline implementation upstream, not methods required by the interface. So they should be specific to the way upstream implements the other providers upstream supplies that extend from it.

Having stubs that match the outcome of upstream's implementations seems fine.

#sampler
#processor

constructor({ instrumentationScope, sampler, processor }) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not sure about that. The options upstream accepts are quite minimal https://open-telemetry.github.io/opentelemetry-js/interfaces/_opentelemetry_api._opentelemetry_api.TracerOptions.html and seem irrelevant to us (I don't know. Their docs don't actually explain what anything is or does.).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I won't block on this, but I do want to point out that I find these sorts of files more frustrating than helpful. The name of the file doesn't provide any hint as to what it contains or exports, and they tend to get filled with random stuff (even though this one is likely to remain small). Personally, I'd prefer to see:

  • lib/otel/traces/helpers/make-processor.js
  • lib/otel/traces/helpers/make-sampler.js

This branch has not been deployed

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

Labels

None yet

Projects

Status: Needs PR Review

Development

Successfully merging this pull request may close these issues.

Remove reliance on @opentelemetry/sdk-trace-base

3 participants