diff --git a/api/src/metrics/BoundInstrument.ts b/api/src/metrics/BoundInstrument.ts index 07302bd22f..0be696d43a 100644 --- a/api/src/metrics/BoundInstrument.ts +++ b/api/src/metrics/BoundInstrument.ts @@ -26,15 +26,15 @@ export interface BoundCounter { add(value: number): void; } -/** Measure to report instantaneous measurement of a value. */ -export interface BoundMeasure { +/** ValueRecorder to report instantaneous measurement of a value. */ +export interface BoundValueRecorder { /** - * Records the given value to this measure. - * @param value the measurement to record. + * Records the given value to this value recorder. + * @param value to record. * @param correlationContext the correlationContext associated with the - * measurements. + * values. * @param spanContext the {@link SpanContext} that identifies the {@link Span} - * for which the measurements are associated with. + * which the values are associated with. */ record(value: number): void; record(value: number, correlationContext: CorrelationContext): void; diff --git a/api/src/metrics/Meter.ts b/api/src/metrics/Meter.ts index 0b43708c4d..5ed8bbf3a9 100644 --- a/api/src/metrics/Meter.ts +++ b/api/src/metrics/Meter.ts @@ -14,22 +14,22 @@ * limitations under the License. */ -import { MetricOptions, Counter, Measure, Observer } from './Metric'; +import { MetricOptions, Counter, ValueRecorder, Observer } from './Metric'; /** * An interface to allow the recording metrics. * * {@link Metric}s are used for recording pre-defined aggregation (`Counter`), - * or raw values (`Measure`) in which the aggregation and labels + * or raw values (`ValueRecorder`) in which the aggregation and labels * for the exported metric are deferred. */ export interface Meter { /** - * Creates and returns a new `Measure`. + * Creates and returns a new `ValueRecorder`. * @param name the name of the metric. * @param [options] the metric options. */ - createMeasure(name: string, options?: MetricOptions): Measure; + createValueRecorder(name: string, options?: MetricOptions): ValueRecorder; /** * Creates a new `Counter` metric. Generally, this kind of metric when the diff --git a/api/src/metrics/Metric.ts b/api/src/metrics/Metric.ts index 3996e5498b..00d4ef215e 100644 --- a/api/src/metrics/Metric.ts +++ b/api/src/metrics/Metric.ts @@ -17,7 +17,7 @@ import { CorrelationContext } from '../correlation_context/CorrelationContext'; import { SpanContext } from '../trace/span_context'; import { ObserverResult } from './ObserverResult'; -import { BoundCounter, BoundMeasure } from './BoundInstrument'; +import { BoundCounter, BoundValueRecorder } from './BoundInstrument'; /** * Options needed for metric creation @@ -56,7 +56,7 @@ export interface MetricOptions { monotonic?: boolean; /** - * (Measure only, default true) Asserts that this metric will only accept + * (ValueRecorder only, default true) Asserts that this metric will only accept * non-negative values (e.g. disk usage). */ absolute?: boolean; @@ -128,9 +128,9 @@ export interface Counter extends UnboundMetric { add(value: number, labels?: Labels): void; } -export interface Measure extends UnboundMetric { +export interface ValueRecorder extends UnboundMetric { /** - * Records the given value to this measure. + * Records the given value to this value recorder. */ record(value: number, labels?: Labels): void; diff --git a/api/src/metrics/NoopMeter.ts b/api/src/metrics/NoopMeter.ts index dcd6a5dea1..eed8c4e9bf 100644 --- a/api/src/metrics/NoopMeter.ts +++ b/api/src/metrics/NoopMeter.ts @@ -20,10 +20,10 @@ import { UnboundMetric, Labels, Counter, - Measure, + ValueRecorder, Observer, } from './Metric'; -import { BoundMeasure, BoundCounter } from './BoundInstrument'; +import { BoundValueRecorder, BoundCounter } from './BoundInstrument'; import { CorrelationContext } from '../correlation_context/CorrelationContext'; import { SpanContext } from '../trace/span_context'; import { ObserverResult } from './ObserverResult'; @@ -36,12 +36,12 @@ export class NoopMeter implements Meter { constructor() {} /** - * Returns constant noop measure. + * Returns constant noop value recorder. * @param name the name of the metric. * @param [options] the metric options. */ - createMeasure(name: string, options?: MetricOptions): Measure { - return NOOP_MEASURE_METRIC; + createValueRecorder(name: string, options?: MetricOptions): ValueRecorder { + return NOOP_VALUE_RECORDER_METRIC; } /** @@ -103,8 +103,8 @@ export class NoopCounterMetric extends NoopMetric } } -export class NoopMeasureMetric extends NoopMetric - implements Measure { +export class NoopValueRecorderMetric extends NoopMetric + implements ValueRecorder { record( value: number, labels: Labels, @@ -131,7 +131,7 @@ export class NoopBoundCounter implements BoundCounter { } } -export class NoopBoundMeasure implements BoundMeasure { +export class NoopBoundValueRecorder implements BoundValueRecorder { record( value: number, correlationContext?: CorrelationContext, @@ -145,7 +145,9 @@ export const NOOP_METER = new NoopMeter(); export const NOOP_BOUND_COUNTER = new NoopBoundCounter(); export const NOOP_COUNTER_METRIC = new NoopCounterMetric(NOOP_BOUND_COUNTER); -export const NOOP_BOUND_MEASURE = new NoopBoundMeasure(); -export const NOOP_MEASURE_METRIC = new NoopMeasureMetric(NOOP_BOUND_MEASURE); +export const NOOP_BOUND_VALUE_RECORDER = new NoopBoundValueRecorder(); +export const NOOP_VALUE_RECORDER_METRIC = new NoopValueRecorderMetric( + NOOP_BOUND_VALUE_RECORDER +); export const NOOP_OBSERVER_METRIC = new NoopObserverMetric(); diff --git a/api/test/noop-implementations/noop-meter.test.ts b/api/test/noop-implementations/noop-meter.test.ts index 7b86f5d59d..8738708eba 100644 --- a/api/test/noop-implementations/noop-meter.test.ts +++ b/api/test/noop-implementations/noop-meter.test.ts @@ -18,9 +18,9 @@ import * as assert from 'assert'; import { NoopMeterProvider, NOOP_BOUND_COUNTER, - NOOP_BOUND_MEASURE, + NOOP_BOUND_VALUE_RECORDER, NOOP_COUNTER_METRIC, - NOOP_MEASURE_METRIC, + NOOP_VALUE_RECORDER_METRIC, } from '../../src'; describe('NoopMeter', () => { @@ -38,20 +38,23 @@ describe('NoopMeter', () => { assert.strictEqual(counter.bind(labels), NOOP_BOUND_COUNTER); counter.clear(); - const measure = meter.createMeasure('some-name'); - measure.bind(labels).record(1); + const valueRecorder = meter.createValueRecorder('some-name'); + valueRecorder.bind(labels).record(1); // ensure the correct noop const is returned - assert.strictEqual(measure, NOOP_MEASURE_METRIC); - assert.strictEqual(measure.bind(labels), NOOP_BOUND_MEASURE); + assert.strictEqual(valueRecorder, NOOP_VALUE_RECORDER_METRIC); + assert.strictEqual(valueRecorder.bind(labels), NOOP_BOUND_VALUE_RECORDER); const options = { component: 'tests', description: 'the testing package', }; - const measureWithOptions = meter.createMeasure('some-name', options); - assert.strictEqual(measureWithOptions, NOOP_MEASURE_METRIC); + const valueRecorderWithOptions = meter.createValueRecorder( + 'some-name', + options + ); + assert.strictEqual(valueRecorderWithOptions, NOOP_VALUE_RECORDER_METRIC); const counterWithOptions = meter.createCounter('some-name', options); assert.strictEqual(counterWithOptions, NOOP_COUNTER_METRIC); });