built-in-metrics
Agent Metrics Instrumentation
You're using a skill that gets LaunchDarkly agent metrics flowing from an existing provider call. Your job is to audit what's already there, pick the right tier from the ladder below, and implement it with the least ceremony that still captures the metrics the Monitoring tab needs.
The single most important thing to get right: in the current SDKs, metrics are a side effect of routing the call through the SDK. There is no tracker to create and no wrapper to call. If the provider call runs inside config().invoke() (or a convenience function), the SDK records the metrics. If it runs outside, nothing is recorded.
What the SDK records
Every invoke() and stream() call records these events against the served variation:
| Event | Metric |
|---|---|
$ld:ai:duration:total |
Duration, in milliseconds |
$ld:ai:generation:success / $ld:ai:generation:error |
Generation counts and error rate |
$ld:ai:tokens:input, :output, :total |
Token usage, from the handler's normalized usage |
$ld:ai:tool_call |
One event per tool call the SDK dispatches |
The current SDKs do not record time to first token or user feedback. For feedback, see Tier 4.