Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sdk-metrics)!: extract IMetricReader interface and use it over abstract class #5311

Conversation

pichlermarc
Copy link
Member

Which problem is this PR solving?

We periodically run into problems since private properties in classes cause the type to be incompatible between versions. This PR fixes that for MetricReader by extracting an interface which we then use instead of the abstract class type in our public interface.

In this PR MetricReader type stays as-is, but this is marked as a breaking change since we technically narrow down what's being provided by MeterProviderOptions.

Part of #5283

Type of change

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

@pichlermarc pichlermarc added pkg:sdk-metrics target:next-major-release This PR targets the next major release (`next` branch) labels Jan 9, 2025
@pichlermarc pichlermarc added this to the OpenTelemetry SDK 2.0 milestone Jan 9, 2025
@pichlermarc pichlermarc marked this pull request as ready for review January 9, 2025 17:37
@pichlermarc pichlermarc requested a review from a team as a code owner January 9, 2025 17:37
Copy link

codecov bot commented Jan 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.54%. Comparing base (c00f36e) to head (ce19b91).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5311   +/-   ##
=======================================
  Coverage   94.54%   94.54%           
=======================================
  Files         318      318           
  Lines        8051     8051           
  Branches     1694     1694           
=======================================
  Hits         7612     7612           
  Misses        439      439           
Files with missing lines Coverage Δ
...imental/packages/opentelemetry-sdk-node/src/sdk.ts 96.01% <100.00%> (ø)
packages/sdk-metrics/src/MeterProvider.ts 100.00% <ø> (ø)
packages/sdk-metrics/src/export/MetricReader.ts 100.00% <100.00%> (ø)
packages/sdk-metrics/src/state/MetricCollector.ts 100.00% <100.00%> (ø)

@legendecas
Copy link
Member

this is marked as a breaking change since we technically narrow down what's being provided by MeterProviderOptions.

Isn't this change make the option bag more general to accept any object that conforms to the new interface, instead of a subclass? In this sense, it reads to me that this is not breaking.

@pichlermarc
Copy link
Member Author

this is marked as a breaking change since we technically narrow down what's being provided by MeterProviderOptions.

Isn't this change make the option bag more general to accept any object that conforms to the new interface, instead of a subclass? In this sense, it reads to me that this is not breaking.

I'm not sure what the stability guarantees are for options bags like this. Practically this is non-breaking - and as a developer I would always expect this to become more general due to the context in which it should be used.

Technically however, the only way this can be breaking is that if someone else consumes a MeterProviderOptions object as part of their own code somewhere, and they expect a MetricReader instead of a IMetricReader. In that case the user that pulls in this change change will get a compile-time error.

Copy link
Member

@legendecas legendecas left a comment

Choose a reason for hiding this comment

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

Thanks for the explanation!

@legendecas
Copy link
Member

This has a conflict.

@pichlermarc pichlermarc added this pull request to the merge queue Jan 23, 2025
Merged via the queue into open-telemetry:main with commit df49fb1 Jan 23, 2025
15 checks passed
@pichlermarc pichlermarc deleted the feat/metricreader-interface branch January 23, 2025 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg:sdk-metrics target:next-major-release This PR targets the next major release (`next` branch)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants