Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

built-in-metrics

БесплатноБез исполняемых скриптовНе проверен

Instrument an existing codebase so LaunchDarkly records config metrics (duration, tokens, success/error, tool calls). Walks the ladder (convenience function →…

launchdarklyот launchdarkly★ 32 звезды на GitHub

Об этом скилле

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.

The four-tier ladder

Walk from the top and stop at the first tier that fits:

Tier Pattern Use when
1 — Convenience function openai_messages(key, input, context) / openaiMessages(key, input, context), one per handler package One provider in one mode, no tools, no streaming. The shortest path.
2 — config() + handler package config(key=..., handler=[...]).invoke(input, context) / .stream(...) A handler package covers your provider, and you need more than one provider or mode, tools, template variables, streaming, or background judges.
3 — Custom handler create_handler((provider, mode), fn) / createHandler([provider, mode], fn), passed to config() No handler package fits (Gemini SDK, Bedrock via boto3, Strands, custom HTTP), or you want to keep an existing provider call as is.
4 — Manual track() get_client().track(event_key, context, result.track_data, value) Events the SDK doesn't record: user feedback and business outcomes. Never for duration, tokens, or success, which the SDK already records.

Workflow

1. Explore the existing call site

Before picking a tier, find the provider call and answer these questions:

  • Provider? OpenAI, Anthropic, Bedrock, Gemini, custom HTTP? → cross-reference with the handler matrix below.
  • Framework? Raw provider SDK, LangChain / LangGraph, OpenAI Agents SDK, Claude Agent SDK, Strands?
  • Mode? A completion (messages) or an agent (agent)? The served variation's mode selects the handler.
  • Streaming? Use stream() instead of invoke(). Metrics are recorded the same way, but time to first token isn't.
  • Language? Python or Node.js? Handler coverage is the same in both.
  • Already using a config? If not, route to configs-create first.
  • On a legacy SDK? If the code imports ldai / @launchdarkly/server-sdk-ai, or calls create_tracker(), track_metrics_of(), trackMetricsOf(), completion_config(), or create_model(), it's on the legacy surface. Replace it as part of this work (see Replacing legacy tracker code), or use legacy-sdk-migrate for a full codebase upgrade. For call sites with hardcoded models or prompts, hand off to migrate instead.

2. Look up your handler

Install the core package ("launchdarkly-ai-server[ld]" or @launchdarkly/ai-node) plus one handler package per provider and mode you serve:

Provider / framework Python handler package Node.js handler package Reference
OpenAI launchdarkly-ai-openai-messages, -openai-agents @launchdarkly/ai-openai-messages, -openai-agents openai-tracking.md
Anthropic launchdarkly-ai-claude-messages, -claude-agents @launchdarkly/ai-claude-messages, -claude-agents anthropic-tracking.md
LangChain / LangGraph (any provider) launchdarkly-ai-langchain-messages, -langchain-agents @launchdarkly/ai-langchain-messages, -langchain-agents langchain-tracking.md
AWS Bedrock LangChain handler + langchain-aws, or a custom handler LangChain handler, or a custom handler bedrock-tracking.md
Gemini / Google GenAI LangChain handler with a model factory, or a custom handler Same gemini-tracking.md
Strands Agents Custom handler Custom handler strands-tracking.md
Cohere, Mistral, custom HTTP Custom handler Custom handler anthropic-tracking.md shows t
Полный SKILL.md на GitHub

Установить built-in-metrics в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

references/anthropic-tracking.mdreferences/bedrock-tracking.mdreferences/gemini-tracking.mdreferences/langchain-tracking.mdreferences/metrics-api.mdreferences/openai-tracking.mdreferences/strands-tracking.mdreferences/streaming-tracking.md

FAQ

Что делает скилл built-in-metrics?

Instrument an existing codebase so LaunchDarkly records config metrics (duration, tokens, success/error, tool calls). Walks the ladder (convenience function → config() with a handler package → custom handler → manual track()) and picks the lowest-ceremony option that still captures what the Monitoring tab needs.

Как установить скилл built-in-metrics?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл built-in-metrics запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить built-in-metrics с