JudgmentTracerProvider
Global singleton that manages tracer registration and context propagation. Acts as a proxy TracerProvider that delegates to the currently active tracer's underlying OpenTelemetry provider.
Global singleton that manages tracer registration and context propagation.
Acts as a proxy TracerProvider that delegates to the currently active tracer's underlying OpenTelemetry provider.
Static MethodgetInstance()
Get the singleton JudgmentTracerProvider instance.
function getInstance(): JudgmentTracerProviderReturns
JudgmentTracerProvider - The global provider instance.
Static Method
installAsGlobalTracerProvider()
Install the JudgmentTracerProvider as the global tracer provider. This generally does not need to be called - Judgeval automatically uses this for all its observability functionality. Only use this if you specifically want to override the global tracer provider, which will enable all Opentelemetry captured instrumentations to flow through judgeval.
function installAsGlobalTracerProvider(): booleanReturns
boolean - True if the installation was successful, false otherwise.
register()
Register a tracer with the provider.
function register(tracer: BaseTracer): voidParameters
tracer
required:BaseTracer
The tracer to register.
Returns
void
deregister()
Remove a tracer from the provider.
function deregister(tracer: BaseTracer): voidParameters
tracer
required:BaseTracer
The tracer to deregister.
Returns
void
setActive()
Set a tracer as the active tracer.
Cannot be called while a root span is active.
function setActive(tracer: BaseTracer): booleanParameters
tracer
required:BaseTracer
The tracer to activate.
Returns
boolean - true if activation succeeded.
getActiveTracer()
Get the currently active tracer.
function getActiveTracer(): BaseTracer | nullReturns
BaseTracer | null - The active tracer, or null if none.
getCurrentContext()
Get the current OpenTelemetry context.
function getCurrentContext(): ContextReturns
Context - The current context.
setSpan()
Set a span on a context, returning a new context.
function setSpan(ctx: Context, span: Span): ContextParameters
ctx
required:Context
span
required:Span
Returns
Context
wrapSpanContext()
Wrap a SpanContext into a non-recording Span.
function wrapSpanContext(spanContext: SpanContext): SpanParameters
spanContext
required:SpanContext
Returns
Span
getCurrentSpan()
Get the span from the current context.
function getCurrentSpan(): Span | undefinedReturns
Span | undefined - The current span, or undefined if none.
hasActiveRootSpan()
Check whether there is an active root span.
function hasActiveRootSpan(): booleanReturns
boolean - true if a root span is currently recording.
addInstrumentation()
Register an OpenTelemetry instrumentation.
function addInstrumentation(instrumentor: Instrumentation<InstrumentationConfig>): voidParameters
instrumentor
required:Instrumentation<InstrumentationConfig>
The instrumentation to add.
Returns
void
withContext()
Run fn with ctx installed as the active context for the
duration of the callback. Sync or async.
function withContext(ctx: Context, fn: () => T): TParameters
ctx
required:Context
fn
required:() => T
Returns
T
forceFlush()
Flush all registered tracers.
async function forceFlush(): Promise<void>Returns
Promise<void>
shutdown()
Shut down all registered tracers and clear state.
async function shutdown(): Promise<void>Returns
Promise<void>