Skip to content

Commit 50cd86a

Browse files
committed
Validation: both values must be positive
Validation: both values must be positive
1 parent c7ed2fb commit 50cd86a

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/Agent/NewRelic/Agent/Core/Configuration/DefaultConfiguration.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2991,8 +2991,15 @@ private void EnsureOtelExportIntervalAndTimeout()
29912991
"NEW_RELIC_OPENTELEMETRY_METRICS_EXPORT_TIMEOUT"
29922992
).GetValueOrDefault(DefaultOtelExportTimeoutMs);
29932993

2994+
// Validation: both values must be positive
2995+
if (intervalMs <= 0 || timeoutMs <= 0)
2996+
{
2997+
Log.Warn($"Invalid OpenTelemetry metrics export values: interval={intervalMs} ms, timeout={timeoutMs} ms. Both values must be positive. Reverting to defaults: interval={DefaultOtelExportIntervalMs} ms, timeout={DefaultOtelExportTimeoutMs} ms.");
2998+
intervalMs = DefaultOtelExportIntervalMs;
2999+
timeoutMs = DefaultOtelExportTimeoutMs;
3000+
}
29943001
// Validation: interval must be >= timeout
2995-
if (intervalMs < timeoutMs)
3002+
else if (intervalMs < timeoutMs)
29963003
{
29973004
Log.Warn($"OpenTelemetry metrics export interval ({intervalMs} ms) is less than export timeout ({timeoutMs} ms). Reverting to defaults: interval={DefaultOtelExportIntervalMs} ms, timeout={DefaultOtelExportTimeoutMs} ms.");
29983005
intervalMs = DefaultOtelExportIntervalMs;

0 commit comments

Comments
 (0)