UNPKG

@sentry/node

Version:

Sentry Node SDK using OpenTelemetry for performance instrumentation

54 lines (50 loc) • 1.44 kB
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); const core = require('@sentry/core'); class SentryBullMQContextManager { active() { return { span: core.getActiveSpan(), scope: core.getCurrentScope() }; } with(context, fn) { if (context.span) { return core.withIsolationScope(() => { return core.withActiveSpan(context.span, fn); }); } return core.withIsolationScope(() => core.withActiveSpan(null, fn)); } /** * Returns a context without a span. BullMQ 6.3.11+ runs the stalled jobs checker in it, so the * checker does not stay attached to the span that was active when the worker started. */ root() { return { span: void 0, scope: core.getCurrentScope() }; } getMetadata(context) { if (context.span) { return core.spanToTraceHeader(context.span); } return ""; } fromMetadata(activeContext, metadata) { const traceparent = core.extractTraceparentData(metadata); if (!traceparent?.traceId || !traceparent?.parentSpanId) { return activeContext; } return { ...activeContext, producerSpanContext: { traceId: traceparent.traceId, spanId: traceparent.parentSpanId, sampled: traceparent.parentSampled === true } }; } } exports.SentryBullMQContextManager = SentryBullMQContextManager; //# sourceMappingURL=contextManager.js.map