opentelemetry-js
opentelemetry-js copied to clipboard
Add Synchronous Gauge instrument to the metrics API
This is a recent addition: https://github.com/open-telemetry/opentelemetry-specification/pull/3540
https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#gauge
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);
}
}
It's yours @mohitk05 :slightly_smiling_face:
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.
Anyone know of a workaround for now?
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)
Apologies for the delay here, seems like @clintonb has implemented this. Please assign them/close the issue as required.