[NodeJS] Update fastify endpoint to use dd-trace's custom OTel context manager#6223
[NodeJS] Update fastify endpoint to use dd-trace's custom OTel context manager#6223
Conversation
|
|
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
💡 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".
| const api = require('@opentelemetry/api') | ||
| const ContextManager = require('dd-trace/packages/dd-trace/src/opentelemetry/context_manager') |
There was a problem hiding this comment.
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 👍 / 👎.
nccatoni
left a comment
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
this is done automatically by us. I copied this code over from the context_manager unit test
Update the fastify end point
otel_drop_in_baggage_api_otelto 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
🚀 Once your PR is reviewed and the CI green, you can merge it!
🛟 #apm-shared-testing 🛟
Reviewer checklist
tests/ormanifests/is modified ? I have the approval from R&P teambuild-XXX-imagelabel is present