-
Notifications
You must be signed in to change notification settings - Fork 637
Open
Labels
bugSomething isn't workingSomething isn't workingpkg:instrumentation-expresspriority:p2Bugs and spec inconsistencies which cause telemetry to be incomplete or incorrectBugs and spec inconsistencies which cause telemetry to be incomplete or incorrect
Description
What version of OpenTelemetry are you using?
2.2.0
What version of Node are you using?
v22.21.1
What did you do?
Initiated opentelemtry
const traceExporter = new OTLPTraceExporter();
const metricReader = new PeriodicExportingMetricReader({
// exporter: new ConsoleMetricExporter()
exporter: new OTLPMetricExporter()
});
const resource = resourceFromAttributes({
[ATTR_SERVICE_NAME]: global.APPLICATION,
[ATTR_SERVICE_VERSION]: global.VERSION
});
const sdk = new opentelemetry.NodeSDK({
resource: resource,
textMapPropagator: new CompositePropagator({
propagators: [new W3CTraceContextPropagator(), new W3CBaggagePropagator()]
}),
traceExporter,
metricReaders: [metricReader],
contextManager: new AsyncLocalStorageContextManager(),
instrumentations: [
getNodeAutoInstrumentations({
'@opentelemetry/instrumentation-express': {},
'@opentelemetry/instrumentation-http': {
startIncomingSpanHook: (request) => {
return {
["http.method"]: request.method,
}
}
},
'@opentelemetry/instrumentation-winston': {
logHook: (span, record) => {
record['resource.service.name'] = resource.attributes[ATTR_SERVICE_NAME];
record['resource.service.version'] = resource.attributes[ATTR_SERVICE_VERSION];
const currentBaggage = propagation.getActiveBaggage()
if (currentBaggage !== undefined) {
for(const key of ['client.id', 'user.id', 'graphql.operation', 'leav.attribute']) {
const baggageValue = currentBaggage.getEntry(key);
if(baggageValue !== undefined) {
record[key] = baggageValue.value;
}
}
}
}
}
}) // liste des instrumentations supportées https://www.npmjs.com/package/@opentelemetry/auto-instrumentations-node
]
});
Also, I defined the middleware in express
app.use((req, res, next) => {
req.baggage = (propagation.getActiveBaggage() || propagation.createBaggage())
.setEntry('client.id', {value: 'client-id'})
.setEntry('user.id', {value: 'some-user'});
context.with(propagation.setBaggage(context.active(), req.baggage), () => {
console.log("Current handler before next", propagation.getActiveBaggage()); //active bagage present
next()
console.log("Current handler after next", propagation.getActiveBaggage()); //active bagage present
});
})
app.use((req, res, next) => {
console.log("Next handler", propagation.getActiveBaggage()); //active bagage undefined
next();
})
What did you expect to see?
I expected baggage to be propagated
What did you see instead?
next handlers are executed without bagage
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingpkg:instrumentation-expresspriority:p2Bugs and spec inconsistencies which cause telemetry to be incomplete or incorrectBugs and spec inconsistencies which cause telemetry to be incomplete or incorrect