Skip to content

Commit 7fe78c9

Browse files
authored
Merge branch 'main' into remove-old-getting-started
2 parents 7ac5854 + 043067f commit 7fe78c9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1058
-1020
lines changed

README.md

+23
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,29 @@ To request automatic tracing support for a module not on this list, please [file
286286

287287
## Upgrade guidelines
288288

289+
### 0.26.x to 0.27.x
290+
291+
Metric types are renamed:
292+
293+
- `@openetelemetry/api-metrics`
294+
- `Meter`
295+
- `createValueRecorder` => `createHistogram`
296+
- `createValueObserver` => `createObservableGauge`
297+
- `createSumObserver` => `createObservableCounter`
298+
- `createUpDownSumObserver` => `createObservableUpDownCounter`
299+
- `ValueRecorder` => `Histogram`
300+
- `ValueObserver` => `ObservableGauge`
301+
- `SumObserver` => `ObservableCounter`
302+
- `UpDownSumObserver` => `ObservableUpDownCounter`
303+
- `ObserverResult` => `ObservableResult`
304+
- `Observation.observer` => `Observation.observable`
305+
- `@opentelemetry/sdk-metrics-base`
306+
- `MetricKind`
307+
- `VALUE_RECORDER` => `HISTOGRAM`
308+
- `SUM_OBSERVER` => `OBSERVABLE_COUNTER`
309+
- `UP_DOWN_SUM_OBSERVER` => `OBSERVABLE_UP_DOWN_COUNTER`
310+
- `VALUE_OBSERVER` => `OBSERVABLE_GAUGE`
311+
289312
### 0.25.x to 1.x.y
290313

291314
Collector exporter packages and types are renamed:

doc/processor-api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ const meter = new MeterProvider({
138138
interval: 1000,
139139
}).getMeter('example-custom-processor');
140140

141-
const requestsLatency = meter.createValueRecorder('requests', {
141+
const requestsLatency = meter.createHistogram('requests', {
142142
monotonic: true,
143143
description: 'Average latency'
144144
});

examples/metrics/metrics/observer.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,29 @@ const exporter = new PrometheusExporter(
2121
const meter = new MeterProvider({
2222
exporter,
2323
interval: 2000,
24-
}).getMeter('example-observer');
24+
}).getMeter('example-meter');
2525

26-
meter.createValueObserver('cpu_core_usage', {
27-
description: 'Example of a sync value observer with callback',
28-
}, async (observerResult) => { // this callback is called once per each interval
26+
meter.createObservableGauge('cpu_core_usage', {
27+
description: 'Example of a sync observable gauge with callback',
28+
}, async (observableResult) => { // this callback is called once per each interval
2929
await new Promise((resolve) => {
3030
setTimeout(()=> {resolve()}, 50);
3131
});
32-
observerResult.observe(getRandomValue(), { core: '1' });
33-
observerResult.observe(getRandomValue(), { core: '2' });
32+
observableResult.observe(getRandomValue(), { core: '1' });
33+
observableResult.observe(getRandomValue(), { core: '2' });
3434
});
3535

3636
// no callback as they will be updated in batch observer
37-
const tempMetric = meter.createValueObserver('cpu_temp_per_app', {
38-
description: 'Example of sync value observer used with async batch observer',
37+
const tempMetric = meter.createObservableGauge('cpu_temp_per_app', {
38+
description: 'Example of sync observable gauge used with async batch observer',
3939
});
4040

4141
// no callback as they will be updated in batch observer
42-
const cpuUsageMetric = meter.createValueObserver('cpu_usage_per_app', {
43-
description: 'Example of sync value observer used with async batch observer',
42+
const cpuUsageMetric = meter.createObservableGauge('cpu_usage_per_app', {
43+
description: 'Example of sync observable gauge used with async batch observer',
4444
});
4545

46-
meter.createBatchObserver((observerBatchResult) => {
46+
meter.createBatchObserver((batchObserverResult) => {
4747
Promise.all([
4848
someAsyncMetrics(),
4949
// simulate waiting
@@ -52,11 +52,11 @@ meter.createBatchObserver((observerBatchResult) => {
5252
}),
5353
]).then(([apps, waiting]) => {
5454
apps.forEach(app => {
55-
observerBatchResult.observe({ app: app.name, core: '1' }, [
55+
batchObserverResult.observe({ app: app.name, core: '1' }, [
5656
tempMetric.observation(app.core1.temp),
5757
cpuUsageMetric.observation(app.core1.usage),
5858
]);
59-
observerBatchResult.observe({ app: app.name, core: '2' }, [
59+
batchObserverResult.observe({ app: app.name, core: '2' }, [
6060
tempMetric.observation(app.core2.temp),
6161
cpuUsageMetric.observation(app.core2.usage),
6262
]);

examples/otlp-exporter-node/metrics.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ const upDownCounter = meter.createUpDownCounter('test_up_down_counter', {
3131
description: 'Example of a UpDownCounter',
3232
});
3333

34-
const recorder = meter.createValueRecorder('test_value_recorder', {
35-
description: 'Example of a ValueRecorder',
34+
const histogram = meter.createHistogram('test_histogram', {
35+
description: 'Example of a Histogram',
3636
});
3737

3838
const labels = { pid: process.pid, environment: 'staging' };
3939

4040
setInterval(() => {
4141
requestCounter.bind(labels).add(1);
4242
upDownCounter.bind(labels).add(Math.random() > 0.5 ? 1 : -1);
43-
recorder.bind(labels).record(Math.random());
43+
histogram.bind(labels).record(Math.random());
4444
}, 1000);

experimental/packages/opentelemetry-api-metrics/src/NoopMeter.ts

+48-47
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,19 @@ import {
2121
UnboundMetric,
2222
Labels,
2323
Counter,
24-
ValueRecorder,
25-
ValueObserver,
24+
Histogram,
25+
ObservableGauge,
2626
UpDownCounter,
27-
BaseObserver,
28-
UpDownSumObserver,
27+
ObservableBase,
28+
ObservableCounter,
29+
ObservableUpDownCounter,
2930
} from './types/Metric';
3031
import {
31-
BoundValueRecorder,
32+
BoundHistogram,
3233
BoundCounter,
33-
BoundBaseObserver,
34+
BoundObservableBase,
3435
} from './types/BoundInstrument';
35-
import { ObserverResult } from './types/ObserverResult';
36+
import { ObservableResult } from './types/ObservableResult';
3637
import { Observation } from './types/Observation';
3738

3839
/**
@@ -43,12 +44,12 @@ export class NoopMeter implements Meter {
4344
constructor() {}
4445

4546
/**
46-
* Returns constant noop value recorder.
47+
* Returns a constant noop histogram.
4748
* @param name the name of the metric.
4849
* @param [options] the metric options.
4950
*/
50-
createValueRecorder(_name: string, _options?: MetricOptions): ValueRecorder {
51-
return NOOP_VALUE_RECORDER_METRIC;
51+
createHistogram(_name: string, _options?: MetricOptions): Histogram {
52+
return NOOP_HISTOGRAM_METRIC;
5253
}
5354

5455
/**
@@ -70,45 +71,45 @@ export class NoopMeter implements Meter {
7071
}
7172

7273
/**
73-
* Returns constant noop value observer.
74+
* Returns a constant noop observable gauge.
7475
* @param name the name of the metric.
7576
* @param [options] the metric options.
76-
* @param [callback] the value observer callback
77+
* @param [callback] the observable gauge callback
7778
*/
78-
createValueObserver(
79+
createObservableGauge(
7980
_name: string,
8081
_options?: MetricOptions,
81-
_callback?: (observerResult: ObserverResult) => void
82-
): ValueObserver {
83-
return NOOP_VALUE_OBSERVER_METRIC;
82+
_callback?: (observableResult: ObservableResult) => void
83+
): ObservableGauge {
84+
return NOOP_OBSERVABLE_GAUGE_METRIC;
8485
}
8586

8687
/**
87-
* Returns constant noop sum observer.
88+
* Returns a constant noop observable counter.
8889
* @param name the name of the metric.
8990
* @param [options] the metric options.
90-
* @param [callback] the sum observer callback
91+
* @param [callback] the observable counter callback
9192
*/
92-
createSumObserver(
93+
createObservableCounter(
9394
_name: string,
9495
_options?: MetricOptions,
95-
_callback?: (observerResult: ObserverResult) => void
96-
): ValueObserver {
97-
return NOOP_SUM_OBSERVER_METRIC;
96+
_callback?: (observableResult: ObservableResult) => void
97+
): ObservableCounter {
98+
return NOOP_OBSERVABLE_COUNTER_METRIC;
9899
}
99100

100101
/**
101-
* Returns constant noop up down sum observer.
102+
* Returns a constant noop up down observable counter.
102103
* @param name the name of the metric.
103104
* @param [options] the metric options.
104-
* @param [callback] the up down sum observer callback
105+
* @param [callback] the up down observable counter callback
105106
*/
106-
createUpDownSumObserver(
107+
createObservableUpDownCounter(
107108
_name: string,
108109
_options?: MetricOptions,
109-
_callback?: (observerResult: ObserverResult) => void
110-
): UpDownSumObserver {
111-
return NOOP_UP_DOWN_SUM_OBSERVER_METRIC;
110+
_callback?: (observableResult: ObservableResult) => void
111+
): ObservableUpDownCounter {
112+
return NOOP_OBSERVABLE_UP_DOWN_COUNTER_METRIC;
112113
}
113114

114115
/**
@@ -165,20 +166,20 @@ export class NoopCounterMetric
165166
}
166167
}
167168

168-
export class NoopValueRecorderMetric
169-
extends NoopMetric<BoundValueRecorder>
170-
implements ValueRecorder {
169+
export class NoopHistogramMetric
170+
extends NoopMetric<BoundHistogram>
171+
implements Histogram {
171172
record(value: number, labels: Labels): void {
172173
this.bind(labels).record(value);
173174
}
174175
}
175176

176-
export class NoopBaseObserverMetric
177-
extends NoopMetric<BoundBaseObserver>
178-
implements BaseObserver {
177+
export class NoopObservableBaseMetric
178+
extends NoopMetric<BoundObservableBase>
179+
implements ObservableBase {
179180
observation(): Observation {
180181
return {
181-
observer: this as BaseObserver,
182+
observable: this as ObservableBase,
182183
value: 0,
183184
};
184185
}
@@ -192,36 +193,36 @@ export class NoopBoundCounter implements BoundCounter {
192193
}
193194
}
194195

195-
export class NoopBoundValueRecorder implements BoundValueRecorder {
196+
export class NoopBoundHistogram implements BoundHistogram {
196197
record(_value: number, _baggage?: unknown, _spanContext?: unknown): void {
197198
return;
198199
}
199200
}
200201

201-
export class NoopBoundBaseObserver implements BoundBaseObserver {
202+
export class NoopBoundObservableBase implements BoundObservableBase {
202203
update(_value: number): void {}
203204
}
204205

205206
export const NOOP_METER = new NoopMeter();
206207
export const NOOP_BOUND_COUNTER = new NoopBoundCounter();
207208
export const NOOP_COUNTER_METRIC = new NoopCounterMetric(NOOP_BOUND_COUNTER);
208209

209-
export const NOOP_BOUND_VALUE_RECORDER = new NoopBoundValueRecorder();
210-
export const NOOP_VALUE_RECORDER_METRIC = new NoopValueRecorderMetric(
211-
NOOP_BOUND_VALUE_RECORDER
210+
export const NOOP_BOUND_HISTOGRAM = new NoopBoundHistogram();
211+
export const NOOP_HISTOGRAM_METRIC = new NoopHistogramMetric(
212+
NOOP_BOUND_HISTOGRAM
212213
);
213214

214-
export const NOOP_BOUND_BASE_OBSERVER = new NoopBoundBaseObserver();
215-
export const NOOP_VALUE_OBSERVER_METRIC = new NoopBaseObserverMetric(
216-
NOOP_BOUND_BASE_OBSERVER
215+
export const NOOP_BOUND_OBSERVABLE_BASE = new NoopBoundObservableBase();
216+
export const NOOP_OBSERVABLE_GAUGE_METRIC = new NoopObservableBaseMetric(
217+
NOOP_BOUND_OBSERVABLE_BASE
217218
);
218219

219-
export const NOOP_UP_DOWN_SUM_OBSERVER_METRIC = new NoopBaseObserverMetric(
220-
NOOP_BOUND_BASE_OBSERVER
220+
export const NOOP_OBSERVABLE_UP_DOWN_COUNTER_METRIC = new NoopObservableBaseMetric(
221+
NOOP_BOUND_OBSERVABLE_BASE
221222
);
222223

223-
export const NOOP_SUM_OBSERVER_METRIC = new NoopBaseObserverMetric(
224-
NOOP_BOUND_BASE_OBSERVER
224+
export const NOOP_OBSERVABLE_COUNTER_METRIC = new NoopObservableBaseMetric(
225+
NOOP_BOUND_OBSERVABLE_BASE
225226
);
226227

227228
export const NOOP_BATCH_OBSERVER = new NoopBatchObserver();

experimental/packages/opentelemetry-api-metrics/src/api/global-utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@ export function makeGetter<T>(
5252
* version. If the global API is not compatible with the API package
5353
* attempting to get it, a NOOP API implementation will be returned.
5454
*/
55-
export const API_BACKWARDS_COMPATIBILITY_VERSION = 3;
55+
export const API_BACKWARDS_COMPATIBILITY_VERSION = 4;

experimental/packages/opentelemetry-api-metrics/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export * from './types/Meter';
2222
export * from './types/MeterProvider';
2323
export * from './types/Metric';
2424
export * from './types/Observation';
25-
export * from './types/ObserverResult';
25+
export * from './types/ObservableResult';
2626

2727
import { MetricsAPI } from './api/metrics';
2828
/** Entrypoint for metrics API */

experimental/packages/opentelemetry-api-metrics/src/types/BatchObserverResult.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ import { Labels } from './Metric';
1818
import { Observation } from './Observation';
1919

2020
/**
21-
* Interface that is being used in callback function for Observer Metric
22-
* for batch
21+
* Interface that is being used in callback function for BatchObserver
2322
*/
2423
export interface BatchObserverResult {
2524
/**

experimental/packages/opentelemetry-api-metrics/src/types/BoundInstrument.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@ export interface BoundCounter {
2323
add(value: number): void;
2424
}
2525

26-
/** ValueRecorder to report instantaneous measurement of a value. */
27-
export interface BoundValueRecorder {
26+
/** Histogram to report instantaneous measurement of a value. */
27+
export interface BoundHistogram {
2828
/**
29-
* Records the given value to this value recorder.
29+
* Records the given value to this histogram.
3030
* @param value to record.
3131
*/
3232
record(value: number): void;
3333
}
3434

35-
/** An Instrument for Base Observer */
36-
export interface BoundBaseObserver {
35+
/** An Instrument for Base Observable */
36+
export interface BoundObservableBase {
3737
update(value: number): void;
3838
}

0 commit comments

Comments
 (0)