UNPKG

nestjs-otel

Version:
17 lines (16 loc) 669 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CurrentSpan = exports.currentSpanParamFactory = void 0; const common_1 = require("@nestjs/common"); const api_1 = require("@opentelemetry/api"); const currentSpanParamFactory = (_data, _ctx) => { const span = api_1.trace.getSpan(api_1.context.active()); return span; }; exports.currentSpanParamFactory = currentSpanParamFactory; /** * Decorator to retrieve the current OpenTelemetry Span from the active context. * * @returns The current Span or undefined if no span is active. */ exports.CurrentSpan = (0, common_1.createParamDecorator)(exports.currentSpanParamFactory);