otel-nestjs-instrumentation
Version:
Comprehensive OpenTelemetry instrumentation for NestJS applications - SQS, Kafka, HTTP/2, cron jobs and custom protocols
23 lines • 913 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.startOtelInstrumentationIfAbsent = startOtelInstrumentationIfAbsent;
const internal_1 = require("./internal");
function startOtelInstrumentationIfAbsent(context, internalContext, emitter, effectiveType) {
const existingTraceId = internal_1.otelInstrumentation.getCurrentTransactionId();
if (existingTraceId)
return;
let traceId;
const transactionName = (0, internal_1.getTransactionName)(context);
try {
traceId = internal_1.otelInstrumentation.create(transactionName, context, effectiveType);
}
catch (error) {
emitter.emit('spanStartFailed', error);
return;
}
if (!traceId)
return;
internalContext.customTransactionId = traceId;
emitter.emit('spanStarted', traceId, context);
}
//# sourceMappingURL=start-otel-instrumentation-if-absent.js.map