Skip to main content
Primary entry point for Fiddler AI observability in JavaScript/TypeScript. Creates an isolated OpenTelemetry BasicTracerProvider that exports traces to the Fiddler backend via OTLP HTTP. The provider is not registered globally, so it will not interfere with other OTel instrumentation in the same process. Node.js only — registers a process.beforeExit handler for automatic shutdown. The process guard is safe in non-Node environments but OTel SDK dependencies require Node.js >= 20.

Methods

constructor(config: FiddlerClientConfig)

Create a new Fiddler client and initialize the OTel provider.
config
FiddlerClientConfig
required
Client configuration including Fiddler URL, API key, and application ID.

async flush(): Promise<void>

Force-flush all buffered spans to the Fiddler backend. Call this before process exit in short-lived scripts to ensure all spans are exported.

async shutdown(): Promise<void>

Flush remaining spans and shut down the underlying OTel provider. After shutdown the client cannot create new spans. This method is idempotent — calling it multiple times is safe.

startAgent(name: string, options?: Omit<StartSpanOptions, "type">): FiddlerAgentSpan

Start a new agent/chain span (sets fiddler.span.type to "chain").
name
string
required
Human-readable name for the agent span.
options
Omit<StartSpanOptions, "type">
Optional parent span for nesting.
return
A new FiddlerAgentSpan with agent-specific helpers.

startGeneration(name: string, options?: Omit<StartSpanOptions, "type">): FiddlerGenerationSpan

Start a new LLM generation span (sets fiddler.span.type to "llm").
name
string
required
Human-readable name for the generation span.
options
Omit<StartSpanOptions, "type">
Optional parent span for nesting.
return
A new FiddlerGenerationSpan with LLM-specific helpers.

startSpan(name: string, options?: StartSpanOptions): FiddlerSpan

Start a new span with an optional explicit type.
name
string
required
Human-readable name for the span.
options
StartSpanOptions
Optional span type and parent span.
return
A new FiddlerSpan instance.

startTool(name: string, options?: Omit<StartSpanOptions, "type">): FiddlerToolSpan

Start a new tool span (sets fiddler.span.type to "tool").
name
string
required
Human-readable name for the tool span.
options
Omit<StartSpanOptions, "type">
Optional parent span for nesting.
return
A new FiddlerToolSpan with tool-specific helpers.