-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nodejs doc: add clarification to node.js getting started #4191
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
maryliag
changed the title
nodejs doc: add clarifycation to node.js getting started
nodejs doc: add clarification to node.js getting started
Mar 21, 2024
One common approach to register de API is to set the environment variable `NODE_OPTIONS` with `--require @opentelemetry/auto-instrumentations-node/register`, but if we follow the `Getting Started` for `Node.js`, the step to use `--require ./instrumentation.ts` on command line can cause a conflict, resulting on an error message similar to: ``` Error: @opentelemetry/api: Attempted duplicate registration of API: trace at registerGlobal (/Users/maryliag/development/otel/opentelemetry-js/api/src/internal/global-utils.ts:47:17) at TraceAPI.setGlobalTracerProvider (/Users/maryliag/development/otel/opentelemetry-js/api/src/api/trace.ts:67:35) at NodeTracerProvider.register (/Users/maryliag/development/otel/opentelemetry-js/packages/opentelemetry-sdk-trace-base/src/BasicTracerProvider.ts:153:11) at NodeTracerProvider.register (/Users/maryliag/development/otel/opentelemetry-js/packages/opentelemetry-sdk-trace-node/src/NodeTracerProvider.ts:68:11) at NodeSDK.start (/Users/maryliag/development/otel/opentelemetry-js/experimental/packages/opentelemetry-sdk-node/src/sdk.ts:355:20) at Object.<anonymous> (/Users/maryliag/development/otel/nodejs-test/instrumentation.ts:17:5) at Module._compile (node:internal/modules/cjs/loader:1378:14) at Module.m._compile (/Users/maryliag/development/otel/nodejs-test/node_modules/ts-node/src/index.ts:1618:23) at Module._extensions..js (node:internal/modules/cjs/loader:1437:10) at Object.require.extensions.<computed> [as .ts] (/Users/maryliag/development/otel/nodejs-test/node_modules/ts-node/src/index.ts:1621:12) Error: @opentelemetry/api: Attempted duplicate registration of API: context at registerGlobal (/Users/maryliag/development/otel/opentelemetry-js/api/src/internal/global-utils.ts:47:17) at ContextAPI.setGlobalContextManager (/Users/maryliag/development/otel/opentelemetry-js/api/src/api/context.ts:53:26) at NodeTracerProvider.register (/Users/maryliag/development/otel/opentelemetry-js/packages/opentelemetry-sdk-trace-base/src/BasicTracerProvider.ts:159:15) at NodeTracerProvider.register (/Users/maryliag/development/otel/opentelemetry-js/packages/opentelemetry-sdk-trace-node/src/NodeTracerProvider.ts:68:11) at NodeSDK.start (/Users/maryliag/development/otel/opentelemetry-js/experimental/packages/opentelemetry-sdk-node/src/sdk.ts:355:20) at Object.<anonymous> (/Users/maryliag/development/otel/nodejs-test/instrumentation.ts:17:5) at Module._compile (node:internal/modules/cjs/loader:1378:14) at Module.m._compile (/Users/maryliag/development/otel/nodejs-test/node_modules/ts-node/src/index.ts:1618:23) at Module._extensions..js (node:internal/modules/cjs/loader:1437:10) at Object.require.extensions.<computed> [as .ts] (/Users/maryliag/development/otel/nodejs-test/node_modules/ts-node/src/index.ts:1621:12) Error: @opentelemetry/api: Attempted duplicate registration of API: propagation at registerGlobal (/Users/maryliag/development/otel/opentelemetry-js/api/src/internal/global-utils.ts:47:17) at PropagationAPI.setGlobalPropagator (/Users/maryliag/development/otel/opentelemetry-js/api/src/api/propagation.ts:67:26) at NodeTracerProvider.register (/Users/maryliag/development/otel/opentelemetry-js/packages/opentelemetry-sdk-trace-base/src/BasicTracerProvider.ts:163:19) at NodeTracerProvider.register (/Users/maryliag/development/otel/opentelemetry-js/packages/opentelemetry-sdk-trace-node/src/NodeTracerProvider.ts:68:11) at NodeSDK.start (/Users/maryliag/development/otel/opentelemetry-js/experimental/packages/opentelemetry-sdk-node/src/sdk.ts:355:20) at Object.<anonymous> (/Users/maryliag/development/otel/nodejs-test/instrumentation.ts:17:5) at Module._compile (node:internal/modules/cjs/loader:1378:14) at Module.m._compile (/Users/maryliag/development/otel/nodejs-test/node_modules/ts-node/src/index.ts:1618:23) at Module._extensions..js (node:internal/modules/cjs/loader:1437:10) at Object.require.extensions.<computed> [as .ts] (/Users/maryliag/development/otel/nodejs-test/node_modules/ts-node/src/index.ts:1621:12) ``` It can be hard to identify the problem from the error message. So this commit adds a small warning to make sure the requirements are not conflicting.
cartermp
approved these changes
Mar 22, 2024
/fix:format |
You triggered fix:format action run at https://github.com/open-telemetry/opentelemetry.io/actions/runs/8386497992 |
cartermp
approved these changes
Mar 22, 2024
6 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
One common approach to register de API is to set the environment variable
NODE_OPTIONS
with--require @opentelemetry/auto-instrumentations-node/register
, but if we follow theGetting Started
forNode.js
, the step to use--require ./instrumentation.ts
on command line can cause a conflict, resulting on an error message similar to:It can be hard to identify the problem from the error message. So this commit adds a small warning to make sure the requirements are not conflicting.
Run the instrumented app
after the change: