Skip to content
Prev Previous commit
Next Next commit
fixup! rename observables
  • Loading branch information
legendecas committed Oct 6, 2021
commit 8d882227a4669eb5114bc66105822df682cbc0d9
2 changes: 1 addition & 1 deletion doc/processor-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ const meter = new MeterProvider({
interval: 1000,
}).getMeter('example-custom-processor');

const requestsLatency = meter.createValueRecorder('requests', {
const requestsLatency = meter.createHistogram('requests', {
monotonic: true,
description: 'Average latency'
});
Expand Down
6 changes: 3 additions & 3 deletions examples/metrics/metrics/observer.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const meter = new MeterProvider({
interval: 2000,
}).getMeter('example-observer');

meter.createValueObserver('cpu_core_usage', {
meter.createObservableGauge('cpu_core_usage', {
description: 'Example of a sync value observer with callback',
}, async (observerResult) => { // this callback is called once per each interval
await new Promise((resolve) => {
Expand All @@ -34,12 +34,12 @@ meter.createValueObserver('cpu_core_usage', {
});

// no callback as they will be updated in batch observer
const tempMetric = meter.createValueObserver('cpu_temp_per_app', {
const tempMetric = meter.createObservableGauge('cpu_temp_per_app', {
description: 'Example of sync value observer used with async batch observer',
});

// no callback as they will be updated in batch observer
const cpuUsageMetric = meter.createValueObserver('cpu_usage_per_app', {
const cpuUsageMetric = meter.createObservableGauge('cpu_usage_per_app', {
description: 'Example of sync value observer used with async batch observer',
});

Expand Down
4 changes: 2 additions & 2 deletions examples/otlp-exporter-node/metrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ const upDownCounter = meter.createUpDownCounter('test_up_down_counter', {
description: 'Example of a UpDownCounter',
});

const recorder = meter.createValueRecorder('test_value_recorder', {
description: 'Example of a ValueRecorder',
const recorder = meter.createHistogram('test_histogram', {
description: 'Example of a Histogram',
});

const labels = { pid: process.pid, environment: 'staging' };
Expand Down
58 changes: 29 additions & 29 deletions experimental/packages/opentelemetry-api-metrics/src/NoopMeter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ import {
Labels,
Counter,
Histogram,
GaugeObserver,
ObservableGauge,
UpDownCounter,
BaseObserver,
CounterObserver,
UpDownCounterObserver,
BaseObservable,
ObservableCounter,
ObservableUpDownCounter,
} from './types/Metric';
import {
BoundHistogram,
BoundCounter,
BoundBaseObserver,
BoundBaseObservable,
} from './types/BoundInstrument';
import { ObserverResult } from './types/ObserverResult';
import { Observation } from './types/Observation';
Expand All @@ -53,17 +53,17 @@ export class NoopMeter implements Meter {
}

/**
* Returns constant noop counter observer.
* Returns constant noop observable counter.
* @param name the name of the metric.
* @param [options] the metric options.
* @param [callback] the counter observer callback
* @param [callback] the observable counter callback
*/
createCounterObserver(
createObservableCounter(
_name: string,
_options?: MetricOptions,
_callback?: (observerResult: ObserverResult) => void
): CounterObserver {
return NOOP_COUNTER_OBSERVER_METRIC;
): ObservableCounter {
return NOOP_OBSERVABLE_COUNTER_METRIC;
}

/**
Expand All @@ -76,17 +76,17 @@ export class NoopMeter implements Meter {
}

/**
* Returns constant noop gauge observer.
* Returns constant noop observable gauge.
* @param name the name of the metric.
* @param [options] the metric options.
* @param [callback] the gauge observer callback
* @param [callback] the observable gauge callback
*/
createGaugeObserver(
createObservableGauge(
_name: string,
_options?: MetricOptions,
_callback?: (observerResult: ObserverResult) => void
): GaugeObserver {
return NOOP_GAUGE_OBSERVER_METRIC;
): ObservableGauge {
return NOOP_OBSERVABLE_GAUGE_METRIC;
}

/**
Expand All @@ -99,17 +99,17 @@ export class NoopMeter implements Meter {
}

/**
* Returns constant noop up down counter observer.
* Returns constant noop up down observable counter.
* @param name the name of the metric.
* @param [options] the metric options.
* @param [callback] the up down counter observer callback
* @param [callback] the up down observable counter callback
*/
createUpDownCounterObserver(
createObservableUpDownCounter(
_name: string,
_options?: MetricOptions,
_callback?: (observerResult: ObserverResult) => void
): UpDownCounterObserver {
return NOOP_UP_DOWN_COUNTER_OBSERVER_METRIC;
): ObservableUpDownCounter {
return NOOP_OBSERVABLE_UP_DOWN_COUNTER_METRIC;
}

/**
Expand Down Expand Up @@ -174,12 +174,12 @@ export class NoopHistogramMetric
}
}

export class NoopBaseObserverMetric
extends NoopMetric<BoundBaseObserver>
implements BaseObserver {
export class NoopBaseObservableMetric
extends NoopMetric<BoundBaseObservable>
implements BaseObservable {
observation(): Observation {
return {
observer: this as BaseObserver,
observer: this as BaseObservable,
value: 0,
};
}
Expand All @@ -199,7 +199,7 @@ export class NoopBoundHistogram implements BoundHistogram {
}
}

export class NoopBoundBaseObserver implements BoundBaseObserver {
export class NoopBoundBaseObservable implements BoundBaseObservable {
update(_value: number): void {}
}

Expand All @@ -212,16 +212,16 @@ export const NOOP_HISTOGRAM_METRIC = new NoopHistogramMetric(
NOOP_BOUND_HISTOGRAM
);

export const NOOP_BOUND_BASE_OBSERVER = new NoopBoundBaseObserver();
export const NOOP_GAUGE_OBSERVER_METRIC = new NoopBaseObserverMetric(
export const NOOP_BOUND_BASE_OBSERVER = new NoopBoundBaseObservable();
export const NOOP_OBSERVABLE_GAUGE_METRIC = new NoopBaseObservableMetric(
NOOP_BOUND_BASE_OBSERVER
);

export const NOOP_UP_DOWN_COUNTER_OBSERVER_METRIC = new NoopBaseObserverMetric(
export const NOOP_OBSERVABLE_UP_DOWN_COUNTER_METRIC = new NoopBaseObservableMetric(
NOOP_BOUND_BASE_OBSERVER
);

export const NOOP_COUNTER_OBSERVER_METRIC = new NoopBaseObserverMetric(
export const NOOP_OBSERVABLE_COUNTER_METRIC = new NoopBaseObservableMetric(
NOOP_BOUND_BASE_OBSERVER
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export interface BoundHistogram {
record(value: number): void;
}

/** An Instrument for Base Observer */
export interface BoundBaseObserver {
/** An Instrument for Base Observable */
export interface BoundBaseObservable {
update(value: number): void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ import {
MetricOptions,
Counter,
Histogram,
GaugeObserver,
ObservableGauge,
BatchObserverOptions,
UpDownCounter,
CounterObserver,
UpDownCounterObserver,
ObservableCounter,
ObservableUpDownCounter,
} from './Metric';
import { ObserverResult } from './ObserverResult';

Expand All @@ -45,16 +45,16 @@ export interface Meter {
createCounter(name: string, options?: MetricOptions): Counter;

/**
* Creates a new `CounterObserver` metric.
* Creates a new `ObservableCounter` metric.
* @param name the name of the metric.
* @param [options] the metric options.
* @param [callback] the observer callback
* @param [callback] the observable callback
*/
createCounterObserver(
createObservableCounter(
name: string,
options?: MetricOptions,
callback?: (observerResult: ObserverResult) => void
): CounterObserver;
): ObservableCounter;

/**
* Creates and returns a new `Histogram`.
Expand All @@ -64,16 +64,16 @@ export interface Meter {
createHistogram(name: string, options?: MetricOptions): Histogram;

/**
* Creates a new `GaugeObserver` metric.
* Creates a new `ObservableGauge` metric.
* @param name the name of the metric.
* @param [options] the metric options.
* @param [callback] the observer callback
* @param [callback] the observable callback
*/
createGaugeObserver(
createObservableGauge(
name: string,
options?: MetricOptions,
callback?: (observerResult: ObserverResult) => void
): GaugeObserver;
): ObservableGauge;

/**
* Creates a new `UpDownCounter` metric. UpDownCounter is a synchronous
Expand All @@ -95,16 +95,16 @@ export interface Meter {
createUpDownCounter(name: string, options?: MetricOptions): UpDownCounter;

/**
* Creates a new `UpDownCounterObserver` metric.
* Creates a new `ObservableUpDownCounter` metric.
* @param name the name of the metric.
* @param [options] the metric options.
* @param [callback] the observer callback
* @param [callback] the observable callback
*/
createUpDownCounterObserver(
createObservableUpDownCounter(
name: string,
options?: MetricOptions,
callback?: (observerResult: ObserverResult) => void
): UpDownCounterObserver;
): ObservableUpDownCounter;

/**
* Creates a new `BatchObserver`, can be used to update many metrics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import {
BoundBaseObserver,
BoundBaseObservable,
BoundCounter,
BoundHistogram,
} from './BoundInstrument';
Expand Down Expand Up @@ -154,23 +154,23 @@ export interface Histogram extends UnboundMetric<BoundHistogram> {
}

/** Base interface for the Observer metrics. */
export interface BaseObserver extends UnboundMetric<BoundBaseObserver> {
export interface BaseObservable extends UnboundMetric<BoundBaseObservable> {
observation: (
value: number
) => {
value: number;
observer: BaseObserver;
observer: BaseObservable;
};
}

/** Base interface for the GaugeObserver metrics. */
export type GaugeObserver = BaseObserver;
/** Base interface for the ObservableGauge metrics. */
export type ObservableGauge = BaseObservable;

/** Base interface for the UpDownCounterObserver metrics. */
export type UpDownCounterObserver = BaseObserver;
/** Base interface for the ObservableUpDownCounter metrics. */
export type ObservableUpDownCounter = BaseObservable;

/** Base interface for the CounterObserver metrics. */
export type CounterObserver = BaseObserver;
/** Base interface for the ObservableCounter metrics. */
export type ObservableCounter = BaseObservable;

/**
* key-value pairs passed by the user.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
* limitations under the License.
*/

import { BaseObserver } from './Metric';
import { BaseObservable } from './Metric';

/**
* Interface for updating value of certain observer
* Interface for updating value of certain observable
*/
export interface Observation {
observer: BaseObserver;
observer: BaseObservable;
value: number;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import { Labels } from './Metric';

/**
* Interface that is being used in callback function for Observer Metric
* Interface that is being used in callback function for Observable Metric
*/
export interface ObserverResult {
observe(value: number, labels: Labels): void;
Expand Down
Loading