ReadonlyresumptionA URL-safe Base64-encoded token that encodes the tracker's runId, configKey, variationKey, and version. Pass this to AIClient.createTracker() to reconstruct the tracker across process boundaries (e.g. for associating deferred feedback with the original AI run).
Get a summary of the tracked metrics.
Get the data for tracking.
Track the duration of the provided function.
If the provided function throws, then this method will also throw. In the case the provided function throws, this function will still record the duration.
This function does not automatically record an error when the function throws.
The function to track the duration of.
The result of the function.
Track sentiment about the generation.
Feedback about the generation.
Track a judge evaluation result.
No event is emitted when the result was not sampled (result.sampled is false).
Judge result containing score, reasoning, and metadata
Track metrics for a generic AI operation.
This function will track the duration of the AI run, extract metrics using the provided metrics extractor function, and track success or error status accordingly.
If the provided function throws, then this method will also throw. In the case the provided function throws, this function will record the duration and an error. A failed AI run will not have any token usage data.
Function that extracts LDAIMetrics from the AI run result
Function which executes the AI run
The result of the AI run
Track metrics for a streaming AI operation.
This function will track the duration of the AI run, extract metrics using the provided metrics extractor function, and track success or error status accordingly.
Unlike trackMetricsOf, this method is designed for streaming AI runs where:
The stream is returned immediately so the caller can begin consuming it without waiting. Metrics extraction happens in the background and does not block stream consumption.
If the stream creator throws, then this method will also throw and record an error. If metrics extraction fails, the error is logged but does not affect stream consumption.
Function that creates and returns the stream (synchronous)
Function that asynchronously extracts metrics from the stream
The stream result (returned immediately, not a Promise)
Track information about token usage.
Token usage information.
The LDAIConfigTracker records metrics for a single AI run.
All events a tracker emits share a runId (a UUIDv4) so LaunchDarkly can correlate them in metrics views. See individual track methods for their specific semantics. Call
createTrackeron the AI Config to start a new run. A resumption token preserves the runId, so events emitted by a tracker reconstructed in another process correlate with the original run.