Closed
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Self-hosted/on-premise
Which SDK are you using?
@sentry/opentelemetry-node
SDK Version
7.49.0
Framework Version
No response
Link to Sentry event
No response
SDK Setup
Sentry.init({
dsn: SENTRY_DSN,
integrations: [
new Sentry.Integrations.Http({ tracing: false }),
new CaptureConsole({
levels: ['error', 'critical'],
}),
],
tracesSampleRate: SENTRY_TRACE_SAMPLING,
release: GIT_SHA,
environment: stack,
instrumenter: 'otel',
})
propagation.setGlobalPropagator(new SentryPropagator())
const tracer = (serviceName: string) => {
const provider = new NodeTracerProvider({
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: serviceName,
}),
sampler: new TraceIdRatioBasedSampler(SENTRY_TRACE_SAMPLING),
})
registerInstrumentations({
tracerProvider: provider,
instrumentations: getNodeAutoInstrumentations({
'@opentelemetry/instrumentation-fs': {
// this instrumentation causes excessive memory usage and we don't really need it
// https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1344
enabled: false,
},
'@opentelemetry/instrumentation-ioredis': {
requireParentSpan: true,
},
'@opentelemetry/instrumentation-http': {
applyCustomAttributesOnSpan: (span) => {
span.setAttribute('z_service_tag', serviceName)
span.setAttribute('stack_name', STACK_NAME)
},
},
}),
})
provider.addSpanProcessor(new SentrySpanProcessor())
// Initialize the OpenTelemetry APIs to use the NodeTracerProvider bindings
provider.register()
}
Steps to Reproduce
import * as SentryCore from '@sentry/core'
import * as Sentry from '@sentry/node'
// @ts-expect-error
import { SENTRY_SPAN_PROCESSOR_MAP } from '@sentry/opentelemetry-node/cjs/spanprocessor'
const fromMapTransaction = Array.from(SENTRY_SPAN_PROCESSOR_MAP.values()).filter(
(v) => v instanceof SentryCore.Transaction
)[0]
const fromScopeTransaction = Sentry.getCurrentHub().getScope().getTransaction()
console.log("fromMapTransaction: ", fromMapTransaction)
console.log("fromScopeTransaction: ", fromScopeTransaction)
I am trying to connect server and browser services with https://docs.sentry.io/platforms/javascript/performance/connect-services/#pageload so need to get the current transaction.
Expected Result
// fromMapTransaction: <ref *1> Transaction
// fromScopeTransaction: <ref *1> Transaction
Expect the same transaction
Actual Result
// fromMapTransaction: <ref *1> Transaction
// fromScopeTransaction: undefined
Metadata
Metadata
Assignees
Labels
No labels