Skip to content

Commit

Permalink
remove Gauge instrument (open-telemetry#791)
Browse files Browse the repository at this point in the history
* remove Gauge instrument
  • Loading branch information
mayurkale22 authored and dyladan committed Feb 18, 2021
1 parent 735da09 commit 176bd28
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 61 deletions.
9 changes: 0 additions & 9 deletions api/src/metrics/BoundInstrument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,6 @@ export interface BoundCounter {
add(value: number): void;
}

/** An Instrument for Gauge Metric. */
export interface BoundGauge {
/**
* Sets the given value. Values can be negative.
* @param value the new value.
*/
set(value: number): void;
}

/** Measure to report instantaneous measurement of a value. */
export interface BoundMeasure {
/**
Expand Down
16 changes: 3 additions & 13 deletions api/src/metrics/Meter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
*/

import { Metric, MetricOptions, Labels, LabelSet } from './Metric';
import { BoundCounter, BoundGauge, BoundMeasure } from './BoundInstrument';
import { BoundCounter, BoundMeasure } from './BoundInstrument';

/**
* An interface to allow the recording metrics.
*
* {@link Metric}s are used for recording pre-defined aggregation (`Gauge` and
* `Counter`), or raw values (`Measure`) in which the aggregation and labels
* {@link Metric}s are used for recording pre-defined aggregation (`Counter`),
* or raw values (`Measure`) in which the aggregation and labels
* for the exported metric are deferred.
*/
export interface Meter {
Expand All @@ -41,16 +41,6 @@ export interface Meter {
*/
createCounter(name: string, options?: MetricOptions): Metric<BoundCounter>;

/**
* Creates a new `gauge` metric. Generally, this kind of metric should be used
* when the metric cannot be expressed as a sum or because the measurement
* interval is arbitrary. Use this kind of metric when the measurement is not
* a quantity, and the sum and event count are not of interest.
* @param name the name of the metric.
* @param [options] the metric options.
*/
createGauge(name: string, options?: MetricOptions): Metric<BoundGauge>;

/**
* Provide a pre-computed re-useable LabelSet by
* converting the unordered labels into a canonicalized
Expand Down
28 changes: 1 addition & 27 deletions api/src/metrics/NoopMeter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import { Meter } from './Meter';
import { MetricOptions, Metric, Labels, LabelSet, MetricUtils } from './Metric';
import { BoundMeasure, BoundCounter, BoundGauge } from './BoundInstrument';
import { BoundMeasure, BoundCounter } from './BoundInstrument';
import { DistributedContext } from '../distributed_context/DistributedContext';
import { SpanContext } from '../trace/span_context';

Expand Down Expand Up @@ -45,15 +45,6 @@ export class NoopMeter implements Meter {
return NOOP_COUNTER_METRIC;
}

/**
* Returns a constant gauge metric.
* @param name the name of the metric.
* @param [options] the metric options.
*/
createGauge(name: string, options?: MetricOptions): Metric<BoundGauge> {
return NOOP_GAUGE_METRIC;
}

labels(labels: Labels): LabelSet {
return NOOP_LABEL_SET;
}
Expand Down Expand Up @@ -111,13 +102,6 @@ export class NoopCounterMetric extends NoopMetric<BoundCounter>
}
}

export class NoopGaugeMetric extends NoopMetric<BoundGauge>
implements Pick<MetricUtils, 'set'> {
set(value: number, labelSet: LabelSet) {
this.bind(labelSet).set(value);
}
}

export class NoopMeasureMetric extends NoopMetric<BoundMeasure>
implements Pick<MetricUtils, 'record'> {
record(
Expand All @@ -142,12 +126,6 @@ export class NoopBoundCounter implements BoundCounter {
}
}

export class NoopBoundGauge implements BoundGauge {
set(value: number): void {
return;
}
}

export class NoopBoundMeasure implements BoundMeasure {
record(
value: number,
Expand All @@ -159,10 +137,6 @@ export class NoopBoundMeasure implements BoundMeasure {
}

export const NOOP_METER = new NoopMeter();

export const NOOP_BOUND_GAUGE = new NoopBoundGauge();
export const NOOP_GAUGE_METRIC = new NoopGaugeMetric(NOOP_BOUND_GAUGE);

export const NOOP_BOUND_COUNTER = new NoopBoundCounter();
export const NOOP_COUNTER_METRIC = new NoopCounterMetric(NOOP_BOUND_COUNTER);

Expand Down
12 changes: 0 additions & 12 deletions api/test/noop-implementations/noop-meter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ import {
Labels,
NoopMeterProvider,
NOOP_BOUND_COUNTER,
NOOP_BOUND_GAUGE,
NOOP_BOUND_MEASURE,
NOOP_COUNTER_METRIC,
NOOP_GAUGE_METRIC,
NOOP_MEASURE_METRIC,
} from '../../src';

Expand Down Expand Up @@ -64,14 +62,6 @@ describe('NoopMeter', () => {
assert.strictEqual(measure.getDefaultBound(), NOOP_BOUND_MEASURE);
assert.strictEqual(measure.bind(labelSet), NOOP_BOUND_MEASURE);

const gauge = meter.createGauge('some-name');
gauge.getDefaultBound().set(1);

// ensure the correct noop const is returned
assert.strictEqual(gauge, NOOP_GAUGE_METRIC);
assert.strictEqual(gauge.getDefaultBound(), NOOP_BOUND_GAUGE);
assert.strictEqual(gauge.bind(labelSet), NOOP_BOUND_GAUGE);

const options = {
component: 'tests',
description: 'the testing package',
Expand All @@ -81,7 +71,5 @@ describe('NoopMeter', () => {
assert.strictEqual(measureWithOptions, NOOP_MEASURE_METRIC);
const counterWithOptions = meter.createCounter('some-name', options);
assert.strictEqual(counterWithOptions, NOOP_COUNTER_METRIC);
const gaugeWithOptions = meter.createGauge('some-name', options);
assert.strictEqual(gaugeWithOptions, NOOP_GAUGE_METRIC);
});
});

0 comments on commit 176bd28

Please sign in to comment.