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

refactor(sdk-metrics) Swap workaround types for @otel/api types #5254

Merged
merged 1 commit into from
Dec 13, 2024

Conversation

chancancode
Copy link
Contributor

@chancancode chancancode commented Dec 11, 2024

Which problem is this PR solving?

The internal Gauge and the unnamed MetricAdvice types were introduced in the 1.0 series when the metrics package depended on an older version of the api package that didn't come with those types, so the interfaces were essentially vendored into the package for internal use.

Now with the 2.0 release on the horrizon, we can bump the required version of @otel/api and is now safe to unvendor these types in favor of the official ones.

This is not expected to have any impact on consumers as the types are intended to be compatible for the positions they were used in.

However, the minimum requirement for the @opentelemetry/api peer dependency has been raised to 1.9.0.

Fixes #5223
Fixes #5224

Short description of the changes

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • TypeScript compiles

Checklist:

  • Followed the style guidelines of this project
  • Unit tests have been added N/A – type-only changes
  • Documentation has been updated

@chancancode chancancode requested a review from a team as a code owner December 11, 2024 19:57
Copy link

linux-foundation-easycla bot commented Dec 11, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: chancancode / name: Godfrey Chan (fd2f57c)

*
* This is intentionally not using the API's type as it's only available from @opentelemetry/api 1.7.0 and up.
* In SDK 2.0 we'll be able to bump the minimum API version and remove this workaround.
* @experimental
Copy link
Contributor Author

@chancancode chancancode Dec 11, 2024

Choose a reason for hiding this comment

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

Kept the @experimental tag since the upstream type is itself @experimental. If it's not worth it I can also just remove the doc comment altogether.

FWIW, the entire InstrumentDescriptor interface is marked as @deprecated in sdk-metrics/index.ts in favor of MetricDescriptor, which does not have this field. But since @pichlermarc opened #5224 pretty recently, I assume the intention is to still keep this and carry it forward into 2.0.

Copy link
Member

Choose a reason for hiding this comment

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

Keeping it experimental is good - we'll bump it to stable in a separate issue. 👍

The InstrumentDescriptor is marked as deprecated as we will stop exporting it. Most properties will move to a MetricDescriptor and InstrumentDescriptor will extend it for internal use. Issue to follow.

Copy link

codecov bot commented Dec 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.57%. Comparing base (47212bb) to head (fd2f57c).
Report is 2 commits behind head on next.

Additional details and impacted files
@@            Coverage Diff             @@
##             next    #5254      +/-   ##
==========================================
+ Coverage   94.56%   94.57%   +0.01%     
==========================================
  Files         316      316              
  Lines        8037     8037              
  Branches     1628     1628              
==========================================
+ Hits         7600     7601       +1     
+ Misses        437      436       -1     
Files with missing lines Coverage Δ
packages/sdk-metrics/src/InstrumentDescriptor.ts 100.00% <100.00%> (ø)
packages/sdk-metrics/src/Instruments.ts 96.00% <ø> (ø)
packages/sdk-metrics/src/Meter.ts 100.00% <ø> (ø)

... and 1 file with indirect coverage changes

Copy link
Member

@pichlermarc pichlermarc left a comment

Choose a reason for hiding this comment

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

Hi @chancancode, thank you for your contribution 🙂 This looks great already 🙌

Only a changelog entry in CHANGELOG_NEXT.md is missing then we can get this merged. 🙂

packages/sdk-metrics/package.json Show resolved Hide resolved
*
* This is intentionally not using the API's type as it's only available from @opentelemetry/api 1.7.0 and up.
* In SDK 2.0 we'll be able to bump the minimum API version and remove this workaround.
* @experimental
Copy link
Member

Choose a reason for hiding this comment

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

Keeping it experimental is good - we'll bump it to stable in a separate issue. 👍

The InstrumentDescriptor is marked as deprecated as we will stop exporting it. Most properties will move to a MetricDescriptor and InstrumentDescriptor will extend it for internal use. Issue to follow.

@chancancode chancancode force-pushed the rm-workaround-types branch 3 times, most recently from 3f2a9fa to 230d3eb Compare December 12, 2024 18:26
@chancancode chancancode changed the title [sdk-metrics] Switch workaround types to official @otel/api types refactor(sdk-metrics) Swap workaround types for @otel/api types Dec 12, 2024
@chancancode
Copy link
Contributor Author

@pichlermarc Should be good to go now. Categorized it as a refactor since these types are internal and the replacements are expected to be compatible. Since I have the context open now, wouldn't mind working on that next refactor, my understanding is (on the next branch):

  • remove the deprecated alias export in sdk-metrics/index.ts
  • refactor the internal un-exported InstrumentDescriptor to extend from MetricDescriptor
  • add CHANGELOG_NEXT.md entry

If that sounds good, let me know, save you from creating an issue for it.

Copy link
Member

@pichlermarc pichlermarc left a comment

Choose a reason for hiding this comment

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

thank you for working on this 🙂

@pichlermarc
Copy link
Member

Since I have the context open now, wouldn't mind working on that next refactor, my understanding is (on the next branch):

* remove the deprecated alias export in `sdk-metrics/index.ts`

* refactor the internal un-exported `InstrumentDescriptor` to extend from `MetricDescriptor`

* add `CHANGELOG_NEXT.md` entry

If that sounds good, let me know, save you from creating an issue for it.

That sounds great 🙌

@@ -23,6 +23,7 @@

### :house: (Internal)

* refactor(sdk-metrics): remove `Gauge` and `MetricAdvice` workaround types in favor of the upstream `@opentelemetry/api` types [#5254](https://github.com/open-telemetry/opentelemetry-js/pull/5254) @chancancode
Copy link
Member

Choose a reason for hiding this comment

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

ah there still needs to be an entry to breaking as we drop support for old API versions 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, that's right, fixed!

The internal `Gauge` and the unnamed `MetricAdvice` types were
introduced in the 1.0 series when the metrics package depended on
an older version of the api package that didn't come with those
types, so the interfaces were essentially vendored into the package
for internal use.

Now with the 2.0 release on the horrizon, we can bump the required
version of @otel/api and is now safe to unvendor these types in
favor of the official ones.

This is not expected to have any impact on consumers as the types
are intended to be compatible for the positions they were used in.

However, the minimum requirement for the `@opentelemetry/api` peer
dependency has been raised to 1.9.0.

Fixes open-telemetry#5223
Fixes open-telemetry#5224
@pichlermarc pichlermarc merged commit 6d7a73a into open-telemetry:next Dec 13, 2024
18 checks passed
@chancancode chancancode deleted the rm-workaround-types branch December 13, 2024 18:19
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.

2 participants