Skip to content

Support temporality selectors in InMemoryMetricExporter - #8993

Open
trask wants to merge 1 commit into
open-telemetry:mainfrom
trask:trask-in-memory-temporality-selector
Open

trask wants to merge 1 commit into
open-telemetry:mainfrom
trask:trask-in-memory-temporality-selector

Conversation

@trask

@trask trask commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

Related to open-telemetry/opentelemetry-java-instrumentation#21111

Allow InMemoryMetricExporter to accept an AggregationTemporalitySelector, so tests can select temporality by instrument type without a custom exporter wrapper.

InMemoryMetricExporter exporter =
    InMemoryMetricExporter.create(AggregationTemporalitySelector.deltaPreferred());

This uses delta temporality for counters and histograms while keeping up-down counters cumulative.

Existing factories retain their behavior: create() uses cumulative temporality for all instruments, and create(AggregationTemporality) applies the given temporality to every instrument type.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@otelbot otelbot Bot added the api-change Changes to public API surface area label Oct 31, 2026
@otelbot

otelbot Bot commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

⚠️ API changes detected — additional maintainer review required

@jack-berg @jkwatson

This PR modifies the public API surface area of the following module(s):

  • opentelemetry-sdk-testing

Please review the changes in docs/apidiffs/current_vs_latest/ carefully before approving.

@trask
trask requested a balanced review from Copilot October 31, 2026 20:25
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Waiting on reviewers · refreshed 2026-11-02 21:10 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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block the temporality-selector factory change.

No open issues 🎉

What changed in this PR

Adds instrument-specific temporality selection to InMemoryMetricExporter, allowing tests to use selectors such as deltaPreferred() without a custom exporter wrapper.

Changes:

  • Adds a selector-based factory while preserving the behavior of existing factories.
  • Expands tests for temporality selection, null-selector rejection, metric collection, and exported-data preservation.
  • Updates the API compatibility report to record the new overload.
File Description
sdk/​testing/​src/​test/​java/​io/​opentelemetry/​sdk/​testing/​exporter/​InMemoryMetricExporterTest.java Tests selector behavior and preserves coverage of existing factories.
sdk/​testing/​src/​main/​java/​io/​opentelemetry/​sdk/​testing/​exporter/​InMemoryMetricExporter.java Adds the selector factory and delegates temporality selection to it.
docs/​apidiffs/​current_vs_latest/​opentelemetry-sdk-testing.txt Records the new public factory overload.

Review effort: Balanced

@codecov

codecov Bot commented Oct 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.38%. Comparing base (dc3019e) to head (4884813).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8993      +/-   ##
============================================
+ Coverage     90.36%   90.38%   +0.01%     
- Complexity    10995    10996       +1     
============================================
  Files          1020     1020              
  Lines         30096    30098       +2     
  Branches       3929     3929              
============================================
+ Hits          27197    27203       +6     
+ Misses         1942     1937       -5     
- Partials        957      958       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

api-change Changes to public API surface area

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants