@juspay/neurolink
Version:
Universal AI Development Platform with working MCP integration, multi-provider support, voice (TTS/STT/realtime), and professional CLI. 58+ external MCP servers discoverable, multimodal file processing, RAG pipelines. Build, test, and deploy AI applicatio
19 lines (18 loc) • 681 B
JavaScript
import { trace, context } from "@opentelemetry/api";
/**
* Extract the current OTel trace context for use by Pipeline B spans.
* Returns undefined values when no OTel context is active, allowing
* Pipeline B spans to share the same trace as Pipeline A spans.
*/
export function getActiveTraceContext() {
const activeSpan = trace.getSpan(context.active());
if (!activeSpan) {
return {};
}
const ctx = activeSpan.spanContext();
// Invalid trace IDs are all zeros — don't use those
if (!ctx.traceId || ctx.traceId === "00000000000000000000000000000000") {
return {};
}
return { traceId: ctx.traceId, parentSpanId: ctx.spanId };
}