Skip to content

feat(exporter-metrics-otlp-http): respect OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION - #6874

Open
buzztaiki wants to merge 5 commits into
open-telemetry:mainfrom
buzztaiki:exponential_histogram_for_nodesdk
Open

feat(exporter-metrics-otlp-http): respect OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION#6874
buzztaiki wants to merge 5 commits into
open-telemetry:mainfrom
buzztaiki:exponential_histogram_for_nodesdk

Conversation

@buzztaiki

Copy link
Copy Markdown

Which problem is this PR solving?

OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION was not respected by the OTLP metric exporters themselves. The env var was only handled by EnvironmentConfigFactory (the declarative config path used by startNodeSDK), which reads it and passes it explicitly as aggregationPreference to the constructor. Code that constructs the exporters without going through that path, including NodeSDK (class API) used by @opentelemetry/auto-instrumentations-node, silently ignored the env var.

Fixes #3920

Short description of the changes

Added chooseAggregationSelectorFromEnvironment() to OTLPMetricExporterBase, following the same pattern as the existing chooseTemporalitySelectorFromEnvironment() for OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE.

  • When aggregationPreference is explicitly passed to the constructor, it takes priority (existing behavior unchanged).
  • Otherwise, the env var is read: base2_exponential_bucket_histogram selects exponential histogram for histogram instruments; explicit_bucket_histogram (or unset) selects explicit bucket histogram; invalid values warn and fall back to DEFAULT.

Since OTLPMetricExporter in exporter-metrics-otlp-grpc and exporter-metrics-otlp-proto both extend OTLPMetricExporterBase, the fix applies to all three exporters.

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • Unit tests added to opentelemetry-exporter-metrics-otlp-http/test/node/OTLPMetricExporter.test.ts covering: default (unset), explicit_bucket_histogram, base2_exponential_bucket_histogram, case-insensitive matching, invalid value (warn + fallback), and constructor option taking priority over env var.

Checklist:

  • Followed the style guidelines of this project
  • Unit tests have been added
  • Documentation has been updated

@buzztaiki
buzztaiki requested a review from a team as a code owner July 3, 2026 14:32
@linux-foundation-easycla

linux-foundation-easycla Bot commented Jul 3, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: buzztaiki / name: Taiki Sugawara (badc566)

@codecov

codecov Bot commented Jul 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.09%. Comparing base (27cd33a) to head (6724b1e).
⚠️ Report is 17 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6874   +/-   ##
=======================================
  Coverage   95.08%   95.09%           
=======================================
  Files         394      394           
  Lines       13997    14016   +19     
  Branches     3224     3231    +7     
=======================================
+ Hits        13309    13328   +19     
  Misses        688      688           
Files with missing lines Coverage Δ
...er-metrics-otlp-http/src/OTLPMetricExporterBase.ts 91.46% <100.00%> (+2.57%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JacksonWeber

Copy link
Copy Markdown
Contributor

Please don't forget to include a changelog.

@buzztaiki

Copy link
Copy Markdown
Author

@JacksonWeber I've added change log entry for this PR.

@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Jul 18, 2026

Copy link
Copy Markdown

Pull request dashboard status

Waiting on reviewers · refreshed 2026-07-29 01:44 UTC

Review the latest changes.

Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

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.

Implement OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION envvar

2 participants