Skip to content

Commit abf9258

Browse files
google-genai-botcopybara-github
authored andcommitted
feat(telemetry): specify bucket boundaries for GenAI metrics
Specify explicit bucket boundaries for GenAI metrics histograms to align with OTel semconv updates: - open-telemetry/semantic-conventions-genai#201 - open-telemetry/semantic-conventions-genai#202 - open-telemetry/semantic-conventions-genai#203 PiperOrigin-RevId: 938553240
1 parent b2dda6e commit abf9258

1 file changed

Lines changed: 76 additions & 0 deletions

File tree

‎src/google/adk/telemetry/_metrics.py‎

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,26 +45,102 @@
4545
"gen_ai.agent.invocation.duration",
4646
unit="s",
4747
description="Duration of agent invocations.",
48+
explicit_bucket_boundaries_advisory=[
49+
0.1,
50+
0.2,
51+
0.4,
52+
0.8,
53+
1.6,
54+
3.2,
55+
6.4,
56+
12.8,
57+
25.6,
58+
51.2,
59+
102.4,
60+
204.8,
61+
409.6,
62+
],
4863
)
4964
_tool_execution_duration = meter.create_histogram(
5065
"gen_ai.tool.execution.duration",
5166
unit="s",
5267
description="Duration of tool executions.",
68+
explicit_bucket_boundaries_advisory=[
69+
0.01,
70+
0.02,
71+
0.04,
72+
0.08,
73+
0.16,
74+
0.32,
75+
0.64,
76+
1.28,
77+
2.56,
78+
5.12,
79+
10.24,
80+
20.48,
81+
40.96,
82+
81.92,
83+
],
5384
)
5485
_agent_request_size = meter.create_histogram(
5586
"gen_ai.agent.request.size",
5687
unit="By",
5788
description="Size of agent requests.",
89+
explicit_bucket_boundaries_advisory=[
90+
1,
91+
4,
92+
16,
93+
64,
94+
256,
95+
1024,
96+
4096,
97+
16384,
98+
65536,
99+
262144,
100+
1048576,
101+
4194304,
102+
16777216,
103+
67108864,
104+
],
58105
)
59106
_agent_response_size = meter.create_histogram(
60107
"gen_ai.agent.response.size",
61108
unit="By",
62109
description="Size of agent responses.",
110+
explicit_bucket_boundaries_advisory=[
111+
1,
112+
4,
113+
16,
114+
64,
115+
256,
116+
1024,
117+
4096,
118+
16384,
119+
65536,
120+
262144,
121+
1048576,
122+
4194304,
123+
16777216,
124+
67108864,
125+
],
63126
)
64127
_agent_workflow_steps = meter.create_histogram(
65128
"gen_ai.agent.workflow.steps",
66129
unit="1",
67130
description="Length of agentic workflow (# of events).",
131+
explicit_bucket_boundaries_advisory=[
132+
1,
133+
2,
134+
4,
135+
8,
136+
16,
137+
32,
138+
64,
139+
128,
140+
256,
141+
512,
142+
1024,
143+
],
68144
)
69145
_client_operation_duration = (
70146
gen_ai_metrics.create_gen_ai_client_operation_duration(meter)

0 commit comments

Comments
 (0)