clade-observability

Featured

Monitor Claude API calls — log tokens, latency, costs, errors, and Use when working with observability patterns. set up alerts for production Claude integrations. Trigger with "anthropic monitoring", "claude observability", "track claude usage", "anthropic logging".

AI & Automation 2,944 stars 440 forks Updated today MIT

Install

View on GitHub

Quality Score: 99/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Anthropic Observability ## Overview Every `messages.create` call should be instrumented. Track tokens, latency, cost, model, and errors. ## Logging Wrapper ```typescript import Anthropic from '@claude-ai/sdk'; const client = new Anthropic(); async function trackedCreate(params: Anthropic.MessageCreateParams) { const start = performance.now(); try { const message = await client.messages.create(params); const durationMs = Math.round(performance.now() - start); const log = { timestamp: new Date().toISOString(), model: message.model, input_tokens: message.usage.input_tokens, output_tokens: message.usage.output_tokens, cache_read_tokens: message.usage.cache_read_input_tokens || 0, duration_ms: durationMs, stop_reason: message.stop_reason, estimated_cost: estimateCost(message.model, message.usage), }; console.log('anthropic_request', JSON.stringify(log)); return message; } catch (err) { const durationMs = Math.round(performance.now() - start); console.error('anthropic_error', JSON.stringify({ timestamp: new Date().toISOString(), model: params.model, error_type: err instanceof Anthropic.APIError ? err.error?.type : 'unknown', status: err instanceof Anthropic.APIError ? err.status : null, request_id: err instanceof Anthropic.APIError ? err.headers?.['request-id'] : null, duration_ms: durationMs, })); throw err; } } function estimateCost(model: s...

Details

Author
jeremylongshore
Repository
jeremylongshore/claude-code-plugins-plus-skills
Created
1 years ago
Last Updated
today
Language
Python
License
MIT

Integrates with

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category