Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/node
SDK Version
8.43.0
Framework Version
Node js 20.12.2
Link to Sentry event
No response
Reproduction Example/SDK Setup
First, we initialize sentry using:
Sentry.init({dsn: process.env.SENTRY_DSN,environment: process.env.SENTRY_ENVIRONMENT||'local',release: process.env.BUILD_VERSION||'local_version',skipOpenTelemetrySetup: true,// We have our custom OpenTelemetry setupregisterEsmLoaderHooks: false,beforeBreadcrumb(){returnnull;},// Disable breadcrumbsbeforeSend(event,hint){// some stuff that doesn't affect this in any way},});Next, we initialize OpenTelemetry SDK using:
importtype{InstrumentationConfig}from'@opentelemetry/instrumentation';import{AwsInstrumentation,typeAwsSdkInstrumentationConfig}from'@opentelemetry/instrumentation-aws-sdk';import{DnsInstrumentation,typeDnsInstrumentationConfig}from'@opentelemetry/instrumentation-dns';import{ExpressInstrumentation,typeExpressInstrumentationConfig}from'@opentelemetry/instrumentation-express';import{FsInstrumentation,typeFsInstrumentationConfig}from'@opentelemetry/instrumentation-fs';import{HttpInstrumentation,typeHttpInstrumentationConfig}from'@opentelemetry/instrumentation-http';import{IORedisInstrumentation,typeIORedisInstrumentationConfig}from'@opentelemetry/instrumentation-ioredis';import{MongoDBInstrumentation,typeMongoDBInstrumentationConfig}from'@opentelemetry/instrumentation-mongodb';import{NestInstrumentation}from'@opentelemetry/instrumentation-nestjs-core';import{NetInstrumentation}from'@opentelemetry/instrumentation-net';import{envDetectorSync}from'@opentelemetry/resources';import{NodeSDK}from'@opentelemetry/sdk-node';constsdk=newNodeSDK({instrumentations: [newAwsInstrumentation({// This hides the underlying HTTP spans that aren't useful since we already have instrumentation for AWS SDKsuppressInternalInstrumentation: true,
...config?.awsInstrumentationConfig,}),newDnsInstrumentation(config?.dnsInstrumentationConfig),newExpressInstrumentation(config?.expressInstrumentationConfig),newFsInstrumentation(config?.fsInstrumentationConfig),newHttpInstrumentation({ignoreIncomingRequestHook(req){// Do not include health check, icon, and metrics endpoints in traces.constisHealthCheckIconOrMetricsUrl=['/health-check','/favicon.ico','/metrics'].includes(req.url||'');returnisHealthCheckIconOrMetricsUrl;},
...config?.httpInstrumentationConfig,}),newIORedisInstrumentation(config?.ioRedisInstrumentationConfig),newMongoDBInstrumentation(config?.mongoDBInstrumentationConfig),newNestInstrumentation(config?.nestInstrumentationConfig),newNetInstrumentation(config?.netInstrumentationConfig),],resourceDetectors: [envDetectorSync],});sdk.start();Steps to Reproduce
If you use the setup above, you'll have spans that look like following (coming from debug OpenTelemetry logs):
Span {
attributes: {
'http.url': 'http://localhost:3333/v2/users/me?token=secret',
'http.host': 'localhost:3333',
'net.host.name': 'localhost',
'http.method': 'GET',
'http.scheme': 'http',
'http.target': '/v2/users/me?token=secret',
'http.user_agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36',
'http.flavor': '1.1',
'net.transport': 'ip_tcp',
'sentry.origin': 'auto.http.otel.http',
'net.host.ip': '::1',
'net.host.port': 3333,
'net.peer.ip': '::1',
'net.peer.port': 59381,
'http.status_code': 200,
'http.status_text': 'OK'
},
}
If I turn Sentry instrumentation off, there'll also be http.route, which is coming from OpenTelemetry express instrumentation.
If I instrument OpenTelemetry before Sentry, it breaks the ignoreIncomingRequestHook defined above (i.e. it doesn't get called at all, probably overwritten by something from Sentry)
Expected Result
The expected span would be something like the following (which I can get when I turn Sentry off):
Span {
attributes: {
'http.url': 'http://localhost:3333/v2/users/me?token=secret',
'http.host': 'localhost:3333',
'net.host.name': 'localhost',
'http.method': 'GET',
'http.scheme': 'http',
'http.target': '/v2/users/me?token=secret',
'http.user_agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36',
'http.flavor': '1.1',
'net.transport': 'ip_tcp',
'net.host.ip': '::1',
'net.host.port': 3333,
'net.peer.ip': '::1',
'net.peer.port': 61320,
'http.status_code': 200,
'http.status_text': 'OK',
'http.route': '/v2/users/:username'
},
}
you can notice the http.route at the end, that's what's missing.
Actual Result
Span {
attributes: {
'http.url': 'http://localhost:3333/v2/users/me?token=secret',
'http.host': 'localhost:3333',
'net.host.name': 'localhost',
'http.method': 'GET',
'http.scheme': 'http',
'http.target': '/v2/users/me?token=secret',
'http.user_agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36',
'http.flavor': '1.1',
'net.transport': 'ip_tcp',
'sentry.origin': 'auto.http.otel.http',
'net.host.ip': '::1',
'net.host.port': 3333,
'net.peer.ip': '::1',
'net.peer.port': 59381,
'http.status_code': 200,
'http.status_text': 'OK'
},
}
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/node
SDK Version
8.43.0
Framework Version
Node js 20.12.2
Link to Sentry event
No response
Reproduction Example/SDK Setup
First, we initialize sentry using:
Next, we initialize OpenTelemetry SDK using:
Steps to Reproduce
If you use the setup above, you'll have spans that look like following (coming from debug OpenTelemetry logs):
If I turn Sentry instrumentation off, there'll also be
http.route, which is coming from OpenTelemetry express instrumentation.If I instrument OpenTelemetry before Sentry, it breaks the
ignoreIncomingRequestHookdefined above (i.e. it doesn't get called at all, probably overwritten by something from Sentry)Expected Result
The expected span would be something like the following (which I can get when I turn Sentry off):
you can notice the
http.routeat the end, that's what's missing.Actual Result