-
Notifications
You must be signed in to change notification settings - Fork 94
LCORE-1857: Add metrics to track degraded mode startup state #1985
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -157,3 +157,18 @@ def record_llm_inference_duration( | |||||||||
| ).observe(duration) | ||||||||||
| except (AttributeError, TypeError, ValueError): | ||||||||||
| logger.warning("Failed to update LLM inference duration metric", exc_info=True) | ||||||||||
|
|
||||||||||
|
|
||||||||||
| def set_started_in_degraded_mode(is_degraded: bool) -> None: | ||||||||||
| """Set the startup degraded mode gauge. | ||||||||||
|
|
||||||||||
| This metric tracks whether the service started in degraded mode. | ||||||||||
| It is set once at startup and does not change at runtime. | ||||||||||
|
|
||||||||||
| Args: | ||||||||||
| is_degraded: True if service started in degraded mode, False if healthy. | ||||||||||
|
Comment on lines
+168
to
+169
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Use the This repo standardizes on the 📝 Proposed fix- Args:
- is_degraded: True if service started in degraded mode, False if healthy.
+ Parameters:
+ is_degraded: True if service started in degraded mode, False if healthy.Based on learnings: docstrings must use the section header name "Parameters:" (not "Args:") for function arguments. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI AgentsSource: Learnings |
||||||||||
| """ | ||||||||||
| try: | ||||||||||
| metrics.started_in_degraded_mode.set(1 if is_degraded else 0) | ||||||||||
| except (AttributeError, TypeError, ValueError): | ||||||||||
| logger.warning("Failed to update started_in_degraded_mode gauge", exc_info=True) | ||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
|
|
||
| from typing import Optional | ||
|
|
||
| from metrics import recording | ||
| from utils.types import Singleton | ||
|
|
||
|
|
||
|
|
@@ -31,11 +32,17 @@ def set_degraded(self, reason: str) -> None: | |
| self._is_degraded = True | ||
| self._degraded_reason = reason | ||
|
|
||
| # Record startup state metric | ||
| recording.set_started_in_degraded_mode(True) | ||
|
|
||
| def set_healthy(self) -> None: | ||
| """Mark the service as running in healthy mode.""" | ||
| self._is_degraded = False | ||
| self._degraded_reason = None | ||
|
|
||
| # Record startup state metric | ||
| recording.set_started_in_degraded_mode(False) | ||
|
Comment on lines
+35
to
+44
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Preserve startup-only semantics for Line 43 resets the gauge to 💡 Suggested fix class DegradedModeTracker(metaclass=Singleton):
@@
def __init__(self) -> None:
"""Initialize the degraded mode tracker."""
self._is_degraded: bool = False
self._degraded_reason: Optional[str] = None
+ self._startup_state_recorded: bool = False
+
+ def _record_startup_state_once(self, is_degraded: bool) -> None:
+ """Record startup degraded-state metric only once per process start."""
+ if self._startup_state_recorded:
+ return
+ recording.set_started_in_degraded_mode(is_degraded)
+ self._startup_state_recorded = True
@@
- recording.set_started_in_degraded_mode(True)
+ self._record_startup_state_once(True)
@@
- recording.set_started_in_degraded_mode(False)
+ self._record_startup_state_once(False)🤖 Prompt for AI Agents |
||
|
|
||
| def is_degraded(self) -> bool: | ||
| """Check if the service is running in degraded mode. | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Regenerate and commit OpenAPI schema to fix CI drift.
The Spectral job is failing because
docs/openapi.jsonno longer matches the generated schema. Please regenerate withuv run python scripts/generate_openapi_schema.py docs/openapi.jsonand commit the updated artifact to keep docs and runtime schema in sync.🤖 Prompt for AI Agents
Source: Pipeline failures