Readonly resumptionA 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.
Optional graphTrack 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.
Because each inner metric is at-most-once per Tracker, calling this twice on the same Tracker will run the inner function again but produce no additional metric events.
Track sentiment about the generation.
Feedback about the generation.
Records at most once per Tracker; further calls are ignored.
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
May be called multiple times per Tracker; each call records the scores from the given response.
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
Subsequent calls re-run the inner function but emit only metrics not already recorded on this Tracker. Call createTracker on the AI Config to start a new 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)
Subsequent calls re-run the inner function but emit only metrics not already recorded on this Tracker. Call createTracker on the AI Config to start a new run.
Track information about token usage.
Token usage information.
Records at most once per Tracker; further calls are ignored.
Generated using TypeDoc
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.