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
10.50.0
Framework Version
No response
Link to Sentry event
No response
Reproduction Example/SDK Setup
See below
// Minimal repro for Sentry OTEL service.name behavior.
// Run with:
// OTEL_SERVICE_NAME=my-app OTEL_RESOURCE_ATTRIBUTES=service.namespace=my-namespace,other_attr=foo node sentry_otel_service_name.js
const Sentry = require("@sentry/node")
Sentry.init({
dsn: "https://public@example.ingest.sentry.io/1",
tracesSampleRate: 1.0,
})
const client = Sentry.getClient()
const traceProvider = client?.traceProvider
const resource =
traceProvider?._resource ?? traceProvider?._config?.resource ?? null
const resourceAttrs = resource?.attributes ?? {}
console.log("OTEL_SERVICE_NAME env:", process.env.OTEL_SERVICE_NAME)
console.log(
"OTEL_RESOURCE_ATTRIBUTES env:",
process.env.OTEL_RESOURCE_ATTRIBUTES,
)
console.log("traceProvider resource attributes:", resourceAttrs)
Steps to Reproduce
- Save script above as
sentry_otel_service_name.js with @sentry/node installed at v10.50.0
- Run
OTEL_SERVICE_NAME=my-app OTEL_RESOURCE_ATTRIBUTES=service.namespace=learn-local,other_attr=foo node sentry_otel_service_name.js
- Observe the output:
OTEL_SERVICE_NAME env: my-app
OTEL_RESOURCE_ATTRIBUTES env: service.namespace=my-namespace,other_attr=foo
traceProvider resource attributes: {
'service.name': 'node',
'service.namespace': 'sentry',
'service.version': '10.50.0',
'telemetry.sdk.language': 'nodejs',
'telemetry.sdk.name': 'opentelemetry',
'telemetry.sdk.version': '2.7.0'
}
Expected Result
The OTEL setup should respect OTEL_SERVICE_NAME. It would be great to also respect OTEL_RESOURCE_ATTRIBUTES
With the script above, I would expect:
traceProvider resource attributes: {
'service.name': 'my-app',
'service.namespace': 'my-namespace',
'service.version': '10.50.0',
'telemetry.sdk.language': 'nodejs',
'telemetry.sdk.name': 'opentelemetry',
'telemetry.sdk.version': '2.7.0'
other_attr: 'foo'
}
Actual Result
OTEL_SERVICE_NAME and OTEL_RESOURCE_ATTRIBUTES are ignored. Sentry always uses OTEL_SERVICE_NAME as the service.name value. (See steps to reproduce above.)
Workaround: Application code adds a custom span/resource override processor to rewrite resource attributes (service.name, service.namespace, service.version) before export.
Additional Context
|
resource: getSentryResource('node'), |
seems to be where
service.name gets set to
"node".
Priority
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.
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
10.50.0
Framework Version
No response
Link to Sentry event
No response
Reproduction Example/SDK Setup
See below
Steps to Reproduce
sentry_otel_service_name.jswith@sentry/nodeinstalled at v10.50.0OTEL_SERVICE_NAME=my-app OTEL_RESOURCE_ATTRIBUTES=service.namespace=learn-local,other_attr=foo node sentry_otel_service_name.jsExpected Result
The OTEL setup should respect OTEL_SERVICE_NAME. It would be great to also respect OTEL_RESOURCE_ATTRIBUTES
With the script above, I would expect:
Actual Result
OTEL_SERVICE_NAME and OTEL_RESOURCE_ATTRIBUTES are ignored. Sentry always uses OTEL_SERVICE_NAME as the
service.namevalue. (See steps to reproduce above.)Workaround: Application code adds a custom span/resource override processor to rewrite resource attributes (
service.name,service.namespace,service.version) before export.Additional Context
sentry-javascript/packages/node/src/sdk/initOtel.ts
Line 93 in b045541
service.namegets set to"node".Priority
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding
+1orme too, to help us triage it.