Visitar URL original
feat(metrics): add composable metric views support by rooks-ns · Pull Request #9020 · open-telemetry/opentelemetry-java · GitHub
Skip to content

feat(metrics): add composable metric views support - #9020

Open
rooks-ns wants to merge 2 commits into
open-telemetry:mainfrom
rooks-ns:feat/composable-metric-views
Open

rooks-ns wants to merge 2 commits into
open-telemetry:mainfrom
rooks-ns:feat/composable-metric-views

Conversation

@rooks-ns

@rooks-ns rooks-ns commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Implement experimental composable view matching mode according to the OpenTelemetry Metrics SDK specification and declarative config schema.

  • Introduce ViewMatchingMode (INDEPENDENT, COMPOSABLE).
  • Track explicit View properties in ViewBuilder, View, and RegisteredView to distinguish configured fields from defaults.
  • Implement composable view resolution in ViewRegistry: stream grouping by configured name, last-wins attribute/cardinality merging, backward-scanning aggregation compatibility fallback, and attribute filter conjunction.
  • Add reflection bridge in SdkMeterProviderUtil to safely configure ViewMatchingMode on SdkMeterProviderBuilder without modifying public 1.x APIs.
  • Wire view_matching_mode/development in MeterProviderFactory for declarative configuration.
  • Add comprehensive unit and integration tests.

Fixes #9013

@otelbot otelbot Bot added the api-change Changes to public API surface area label Nov 8, 2026
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Waiting on the author · refreshed 2026-11-13 05:43 UTC

Respond to 1 review item (e.g. link a commit, explain why not, ask a follow-up):

  • Inline threads: 1
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.
  • Should this be with reviewers? Comment /dashboard route:reviewers to route it to them.
  • Anything wrong — including the routing? Report it with what you expected; it helps us improve the dashboard.

@codecov

codecov Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.29536% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.45%. Comparing base (b11bb9c) to head (ad6265a).

Files with missing lines Patch % Lines
...emetry/sdk/metrics/internal/view/ViewRegistry.java 93.57% 7 Missing and 2 partials ⚠️
...c/main/java/io/opentelemetry/sdk/metrics/View.java 73.91% 1 Missing and 5 partials ⚠️
...k/metrics/internal/view/CompositeAndPredicate.java 81.48% 3 Missing and 2 partials ⚠️
...try/sdk/metrics/internal/SdkMeterProviderUtil.java 75.00% 2 Missing ⚠️
...figure/declarativeconfig/MeterProviderFactory.java 85.71% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #9020      +/-   ##
============================================
+ Coverage     90.44%   90.45%   +0.01%     
- Complexity    11171    11237      +66     
============================================
  Files          1032     1034       +2     
  Lines         30451    30664     +213     
  Branches       3974     4021      +47     
============================================
+ Hits          27540    27736     +196     
- Misses         1935     1942       +7     
- Partials        976      986      +10     

☔ 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.

@rooks-ns
rooks-ns force-pushed the feat/composable-metric-views branch from 5b4722c to 71baf95 Compare November 9, 2026 14:39
@otelbot otelbot Bot removed the api-change Changes to public API surface area label Nov 9, 2026
@dashpole
dashpole self-requested a review November 9, 2026 18:11
@rooks-ns
rooks-ns force-pushed the feat/composable-metric-views branch 2 times, most recently from 845fbfd to 6d78faf Compare November 11, 2026 20:22
@rooks-ns
rooks-ns marked this pull request as ready for review November 12, 2026 02:19
@rooks-ns
rooks-ns requested a review from a team as a code owner November 12, 2026 02:19
@rooks-ns
rooks-ns force-pushed the feat/composable-metric-views branch 3 times, most recently from 23adc54 to f6bd08b Compare November 13, 2026 03:40
Implement experimental composable view matching mode according to the OpenTelemetry Metrics SDK specification and declarative config schema.

- Introduce ViewMatchingMode (INDEPENDENT, COMPOSABLE).
- Track explicit View properties in ViewBuilder, View, and RegisteredView to distinguish configured fields from defaults.
- Implement composable view resolution in ViewRegistry: stream grouping by configured name, last-wins attribute/cardinality merging, backward-scanning aggregation compatibility fallback, and attribute filter conjunction.
- Add reflection bridge in SdkMeterProviderUtil to safely configure ViewMatchingMode on SdkMeterProviderBuilder without modifying public 1.x APIs.
- Wire view_matching_mode/development in MeterProviderFactory for declarative configuration.
- Add comprehensive unit and integration tests.

Fixes open-telemetry#9013
@rooks-ns
rooks-ns force-pushed the feat/composable-metric-views branch from f6bd08b to 0dbd6d0 Compare November 13, 2026 03:53

@dashpole dashpole left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I validated that this properly implements the composable view spec.

assertThat(point.getValue()).isEqualTo(1);
}
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Because attribute filter functions cannot be compared for equality, this test actually emits 2 conflicting streams instead of deduplicating them (unlike the test right below it), and the for loop would pass even if metrics were empty. My suggestion would be to either remove this test or assert assertThat(metrics).isNotEmpty() before the loop.

abstract Predicate<String> getExplicitAttributeFilter();

@Nullable
abstract Integer getExplicitCardinalityLimit();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Including getExplicitAggregation(), getExplicitAttributeFilter(), and getExplicitCardinalityLimit() in View.equals means View.builder().build() and View.builder().setAggregation(Aggregation.defaultAggregation()).build() are no longer considered equal. Should we exclude those three internal tracking fields from equals and hashCode so View equality only compares the effective view settings?

@otelbot otelbot Bot added the api-change Changes to public API surface area label Nov 13, 2026
@otelbot

otelbot Bot commented Nov 13, 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-metrics

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

@rooks-ns

rooks-ns commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

@dashpole commit includes the changes that have been suggested. Thanks.

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.

Add experimental view_matching_mode (composable metric views) support

2 participants