MCPcopy Index your code
hub / github.com/google/adk-python / _extract_metrics

Function _extract_metrics

tests/unittests/telemetry/test_functional.py:183–202  ·  view source on GitHub ↗
(
    metrics_list: Sequence[Metric], name: str, agent_name: str | None = None
)

Source from the content-addressed store, hash-verified

181
182
183def _extract_metrics(
184 metrics_list: Sequence[Metric], name: str, agent_name: str | None = None
185) -> list[MetricPoint]:
186 m = next((m for m in metrics_list if m.name == name), None)
187 if not m:
188 return []
189 points = []
190 for dp in m.data.data_points:
191 if (
192 agent_name is not None
193 and dp.attributes.get("gen_ai.agent.name") != agent_name
194 ):
195 continue
196 value = None
197 if hasattr(dp, "sum"):
198 value = dp.sum
199 elif hasattr(dp, "value"):
200 value = dp.value
201 points.append(MetricPoint(attributes=dp.attributes, value=value))
202 return points
203
204
205def _setup_test_metrics(monkeypatch):

Callers 2

test_metricsFunction · 0.85
test_metrics_tool_errorFunction · 0.85

Calls 3

MetricPointClass · 0.85
getMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected