opentelemetry-js
opentelemetry-js copied to clipboard
Same traceID printed, while two incoming requests in parallel.
I'm trying to propagate the context in hapi js code using AsyncHooksContextManager
The issue which I'm facing is, when two requests are hit in parallel, both the requests takes the same traceId. Instead I want two different traceId to be propagated. Below given is the sample snippet.
`const { context, trace } = require('@opentelemetry/api'); const { v4: uuidv4 } = require('uuid'); const { AsyncHooksContextManager } = require('@opentelemetry/context-async-hooks'); // Initialize the async hooks context manager const contextManager = new AsyncHooksContextManager(); contextManager.enable(); context.setGlobalContextManager(contextManager);
// and then in 'onRequest' middleware
await context.with(trace.setSpan(context.active(), trace.getActiveSpan()), async () => { h.continue() }
`
Am I missing anything here? Kindly guide.
- Hapi - version 16.1.0
- node - version 14
- sequelize - 5.21.3