Skip to content

feat(telemetry): honour OTEL_METRICS_EXPORTER=none - #2121

Open
Moep90 wants to merge 1 commit into
alibaba:mainfrom
Moep90:feat/metrics-exporter-none
Open

Moep90 wants to merge 1 commit into
alibaba:mainfrom
Moep90:feat/metrics-exporter-none

Conversation

@Moep90

@Moep90 Moep90 commented Nov 27, 2026 •

Copy link
Copy Markdown

Description

With OTEL_METRICS_EXPORTER=none, ocr no longer creates a metric exporter (OTLP gRPC, OTLP HTTP, console), so spans can go to a trace-only backend without a 404 on /v1/metrics at the end of every run. Any other value keeps the current behaviour.

Init now sets the global meter provider only when one was created. Without that guard a nil *sdkmetric.MeterProvider becomes the global provider and the first Record* call panics; TestInit_MetricsExporterNoneRecordsNothing hits that panic when the guard is removed.

The new Config.NoMetrics field is a negative so that existing Config{} literals keep exporting metrics.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Refactoring (no functional changes)
  • Documentation update
  • CI / Build / Tooling

How Has This Been Tested?

make check, and go test -race ./internal/telemetry with three new tests: env resolution, the three init paths with metrics off, and Init followed by Record* calls. I did not run the full make test locally.

  • make test passes locally
  • Manual testing (describe below)

Checklist

  • My code follows the project's coding style (go fmt, go vet)
  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or my feature works
  • New and existing unit tests pass locally with my changes
  • I have updated the documentation accordingly (if applicable)
  • I have signed the CLA
  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

I used Claude Code (Claude Opus 5.5) to trace the cause and draft the change and this description.

Related Issues

Closes #2120

@CLAassistant

CLAassistant commented Nov 27, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions

Copy link
Copy Markdown
Contributor

✅ OpenCodeReview: Review complete: 0 finding(s) across 3 selected item(s).

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(telemetry): honour OTEL_METRICS_EXPORTER=none

2 participants