(generation_type: str, result: str, duration_seconds: Optional[float])
| 358 | |
| 359 | |
| 360 | def record_generation_result(generation_type: str, result: str, duration_seconds: Optional[float]) -> None: |
| 361 | normalized_type = generation_type if generation_type in {"image", "video"} else "unknown" |
| 362 | normalized_result = result if result in {"success", "failed", "cancelled", "no_token", "invalid"} else "unknown" |
| 363 | GENERATION_REQUESTS_TOTAL.labels( |
| 364 | generation_type=normalized_type, |
| 365 | result=normalized_result, |
| 366 | ).inc() |
| 367 | if duration_seconds is not None and duration_seconds >= 0: |
| 368 | GENERATION_DURATION_SECONDS.labels( |
| 369 | generation_type=normalized_type, |
| 370 | result=normalized_result, |
| 371 | ).observe(float(duration_seconds)) |
| 372 | |
| 373 | |
| 374 | def record_token_refresh(kind: str, result: str) -> None: |
no test coverage detected