MCPcopy Create free account
hub / github.com/AgentOps-AI/agentops / get_trace_metrics

Function get_trace_metrics

agentops/validation.py:131–154  ·  view source on GitHub ↗

Get trace metrics from AgentOps API. Args: trace_id: The trace ID to query jwt_token: JWT authentication token Returns: Trace metrics including token counts and costs Raises: ApiServerException: If API request fails

(trace_id: str, jwt_token: str)

Source from the content-addressed store, hash-verified

129
130
131def get_trace_metrics(trace_id: str, jwt_token: str) -> Dict[str, Any]:
132 """
133 Get trace metrics from AgentOps API.
134
135 Args:
136 trace_id: The trace ID to query
137 jwt_token: JWT authentication token
138
139 Returns:
140 Trace metrics including token counts and costs
141
142 Raises:
143 ApiServerException: If API request fails
144 """
145 try:
146 response = requests.get(
147 f"https://api.agentops.ai/public/v1/traces/{trace_id}/metrics",
148 headers={"Authorization": f"Bearer {jwt_token}"},
149 timeout=10,
150 )
151 response.raise_for_status()
152 return response.json()
153 except requests.exceptions.RequestException as e:
154 raise ApiServerException(f"Failed to get trace metrics: {e}")
155
156
157def check_llm_spans(spans: List[Dict[str, Any]]) -> Tuple[bool, List[str]]:

Callers 1

validate_trace_spansFunction · 0.85

Calls 3

ApiServerExceptionClass · 0.90
jsonMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…