Summary
Follow-up to inference-gateway/inference-gateway#404 (client side), required by its acceptance criteria. The gateway now exposes an opt-in OTLP/HTTP metrics push endpoint (POST /v1/metrics, gateway PR inference-gateway/inference-gateway#409).
When infer runs with a Claude Code Max subscription, traffic goes infer CLI -> Claude Code -> Anthropic API and bypasses the gateway entirely, so no metrics are recorded. The CLI should parse Claude Code headless-mode logs and push usage/tool-call metrics to the gateway:
- Push OTLP JSON (or protobuf) to
POST {gateway}/v1/metrics with Content-Type: application/json, delta temporality.
- Supported metrics:
gen_ai.client.token.usage (delta sum per operation, with gen_ai.token.type = input|output), gen_ai.client.operation.duration, gen_ai.client.operation.time_to_first_chunk, gen_ai.execute_tool.duration (histograms, seconds; carry error.type on failures so tool success/failure is derivable), inference_gateway.tool_calls (delta monotonic sum).
- Attributes:
gen_ai.provider.name, gen_ai.request.model, gen_ai.tool.name, gen_ai.tool.type, error.type, and set source to claude-code-subscription so subscription clients are labeled distinctly (anything else is dropped by the gateway's allowlist; source="gateway" is rewritten server-side).
- Forward the user's bearer token when the gateway runs with auth enabled; handle 403 (push disabled) gracefully.
Example payload: see "Pushing metrics (OTLP)" in the gateway's examples/docker-compose/monitoring/README.md.
Acceptance Criteria
Summary
Follow-up to inference-gateway/inference-gateway#404 (client side), required by its acceptance criteria. The gateway now exposes an opt-in OTLP/HTTP metrics push endpoint (POST /v1/metrics, gateway PR inference-gateway/inference-gateway#409).
When infer runs with a Claude Code Max subscription, traffic goes
infer CLI -> Claude Code -> Anthropic APIand bypasses the gateway entirely, so no metrics are recorded. The CLI should parse Claude Code headless-mode logs and push usage/tool-call metrics to the gateway:POST {gateway}/v1/metricswithContent-Type: application/json, delta temporality.gen_ai.client.token.usage(delta sum per operation, withgen_ai.token.type= input|output),gen_ai.client.operation.duration,gen_ai.client.operation.time_to_first_chunk,gen_ai.execute_tool.duration(histograms, seconds; carryerror.typeon failures so tool success/failure is derivable),inference_gateway.tool_calls(delta monotonic sum).gen_ai.provider.name,gen_ai.request.model,gen_ai.tool.name,gen_ai.tool.type,error.type, and setsourcetoclaude-code-subscriptionso subscription clients are labeled distinctly (anything else is dropped by the gateway's allowlist;source="gateway"is rewritten server-side).Example payload: see "Pushing metrics (OTLP)" in the gateway's examples/docker-compose/monitoring/README.md.
Acceptance Criteria