Skip to content

Commit

Permalink
remove getDefaultBound and setCallback from Metric API (#793)
Browse files Browse the repository at this point in the history
  • Loading branch information
mayurkale22 authored Feb 20, 2020
1 parent 5e0d2c9 commit 28b9b74
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 41 deletions.
10 changes: 0 additions & 10 deletions packages/opentelemetry-api/src/metrics/Metric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,6 @@ export interface Metric<T> {
*/
bind(labels: LabelSet): T;

/**
* Returns a Instrument for a metric with all labels not set.
*/
getDefaultBound(): T;

/**
* Removes the Instrument from the metric, if it is present.
* @param labels the canonicalized LabelSet used to associate with this
Expand All @@ -102,11 +97,6 @@ export interface Metric<T> {
* Clears all timeseries from the Metric.
*/
clear(): void;

/**
* what should the callback signature be?
*/
setCallback(fn: () => void): void;
}

export interface MetricUtils {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,34 +32,19 @@ describe('NoopMeter', () => {
const labelSet = meter.labels(labels);

// ensure NoopMetric does not crash.
counter.setCallback(() => {
assert.fail('callback occurred');
});
counter.bind(labelSet).add(1);
counter.getDefaultBound().add(1);
counter.unbind(labelSet);

// ensure the correct noop const is returned
assert.strictEqual(counter, NOOP_COUNTER_METRIC);
assert.strictEqual(counter.bind(labelSet), NOOP_BOUND_COUNTER);
assert.strictEqual(counter.getDefaultBound(), NOOP_BOUND_COUNTER);
counter.clear();

const measure = meter.createMeasure('some-name');
measure.getDefaultBound().record(1);
measure.getDefaultBound().record(1, { key: { value: 'value' } });
measure.getDefaultBound().record(
1,
{ key: { value: 'value' } },
{
traceId: 'a3cda95b652f4a1592b449d5929fda1b',
spanId: '5e0c63257de34c92',
}
);
measure.bind(labelSet).record(1);

// ensure the correct noop const is returned
assert.strictEqual(measure, NOOP_MEASURE_METRIC);
assert.strictEqual(measure.getDefaultBound(), NOOP_BOUND_MEASURE);
assert.strictEqual(measure.bind(labelSet), NOOP_BOUND_MEASURE);

const options = {
Expand Down
15 changes: 0 additions & 15 deletions packages/opentelemetry-metrics/src/Metric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,6 @@ export abstract class Metric<T extends BaseBoundInstrument>
return instrument;
}

/**
* Returns a Instrument for a metric with all labels not set.
*/
getDefaultBound(): T {
// @todo: implement this method
this._logger.error('not implemented yet');
throw new Error('not implemented yet');
}

/**
* Removes the Instrument from the metric, if it is present.
* @param labelSet the canonicalized LabelSet used to associate with this
Expand All @@ -86,12 +77,6 @@ export abstract class Metric<T extends BaseBoundInstrument>
this._instruments.clear();
}

setCallback(fn: () => void): void {
// @todo: implement this method
this._logger.error('not implemented yet');
return;
}

getMetricRecord(): MetricRecord[] {
return Array.from(this._instruments.values()).map(instrument => ({
descriptor: this._descriptor,
Expand Down

0 comments on commit 28b9b74

Please sign in to comment.