mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-11 22:51:28 +00:00
fix(otel): honor metric export interval
This commit is contained in:
parent
f005afa146
commit
d0e802db5b
2 changed files with 10 additions and 2 deletions
|
|
@ -206,7 +206,7 @@ def build_metric_reader(config: OpenTelemetryV2Config) -> "MetricReader":
|
|||
|
||||
``console`` (and any unrecognized kind) exports to the console; ``otlp_http``
|
||||
and ``otlp_grpc`` export over OTLP with the configured endpoint/headers. The
|
||||
reader exports on a 5s period, matching v1.
|
||||
reader uses the OpenTelemetry SDK's standard ``OTEL_METRIC_EXPORT_INTERVAL`` setting.
|
||||
|
||||
Histograms keep the SDK's default cumulative temporality. Prometheus-backed
|
||||
OTLP receivers (Grafana Cloud / Mimir, and the Prometheus OTLP endpoint)
|
||||
|
|
@ -248,7 +248,7 @@ def build_metric_reader(config: OpenTelemetryV2Config) -> "MetricReader":
|
|||
else:
|
||||
exporter = ConsoleMetricExporter()
|
||||
|
||||
return PeriodicExportingMetricReader(exporter, export_interval_millis=5000)
|
||||
return PeriodicExportingMetricReader(exporter)
|
||||
|
||||
|
||||
def _otlp_logs_endpoint(endpoint: str | None) -> str | None:
|
||||
|
|
|
|||
|
|
@ -529,6 +529,14 @@ def test_otlp_metric_exporter_uses_cumulative_histogram_temporality():
|
|||
assert temporality[Histogram] is AggregationTemporality.CUMULATIVE
|
||||
|
||||
|
||||
def test_metric_reader_honors_standard_export_interval(monkeypatch):
|
||||
monkeypatch.setenv("OTEL_METRIC_EXPORT_INTERVAL", "12345")
|
||||
|
||||
reader = providers.build_metric_reader(OpenTelemetryV2Config(exporter="console"))
|
||||
|
||||
assert reader._export_interval_millis == 12345
|
||||
|
||||
|
||||
def test_otlp_logs_endpoint_normalization():
|
||||
norm = providers._otlp_logs_endpoint
|
||||
# A base endpoint gets the signal path appended (the common OTLP env shape).
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue