@juspay/neurolink
Version:
The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types — generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002
51 lines (50 loc) • 2.75 kB
TypeScript
import { type Context } from "@opentelemetry/api";
import type { ReadableSpan, Span, SpanProcessor as OtelSpanProcessor } from "@opentelemetry/sdk-trace-base";
import type { ExporterRegistry } from "./exporterRegistry.js";
/**
* @description OpenTelemetry span processor that turns every observation span into `SpanData` and hands it to an `ExporterRegistry`, so one instrumentation feeds Langfuse, Datadog, Sentry and every other registered exporter. Spans that are not observations are skipped and their children are re-parented onto the nearest exported ancestor. Delivery never blocks the span's thread.
*/
export declare class ExporterSpanProcessor implements OtelSpanProcessor {
private readonly registry;
private readonly open;
private readonly ended;
/**
* @description Creates a processor bound to a registry.
* @param registry {ExporterRegistry} - Registry that receives every exported span.
*/
constructor(registry: ExporterRegistry);
/**
* @description Copies the propagated Langfuse trace attributes (user, session, trace name, tags, metadata) from the parent context onto the new span and remembers it until it ends.
* @param span {Span} - Span that just started.
* @param parentContext {Context} - Context the span was started in.
* @returns {void} Nothing.
*/
onStart(span: Span, parentContext: Context): void;
/**
* @description Exports an ended observation span without waiting for the exporters.
* @param span {ReadableSpan} - Span that just ended.
* @returns {void} Nothing.
*/
onEnd(span: ReadableSpan): void;
/**
* @description Flushes every exporter in the registry.
* @returns {Promise<void>} Resolves when all exporters have flushed.
*/
forceFlush(): Promise<void>;
/**
* @description Shuts down every exporter in the registry.
* @returns {Promise<void>} Resolves when all exporters have shut down.
*/
shutdown(): Promise<void>;
private exportQuietly;
private remember;
private nearestExportedAncestor;
}
/**
* @description Creates a span processor that feeds NeuroLink's observation spans to an exporter registry. Add it to a host `TracerProvider` to deliver spans through the registered exporters (such as `LangfuseExporter`) instead of `LangfuseSpanProcessor`.
* @param registry {ExporterRegistry} - Registry to export to; defaults to the process-wide registry.
* @returns {ExporterSpanProcessor} A processor ready to be added to a TracerProvider.
* @example
* const provider = new NodeTracerProvider({ spanProcessors: [createExporterSpanProcessor()] });
*/
export declare function createExporterSpanProcessor(registry?: ExporterRegistry): ExporterSpanProcessor;