Skip to content

feat(telemetry): honour OTEL_METRICS_EXPORTER=none #2120

Backlog

Description

@Moep90

Problem Statement

With telemetry on and an OTLP endpoint set, ocr always starts a metric exporter next to the trace exporter. A backend that only accepts traces answers /v1/metrics with 404, so every run ends with:

[ocr] WARNING: telemetry shutdown error: telemetry shutdown: [failed to upload metrics: failed to send metrics to http://collector:4318/v1/metrics: 404 Not Found (body: (empty))]

There is currently no way to export spans only.

Proposed Solution

Honour the standard OTEL_METRICS_EXPORTER variable. With none, ocr skips the metric exporter for OTLP gRPC, OTLP HTTP and the console exporter, and spans are exported as before. Any other value keeps today's behaviour.

Init would then set the global meter provider only when one was created. Passing a nil *sdkmetric.MeterProvider to otel.SetMeterProvider replaces the no-op provider and panics on the first Record* call; I checked that with a test.

Alternatives Considered

Sending metrics to another collector doesn't help when the only backend is trace-only. Ignoring the warning works, but it sits at the end of the stderr of every run, including failed ones.

Affected Area

Telemetry / Observability

Additional Context

I used Claude Code (Claude Opus 5.5) to trace the cause, draft the change and this text, and reviewed the result myself. I have a PR ready and will link it here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions