From ab834b641a129e03b3533307b3834b2144596cbe Mon Sep 17 00:00:00 2001 From: Erich Blume Date: Mon, 13 Apr 2026 08:11:15 -0700 Subject: [PATCH] Fix OTEL metrics exporter warnings in Dagger builds The Dagger engine shim sets OTEL_METRICS_EXPORTER before our module loads, so os.environ.setdefault was a no-op. Switch to a hard override. Remove the redundant workflow-level env var since the fix belongs in the module. Co-Authored-By: Claude Opus 4.6 (1M context) --- .forgejo/workflows/build-container.yaml | 4 ---- docs/changelog.d/+dagger-otel-metrics-fix.bugfix.md | 1 + src/blumeops/main.py | 9 ++++++--- 3 files changed, 7 insertions(+), 7 deletions(-) create mode 100644 docs/changelog.d/+dagger-otel-metrics-fix.bugfix.md diff --git a/.forgejo/workflows/build-container.yaml b/.forgejo/workflows/build-container.yaml index fe6b000..efa9007 100644 --- a/.forgejo/workflows/build-container.yaml +++ b/.forgejo/workflows/build-container.yaml @@ -73,10 +73,6 @@ jobs: needs: detect if: needs.detect.outputs.dagger != '[]' runs-on: k8s - env: - # Disable Python SDK OTLP metrics exporter — the Dagger engine's local - # OTLP endpoint returns 500s, causing ~9s retry cycles per minute. - OTEL_METRICS_EXPORTER: none strategy: matrix: container: ${{ fromJson(needs.detect.outputs.dagger) }} diff --git a/docs/changelog.d/+dagger-otel-metrics-fix.bugfix.md b/docs/changelog.d/+dagger-otel-metrics-fix.bugfix.md new file mode 100644 index 0000000..6c02765 --- /dev/null +++ b/docs/changelog.d/+dagger-otel-metrics-fix.bugfix.md @@ -0,0 +1 @@ +Fix OTEL metrics exporter warnings in Dagger builds by hard-overriding the env var before SDK init. diff --git a/src/blumeops/main.py b/src/blumeops/main.py index 56595e2..9f60fd4 100644 --- a/src/blumeops/main.py +++ b/src/blumeops/main.py @@ -1,9 +1,12 @@ import os from pathlib import Path -# Disable OTLP metrics exporter before the Dagger SDK initializes OpenTelemetry. -# The Dagger engine's local OTLP endpoint returns 500s, causing ~11s retry delays. -os.environ.setdefault("OTEL_METRICS_EXPORTER", "none") +# Force-disable OTLP metrics exporter before the Dagger SDK initializes +# OpenTelemetry. The engine shim may set OTEL_METRICS_EXPORTER=otlp before +# our module loads, so setdefault won't work — we need a hard override. +# Without this, the engine's local OTLP endpoint returns 500s on metrics, +# causing ~9s retry cycles per pipeline step. +os.environ["OTEL_METRICS_EXPORTER"] = "none" import dagger from dagger import dag, function, object_type