feat: add cost instrumentation to direct LLM call paths
loading diff…
~60% of actual Bedrock spend is invisible to Datadog because two code paths make direct AnthropicBedrock calls without emitting cost metrics. The agent SDK path (cortex.agents.run.cost_usd) only covers agent-based calls, missing:
call_generic_llm() — used by curl_tester summarization, repro classification, failure categorizer (~$4,000-4,500/day)ClaudeLLMProvider — runs every 30min with Opus (~$135-234/day)ClaudeLLMProvider.call() in cortex/generic/llm.py — emits cost after both structured output and standard text response pathsClaudeLLMProvider.call() in watchdog/clients/llm/client.py — emits cost after .parse() callcortex.llm.direct_call.{cost_usd, input_tokens, output_tokens} with model and caller tagscortex.llm.direct_call.cost_usdmodel:claude-sonnet-4-5, caller:generic_llm for cortex; model:claude-opus-4-6, caller:watchdog for watchdogdistribution metric type (same as cortex.agents.run.cost_usd) for proper percentile aggregationcaller tag allows filtering dashboard by source (generic_llm vs watchdog)🤖 Generated with Claude Code