@@ -13,20 +13,22 @@ A Prometheus histogram, served at **`/metrics`** on the agent's HTTP port:
1313| --- | --- | --- |
1414| ` gen_ai_client_token_usage ` | ` gen_ai.client.token.usage ` | histogram, semconv-recommended buckets |
1515
16- Labels (semconv attributes, dots → underscores), aligned with what the upstream Google ADK Python
17- runtime emits for the same instrument so a single dashboard works across both runtimes:
16+ Labels use semconv attribute names with dots mapped to underscores:
1817
1918| Label | Values |
2019| --- | --- |
2120| ` gen_ai_token_type ` | ` input ` , ` output ` (output = candidate + reasoning tokens) |
22- | ` gen_ai_operation_name ` | ` chat ` |
21+ | ` gen_ai_operation_name ` | ` generate_content ` for Gemini; ` chat ` for chat-completion providers |
2322| ` gen_ai_provider_name ` | well-known value, e.g. ` openai ` , ` anthropic ` , ` gcp.vertex_ai ` , ` aws.bedrock ` , ` azure.ai.openai ` |
2423| ` gen_ai_request_model ` | configured model, e.g. ` gpt-4o ` |
2524| ` gen_ai_response_model ` | model the provider served (falls back to request model) |
26- | ` gen_ai_agent_name ` | agent that produced the tokens ( the kagent app name) |
25+ | ` gen_ai_agent_name ` | ADK agent that made the model call (not the application name) |
2726| ` error_type ` | set on failed requests; empty otherwise |
2827
29- One observation is recorded per LLM call (streaming partial chunks are not double-counted).
28+ For each positive input/output count, one observation is recorded per LLM call.
29+ Streaming partial chunks are not double-counted. Recording runs in the model callback,
30+ so usage-only responses are counted even when they do not produce an A2A artifact.
31+ Missing optional labels are exported as empty strings.
3032
3133## Configuration
3234
@@ -89,14 +91,14 @@ chunks, and the semconv labels including `gen_ai.agent.name`, response model, an
8991` ` ` text
9092# HELP gen_ai_client_token_usage Measures the number of input and output tokens used by GenAI requests.
9193# TYPE gen_ai_client_token_usage histogram
92- gen_ai_client_token_usage_sum{error_type="",gen_ai_agent_name="my_agent",gen_ai_operation_name="chat ",gen_ai_provider_name="gcp.vertex_ai",gen_ai_request_model="gemini-2.5-flash",gen_ai_response_model="gemini-2.5-flash",gen_ai_token_type="input"} 137
93- gen_ai_client_token_usage_count{error_type="",gen_ai_agent_name="my_agent",gen_ai_operation_name="chat ",gen_ai_provider_name="gcp.vertex_ai",gen_ai_request_model="gemini-2.5-flash",gen_ai_response_model="gemini-2.5-flash",gen_ai_token_type="input"} 2
94- gen_ai_client_token_usage_sum{error_type="",gen_ai_agent_name="my_agent",gen_ai_operation_name="chat ",gen_ai_provider_name="gcp.vertex_ai",gen_ai_request_model="gemini-2.5-flash",gen_ai_response_model="gemini-2.5-flash",gen_ai_token_type="output"} 91
95- gen_ai_client_token_usage_count{error_type="",gen_ai_agent_name="my_agent",gen_ai_operation_name="chat ",gen_ai_provider_name="gcp.vertex_ai",gen_ai_request_model="gemini-2.5-flash",gen_ai_response_model="gemini-2.5-flash",gen_ai_token_type="output"} 2
94+ gen_ai_client_token_usage_sum{error_type="",gen_ai_agent_name="my_agent",gen_ai_operation_name="generate_content ",gen_ai_provider_name="gcp.vertex_ai",gen_ai_request_model="gemini-2.5-flash",gen_ai_response_model="gemini-2.5-flash",gen_ai_token_type="input"} 137
95+ gen_ai_client_token_usage_count{error_type="",gen_ai_agent_name="my_agent",gen_ai_operation_name="generate_content ",gen_ai_provider_name="gcp.vertex_ai",gen_ai_request_model="gemini-2.5-flash",gen_ai_response_model="gemini-2.5-flash",gen_ai_token_type="input"} 2
96+ gen_ai_client_token_usage_sum{error_type="",gen_ai_agent_name="my_agent",gen_ai_operation_name="generate_content ",gen_ai_provider_name="gcp.vertex_ai",gen_ai_request_model="gemini-2.5-flash",gen_ai_response_model="gemini-2.5-flash",gen_ai_token_type="output"} 91
97+ gen_ai_client_token_usage_count{error_type="",gen_ai_agent_name="my_agent",gen_ai_operation_name="generate_content ",gen_ai_provider_name="gcp.vertex_ai",gen_ai_request_model="gemini-2.5-flash",gen_ai_response_model="gemini-2.5-flash",gen_ai_token_type="output"} 2
9698` ` `
9799
98100# # Follow-ups
99101
100102- Optional OTLP **push** (in addition to the scrape endpoint) via the OpenTelemetry
101103 [Prometheus→OTLP bridge](https://pkg.go.dev/go.opentelemetry.io/contrib/bridges/prometheus), for
102- environments that push to an OTLP collector rather than scrape.
104+ environments that push to an OTLP collector rather than scrape.
0 commit comments