Skip to content

Commit

Permalink
fix: use GAUGE_DOUBLE and COUNTER_DOUBLE type
Browse files Browse the repository at this point in the history
  • Loading branch information
mayurkale22 committed Oct 30, 2019
1 parent ec99f13 commit f8e3fe1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions packages/opentelemetry-metrics/src/Metric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export abstract class Metric<T extends BaseHandle> implements types.Metric<T> {

constructor(
private readonly _name: string,
private readonly _type: MetricDescriptorType,
private readonly _options: MetricOptions
) {
this._monotonic = _options.monotonic;
Expand Down Expand Up @@ -111,7 +112,7 @@ export abstract class Metric<T extends BaseHandle> implements types.Metric<T> {
description: this._options.description,
unit: this._options.unit,
labelKeys: this._options.labelKeys,
type: MetricDescriptorType.GAUGE_INT64,
type: this._type,
};
}

Expand All @@ -121,7 +122,7 @@ export abstract class Metric<T extends BaseHandle> implements types.Metric<T> {
/** This is a SDK implementation of Counter Metric. */
export class CounterMetric extends Metric<CounterHandle> {
constructor(name: string, options: MetricOptions) {
super(name, options);
super(name, MetricDescriptorType.COUNTER_DOUBLE, options);
}
protected _makeHandle(labelValues: string[]): CounterHandle {
return new CounterHandle(
Expand All @@ -136,7 +137,7 @@ export class CounterMetric extends Metric<CounterHandle> {
/** This is a SDK implementation of Gauge Metric. */
export class GaugeMetric extends Metric<GaugeHandle> {
constructor(name: string, options: MetricOptions) {
super(name, options);
super(name, MetricDescriptorType.GAUGE_DOUBLE, options);
}
protected _makeHandle(labelValues: string[]): GaugeHandle {
return new GaugeHandle(
Expand Down
4 changes: 2 additions & 2 deletions packages/opentelemetry-metrics/test/Meter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ describe('Meter', () => {
name: 'counter',
description: 'test',
unit: '1',
type: MetricDescriptorType.GAUGE_INT64,
type: MetricDescriptorType.COUNTER_DOUBLE,
labelKeys: ['key'],
});
assert.strictEqual(timeseries.length, 1);
Expand Down Expand Up @@ -284,7 +284,7 @@ describe('Meter', () => {
name: 'gauge',
description: '',
unit: 'ms',
type: MetricDescriptorType.GAUGE_INT64,
type: MetricDescriptorType.GAUGE_DOUBLE,
labelKeys: ['gauge-key'],
});
assert.strictEqual(timeseries.length, 2);
Expand Down

0 comments on commit f8e3fe1

Please sign in to comment.