built-in-metrics
Instrument an existing codebase with LaunchDarkly config tracking. Walks the four-tier ladder (managed runner → provider package → custom extractor + trackMetricsOf → raw manual) and picks the lowest-ceremony option that still captures duration, tokens, and success/error.
Security Assessment
About built-in-metrics
built-in-metrics is a LaunchDarkly skill for instrumenting an existing codebase with AI config metric tracking, so an application's provider calls report duration, input/output tokens, success/error, and time-to-first-token to LaunchDarkly's Monitoring tab. Its guiding principle is to add the least ceremony that still captures the needed metrics by choosing the highest applicable tier of a four-tier ladder rather than dropping straight to manual tracker calls.
The four tiers are: a managed runner (create_model/createModel returning a ManagedModel whose run() captures everything automatically) for chat-style calls; a provider package plus trackMetricsOf using the package's getAIMetricsFromResponse extractor for non-chat shapes; a custom extractor with trackMetricsOf when no provider package exists (Anthropic direct, Gemini, Cohere, custom HTTP); and raw manual tracking (trackDuration, trackTokens, trackSuccess/trackError, trackTimeToFirstToken) for streaming and unusual shapes. The skill emphasizes that every provider uses the same generic wrapper shape and that only the extractor changes per provider. It ships extensive reference files with concrete Python and Node patterns for OpenAI, Bedrock, Gemini, Anthropic, LangChain, Strands, streaming, and the metrics API, including guidance on error handling (trackMetricsOf records and re-throws) and TTFT tracking for streams.
It targets backend engineers using the LaunchDarkly server-side AI SDKs (Python launchdarkly-server-sdk-ai or Node @launchdarkly/server-sdk-ai, version 0.20.0+) who already have a config and want observability over their LLM calls. It is a defensive/observability skill that instruments existing code with official SDK APIs.
FAQ
What are the prerequisites?
The LaunchDarkly server-side AI SDK — launchdarkly-server-sdk-ai>=0.20.0 for Python or @launchdarkly/server-sdk-ai>=0.20.0 for Node — plus an existing AI config to attach tracking to.
How does the four-tier ladder work?
Walk from the top and stop at the first tier that fits: managed runner for chat loops, provider package plus trackMetricsOf for other shapes, custom extractor when no package exists, and raw manual tracking for streaming/TTFT or unusual response shapes.
Which providers are covered?
Reference files cover OpenAI, AWS Bedrock, Gemini, Anthropic, LangChain, and Strands, plus streaming tracking and the metrics API. OpenAI and LangChain have first-class provider packages; Bedrock and Anthropic direct use custom extractors.
Do I need manual error handling?
No. trackMetricsOf (and track_metrics_of in Python) catches exceptions, records trackError on the tracker, and re-throws, so you should not add your own except-and-trackError block, which would be a no-op guarded against double counting.
How is streaming handled?
Streaming needs manual time-to-first-token tracking because current provider packages don't capture TTFT — you call trackTimeToFirstToken on the first content chunk even if the rest uses a higher tier.
All Files
9 filesInstall built-in-metrics
Quick Setup:
- Copy the skill folder to
.claude/skills/ - Claude will automatically detect and use the skill
Repository
launchdarkly/agent-skills