Skip to content

Commit 2ff80f5

Browse files
committed
fixup! feat(instrumentation): added synchronous gauge
1 parent 42f977c commit 2ff80f5

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

packages/sdk-metrics/src/Meter.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import {
2525
ObservableUpDownCounter,
2626
BatchObservableCallback,
2727
Observable,
28-
Attributes,
2928
Gauge,
3029
} from '@opentelemetry/api';
3130
import {
@@ -52,10 +51,7 @@ export class Meter implements IMeter {
5251
/**
5352
* Create a {@link Gauge} instrument.
5453
*/
55-
createGauge<AttributesTypes extends Attributes = Attributes>(
56-
name: string,
57-
options?: MetricOptions
58-
): Gauge<AttributesTypes> {
54+
createGauge(name: string, options?: MetricOptions): Gauge {
5955
const descriptor = createInstrumentDescriptor(
6056
name,
6157
InstrumentType.GAUGE,

packages/sdk-metrics/src/types.ts

+14
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
import { Context, MetricAttributes } from '@opentelemetry/api';
1617

1718
export type CommonReaderOptions = {
1819
timeoutMillis?: number;
@@ -23,3 +24,16 @@ export type CollectionOptions = CommonReaderOptions;
2324
export type ShutdownOptions = CommonReaderOptions;
2425

2526
export type ForceFlushOptions = CommonReaderOptions;
27+
28+
/**
29+
* This is intentionally not using the API's type as it's only available from @opentelemetry/api 1.9.0 and up.
30+
* In SDK 2.0 we'll be able to bump the minimum API version and remove this workaround.
31+
*/
32+
export interface Gauge<
33+
AttributesTypes extends MetricAttributes = MetricAttributes,
34+
> {
35+
/**
36+
* Records a measurement. Value of the measurement must not be negative.
37+
*/
38+
record(value: number, attributes?: AttributesTypes, context?: Context): void;
39+
}

0 commit comments

Comments
 (0)