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

Merged
merged 4 commits into from
May 27, 2024

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 35 commits behind head on main.

Current head 313ce47 differs from pull request most recent head 5da7a9d

Please upload reports for the commit 5da7a9d 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 🙂

packages/sdk-metrics/src/Instruments.ts Outdated Show resolved Hide resolved
@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 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.

@@ -36,7 +37,6 @@ import {
AsyncWritableMetricStorage,
WritableMetricStorage,
} from './state/WritableMetricStorage';
import { Gauge } from './types';
Copy link
Member

@pichlermarc pichlermarc May 15, 2024

Choose a reason for hiding this comment

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

We should keep using Gauge from ./types as it could still happen that (for instance) @opentelemetry/api@1.3.0 is used which does not have the Gauge type.

@@ -41,7 +41,6 @@ import {
UpDownCounterInstrument,
} from './Instruments';
import { MeterSharedState } from './state/MeterSharedState';
import { Gauge } from './types';
Copy link
Member

@pichlermarc pichlermarc May 15, 2024

Choose a reason for hiding this comment

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

We should keep using Gauge from ./types as it could still happen that (for instance) @opentelemetry/api@1.3.0 is used which does not have the Gauge type.

@clintonb clintonb force-pushed the clintonb/synchronous-gauge branch from 2ff80f5 to bead4cf Compare May 15, 2024 18:16
@clintonb
Copy link
Contributor Author

@pichlermarc fixes implemented

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.

Thanks 🙂

@clintonb clintonb force-pushed the clintonb/synchronous-gauge branch from bead4cf to 5da7a9d Compare May 18, 2024 20:21
@clintonb
Copy link
Contributor Author

@pichlermarc what are the next steps? Do you merge, or someone else?

@pichlermarc pichlermarc changed the title feat(instrumentation): added synchronous gauge feat(api): added synchronous gauge May 22, 2024
@pichlermarc pichlermarc added this pull request to the merge queue May 27, 2024
Merged via the queue into open-telemetry:main with commit 095003d May 27, 2024
19 checks passed
@clintonb clintonb deleted the clintonb/synchronous-gauge branch May 27, 2024 15:31
Zirak pushed a commit to Zirak/opentelemetry-js that referenced this pull request Sep 14, 2024
* feat(instrumentation): added synchronous gauge

* fixup! feat(instrumentation): added synchronous gauge

* fixup! feat(instrumentation): added synchronous gauge

* fixup! feat(instrumentation): added synchronous gauge
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