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) <noreply@anthropic.com>
This commit is contained in:
Erich Blume 2026-04-13 08:11:15 -07:00
commit ab834b641a
3 changed files with 7 additions and 7 deletions

View file

@ -73,10 +73,6 @@ jobs:
needs: detect needs: detect
if: needs.detect.outputs.dagger != '[]' if: needs.detect.outputs.dagger != '[]'
runs-on: k8s 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: strategy:
matrix: matrix:
container: ${{ fromJson(needs.detect.outputs.dagger) }} container: ${{ fromJson(needs.detect.outputs.dagger) }}

View file

@ -0,0 +1 @@
Fix OTEL metrics exporter warnings in Dagger builds by hard-overriding the env var before SDK init.

View file

@ -1,9 +1,12 @@
import os import os
from pathlib import Path from pathlib import Path
# Disable OTLP metrics exporter before the Dagger SDK initializes OpenTelemetry. # Force-disable OTLP metrics exporter before the Dagger SDK initializes
# The Dagger engine's local OTLP endpoint returns 500s, causing ~11s retry delays. # OpenTelemetry. The engine shim may set OTEL_METRICS_EXPORTER=otlp before
os.environ.setdefault("OTEL_METRICS_EXPORTER", "none") # 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 import dagger
from dagger import dag, function, object_type from dagger import dag, function, object_type