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

Add Synchronous Gauge instrument to the metrics API #4296

Closed
karlbohlmark opened this issue Nov 15, 2023 · 5 comments · Fixed by #4528
Closed

Add Synchronous Gauge instrument to the metrics API #4296

karlbohlmark opened this issue Nov 15, 2023 · 5 comments · Fixed by #4528
Assignees
Labels
api:metrics Issues and PRs related to the Metrics API feature-request sdk:metrics Issues and PRs related to the Metrics SDK spec-feature This is a request to implement a new feature which is already specified by the OTel specification

Comments

@karlbohlmark
Copy link

This is a recent addition: open-telemetry/opentelemetry-specification#3540

https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#gauge

@pichlermarc pichlermarc added api:metrics Issues and PRs related to the Metrics API sdk:metrics Issues and PRs related to the Metrics SDK spec-feature This is a request to implement a new feature which is already specified by the OTel specification labels Dec 13, 2023
@mohitk05
Copy link
Contributor

Hey @pichlermarc, is this up for grabs? I can take this up. I think the implementation could look similar to other SyncInstruments?

export class GaugeInstrument extends SyncInstrument implements Gauge {
  record(value: number, attributes?: MetricAttributes, ctx?: Context): void {
    this._record(value, attributes, ctx);
  }
}

@pichlermarc
Copy link
Member

It's yours @mohitk05 🙂

Yes, implementation would look similar, however, you'll need to duplicate the (currently non-existent) Gauge interface in the SDK as we can't use types that are not available in earlier API versions. The SDK is backwards compatible with the API, so it can't use any types that were added after its initial release.

@fordneild
Copy link

Anyone know of a workaround for now?

@pichlermarc
Copy link
Member

Anyone know of a workaround for now?

Using an UpDownCounter and registering a view with a LastValueAggregation (see https://opentelemetry.io/docs/languages/js/instrumentation/#configure-metric-views, it does not show that example implicitly, but similar to the histogram one, except you're adding new LastValueAggregation() as the aggregation)

@mohitk05
Copy link
Contributor

Apologies for the delay here, seems like @clintonb has implemented this. Please assign them/close the issue as required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api:metrics Issues and PRs related to the Metrics API feature-request sdk:metrics Issues and PRs related to the Metrics SDK spec-feature This is a request to implement a new feature which is already specified by the OTel specification
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants