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(instrumentation): added synchronous gauge #4528

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

clintonb
Copy link
Contributor

@clintonb clintonb commented Mar 7, 2024

Which problem is this PR solving?

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes #4296

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

  • Test A

Checklist:

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

Copy link

linux-foundation-easycla bot commented Mar 7, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

Copy link

codecov bot commented Mar 13, 2024

Codecov Report

Attention: Patch coverage is 80.00000% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 92.84%. Comparing base (2610122) to head (313ce47).
Report is 23 commits behind head on main.

❗ Current head 313ce47 differs from pull request most recent head 2ff80f5. Consider uploading reports for the commit 2ff80f5 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4528      +/-   ##
==========================================
+ Coverage   90.77%   92.84%   +2.07%     
==========================================
  Files          90      328     +238     
  Lines        1930     9524    +7594     
  Branches      417     2050    +1633     
==========================================
+ Hits         1752     8843    +7091     
- Misses        178      681     +503     
Files Coverage Δ
api/src/metrics/Metric.ts 100.00% <ø> (ø)
api/src/metrics/NoopMeter.ts 95.34% <80.00%> (-2.02%) ⬇️

... and 244 files 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.

@clintonb looks awesome already. 🙂

I see this is currently a draft: when getting ready for the review, would you mind splitting the PR into two parts? So in essence:

  • PR#1 SDK changes only (merged first)
  • PR#2 API changes only (merged second)

The reason for that is: the SDK changes need to be functional with an older version of the API that does not include the new types. If we split that into two PRs we'll very easily be able to see if there's any adjustments that need to be made to the SDK part to ensure that it also works with the older (current) version of the API. That usually includes duplicating types from the API PR#2 into the SDK PR#1 to ensure we don't use anything that might not yet be there 🙂

@@ -22,6 +22,7 @@ import {
ValueType,
UpDownCounter,
Counter,
Gauge,
Copy link
Member

Choose a reason for hiding this comment

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

This is the case I was talking about above, where we may need to duplicate the type from @opentelemetry/api as we need to be backward compatible to @opentelemetry/api@1.3.0 which does not yet have this type. 🙂

While somewhat counter-intuitive, splitting it into two PRs where the SDK changes come first makes this a bit easier to see. 🙂

@clintonb clintonb force-pushed the clintonb/synchronous-gauge branch 2 times, most recently from ea980b5 to d339cf4 Compare March 31, 2024 16:55
@clintonb clintonb marked this pull request as ready for review March 31, 2024 16:57
@clintonb clintonb requested a review from a team as a code owner March 31, 2024 16:57
@clintonb clintonb force-pushed the clintonb/synchronous-gauge branch 3 times, most recently from e803423 to 313ce47 Compare April 3, 2024 15:10
@clintonb
Copy link
Contributor Author

clintonb commented Apr 4, 2024

@pichlermarc let me know if there is anything I need to do here and/or next steps.,

@pichlermarc
Copy link
Member

@pichlermarc let me know if there is anything I need to do here and/or next steps.,

Sorry this is taking so long.

Turns out we need to figure out a way to add experimental metrics features to the API package as we've never done it before with new Instruments. I've opened a prototype PR to look into that #4622.

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.

The specification was marked stable, so we can proceed with this PR without having to go the experimental route (#4622)

While reviewing this PR I just saw that we put the Type-Parameters on the SDK implementation of the Gauge too:

createGauge<AttributesTypes extends Attributes = Attributes>(
name: string,
options?: MetricOptions
): Gauge<AttributesTypes> {

These can be removed now as they're part of the interface we're implementing (like on the rest of the functions on the Meter class).

You may now also remove the @experimental annotations from the SDK that we added in #4565:

api/src/metrics/NoopMeter.ts Outdated Show resolved Hide resolved
@clintonb clintonb force-pushed the clintonb/synchronous-gauge branch from 313ce47 to 0b02976 Compare May 6, 2024 06:56
@clintonb
Copy link
Contributor Author

clintonb commented May 6, 2024

@pichlermarc please review. 🤞🏾

packages/sdk-metrics/src/types.ts Outdated Show resolved Hide resolved
packages/sdk-metrics/src/Meter.ts Outdated Show resolved Hide resolved
@clintonb clintonb force-pushed the clintonb/synchronous-gauge branch from 0b02976 to 2ff80f5 Compare May 6, 2024 15:34
@clintonb
Copy link
Contributor Author

clintonb commented May 6, 2024

@pichlermarc one more look?

@clintonb
Copy link
Contributor Author

clintonb commented May 6, 2024

Failing test is unrelated to this change.

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.

Add Synchronous Gauge instrument to the metrics API
2 participants