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)
| 129 | |
| 130 | |
| 131 | def 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 | |
| 157 | def check_llm_spans(spans: List[Dict[str, Any]]) -> Tuple[bool, List[str]]: |
no test coverage detected
searching dependent graphs…