Skip to content

[NodeJS] Update fastify endpoint to use dd-trace's custom OTel context manager#6223

Merged
ida613 merged 2 commits intomainfrom
ida613/otel-baggage-api-fix
Feb 10, 2026
Merged

[NodeJS] Update fastify endpoint to use dd-trace's custom OTel context manager#6223
ida613 merged 2 commits intomainfrom
ida613/otel-baggage-api-fix

Conversation

@ida613
Copy link
Copy Markdown
Contributor

@ida613 ida613 commented Feb 5, 2026

Update the fastify end point otel_drop_in_baggage_api_otel to use dd-trace-js's custom OTel context manager. Before this change, OpenTelemetry api calls in this end point do not go through any of the otel drop in support code within dd-trace-js.

Changes

Workflow

  1. ⚠️ Create your PR as draft ⚠️
  2. Work on you PR until the CI passes
  3. Mark it as ready for review
    • Test logic is modified? -> Get a review from RFC owner.
    • Framework is modified, or non obvious usage of it -> get a review from R&P team

🚀 Once your PR is reviewed and the CI green, you can merge it!

🛟 #apm-shared-testing 🛟

Reviewer checklist

  • Anything but tests/ or manifests/ is modified ? I have the approval from R&P team
  • A docker base image is modified?
    • the relevant build-XXX-image label is present
  • A scenario is added, removed or renamed?

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 5, 2026

CODEOWNERS have been resolved as:

utils/build/docker/nodejs/fastify/app.js                                @DataDog/dd-trace-js @DataDog/system-tests-core

@datadog-datadog-prod-us1

This comment has been minimized.

@ida613 ida613 marked this pull request as ready for review February 6, 2026 19:09
@ida613 ida613 requested review from a team as code owners February 6, 2026 19:09
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 25c33399d1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 611 to +612
const api = require('@opentelemetry/api')
const ContextManager = require('dd-trace/packages/dd-trace/src/opentelemetry/context_manager')
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Use a dd-trace path that exists in npm installs

This endpoint now requires dd-trace/packages/dd-trace/src/opentelemetry/context_manager, but in the default Docker build dd-trace is installed from npm (see utils/build/docker/nodejs/install_ddtrace.sh). The published package doesn’t include the monorepo path packages/dd-trace/..., so require will throw MODULE_NOT_FOUND and the endpoint will 500 in the common npm-install case. This only works when the monorepo layout is present (e.g., a local repo build), so the endpoint becomes broken for standard installs.

Useful? React with 👍 / 👎.

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.

how do i fix it?

Copy link
Copy Markdown
Collaborator

@nccatoni nccatoni left a comment

Choose a reason for hiding this comment

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

The tests are passing so I would say it's, ok but you should get a review from someone familiar with the weblog

const baggageToSet = baggageSet ? baggageSet.split(',').map(item => item.split('=')) : []

const contextManager = new ContextManager()
api.context.setGlobalContextManager(contextManager)
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.

Is adding this code to an application going to be a required step for all users of the OTel Baggage API? Or can this be done automatically by us?

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.

this is done automatically by us. I copied this code over from the context_manager unit test

Copy link
Copy Markdown
Contributor

@zacharycmontoya zacharycmontoya left a comment

Choose a reason for hiding this comment

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

LGTM

@ida613 ida613 merged commit 88acc76 into main Feb 10, 2026
179 checks passed
@ida613 ida613 deleted the ida613/otel-baggage-api-fix branch February 10, 2026 17:28
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.

3 participants