Skip to content

Commit a6a457a

Browse files
committed
fix: guard against zero or negative DYN_HTTP_SVC_CONFIG_METRICS_POLL_INTERVAL_SECS
- Add validation to ensure poll interval is greater than 0 - Use filter() to reject zero or negative values - Update documentation to clarify validation requirement - Prevents potential issues with zero-duration polling intervals Signed-off-by: Keiven Chang <keivenchang@users.noreply.github.com>
1 parent c923c2b commit a6a457a

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

lib/llm/src/http/service/metrics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ impl Metrics {
159159
/// ## Runtime Config Polling Configuration
160160
///
161161
/// The polling behavior can be configured via environment variables:
162-
/// - `DYN_HTTP_SVC_CONFIG_METRICS_POLL_INTERVAL_SECS`: Poll interval in seconds
162+
/// - `DYN_HTTP_SVC_CONFIG_METRICS_POLL_INTERVAL_SECS`: Poll interval in seconds (must be > 0, defaults to 8)
163163
///
164164
/// Metrics are never removed to preserve historical data. Runtime config and MDC
165165
/// metrics are updated when models are discovered and their configurations are available.

lib/llm/src/http/service/service_v2.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,12 @@ impl HttpService {
205205
tracing::info!(protocol, address, "Starting HTTP(S) service");
206206

207207
// Start background task to poll runtime config metrics with proper cancellation
208-
let poll_interval = Duration::from_secs(
209-
std::env::var("DYN_HTTP_SVC_CONFIG_METRICS_POLL_INTERVAL_SECS")
210-
.ok()
211-
.and_then(|s| s.parse().ok())
212-
.unwrap_or(8),
213-
);
208+
let poll_interval_secs = std::env::var("DYN_HTTP_SVC_CONFIG_METRICS_POLL_INTERVAL_SECS")
209+
.ok()
210+
.and_then(|s| s.parse::<u64>().ok())
211+
.filter(|&secs| secs > 0) // Guard against zero or negative values
212+
.unwrap_or(8);
213+
let poll_interval = Duration::from_secs(poll_interval_secs);
214214

215215
let _polling_task = super::metrics::Metrics::start_runtime_config_polling_task(
216216
self.state.metrics_clone(),

0 commit comments

Comments
 (0)