Skip to content

Commit 3fd1b1e

Browse files
feat(sdk-metrics-base): update exporting names (#2829)
Co-authored-by: Valentin Marchaud <[email protected]>
1 parent 70dc60b commit 3fd1b1e

22 files changed

+305
-301
lines changed

experimental/packages/opentelemetry-sdk-metrics-base/src/Instruments.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class SyncInstrument {
4040
/**
4141
* The class implements {@link metrics.UpDownCounter} interface.
4242
*/
43-
export class UpDownCounter extends SyncInstrument implements metrics.UpDownCounter {
43+
export class UpDownCounterInstrument extends SyncInstrument implements metrics.UpDownCounter {
4444
/**
4545
* Increment value of counter by the input. Inputs may be negative.
4646
*/
@@ -52,7 +52,7 @@ export class UpDownCounter extends SyncInstrument implements metrics.UpDownCount
5252
/**
5353
* The class implements {@link metrics.Counter} interface.
5454
*/
55-
export class Counter extends SyncInstrument implements metrics.Counter {
55+
export class CounterInstrument extends SyncInstrument implements metrics.Counter {
5656
/**
5757
* Increment value of counter by the input. Inputs may not be negative.
5858
*/
@@ -69,7 +69,7 @@ export class Counter extends SyncInstrument implements metrics.Counter {
6969
/**
7070
* The class implements {@link metrics.Histogram} interface.
7171
*/
72-
export class Histogram extends SyncInstrument implements metrics.Histogram {
72+
export class HistogramInstrument extends SyncInstrument implements metrics.Histogram {
7373
/**
7474
* Records a measurement. Value of the measurement must not be negative.
7575
*/

experimental/packages/opentelemetry-sdk-metrics-base/src/Meter.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import * as metrics from '@opentelemetry/api-metrics-wip';
1818
import { InstrumentationLibrary } from '@opentelemetry/core';
1919
import { createInstrumentDescriptor, InstrumentDescriptor, InstrumentType } from './InstrumentDescriptor';
20-
import { Counter, Histogram, UpDownCounter } from './Instruments';
20+
import { CounterInstrument, HistogramInstrument, UpDownCounterInstrument } from './Instruments';
2121
import { MeterProviderSharedState } from './state/MeterProviderSharedState';
2222
import { MultiMetricStorage } from './state/MultiWritableMetricStorage';
2323
import { SyncMetricStorage } from './state/SyncMetricStorage';
@@ -45,7 +45,7 @@ export class Meter implements metrics.Meter {
4545
createHistogram(name: string, options?: metrics.HistogramOptions): metrics.Histogram {
4646
const descriptor = createInstrumentDescriptor(name, InstrumentType.HISTOGRAM, options);
4747
const storage = this._registerMetricStorage(descriptor);
48-
return new Histogram(storage, descriptor);
48+
return new HistogramInstrument(storage, descriptor);
4949
}
5050

5151
/**
@@ -54,7 +54,7 @@ export class Meter implements metrics.Meter {
5454
createCounter(name: string, options?: metrics.CounterOptions): metrics.Counter {
5555
const descriptor = createInstrumentDescriptor(name, InstrumentType.COUNTER, options);
5656
const storage = this._registerMetricStorage(descriptor);
57-
return new Counter(storage, descriptor);
57+
return new CounterInstrument(storage, descriptor);
5858
}
5959

6060
/**
@@ -63,7 +63,7 @@ export class Meter implements metrics.Meter {
6363
createUpDownCounter(name: string, options?: metrics.UpDownCounterOptions): metrics.UpDownCounter {
6464
const descriptor = createInstrumentDescriptor(name, InstrumentType.UP_DOWN_COUNTER, options);
6565
const storage = this._registerMetricStorage(descriptor);
66-
return new UpDownCounter(storage, descriptor);
66+
return new UpDownCounterInstrument(storage, descriptor);
6767
}
6868

6969
/**

experimental/packages/opentelemetry-sdk-metrics-base/src/aggregator/Drop.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class DropAggregator implements Aggregator<undefined> {
4141
}
4242

4343
toMetricData(
44-
_instrumentDescriptor: InstrumentDescriptor,
44+
_descriptor: InstrumentDescriptor,
4545
_accumulationByAttributes: AccumulationRecord<undefined>[],
4646
_startTime: HrTime,
4747
_endTime: HrTime): Maybe<MetricData> {

experimental/packages/opentelemetry-sdk-metrics-base/src/aggregator/Histogram.ts

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
AggregatorKind,
2222
Histogram,
2323
} from './types';
24-
import { HistogramMetricData, PointDataType } from '../export/MetricData';
24+
import { HistogramMetricData, DataPointType } from '../export/MetricData';
2525
import { HrTime } from '@opentelemetry/api';
2626
import { InstrumentDescriptor } from '../InstrumentDescriptor';
2727
import { Maybe } from '../utils';
@@ -57,7 +57,7 @@ export class HistogramAccumulation implements Accumulation {
5757
this._current.buckets.counts[this._boundaries.length] += 1;
5858
}
5959

60-
toPoint(): Histogram {
60+
toPointValue(): Histogram {
6161
return this._current;
6262
}
6363
}
@@ -89,66 +89,66 @@ export class HistogramAggregator implements Aggregator<HistogramAccumulation> {
8989
* merging accumulations with different boundaries.
9090
*/
9191
merge(previous: HistogramAccumulation, delta: HistogramAccumulation): HistogramAccumulation {
92-
const previousPoint = previous.toPoint();
93-
const deltaPoint = delta.toPoint();
92+
const previousValue = previous.toPointValue();
93+
const deltaValue = delta.toPointValue();
9494

95-
const previousCounts = previousPoint.buckets.counts;
96-
const deltaCounts = deltaPoint.buckets.counts;
95+
const previousCounts = previousValue.buckets.counts;
96+
const deltaCounts = deltaValue.buckets.counts;
9797

9898
const mergedCounts = new Array(previousCounts.length);
9999
for (let idx = 0; idx < previousCounts.length; idx++) {
100100
mergedCounts[idx] = previousCounts[idx] + deltaCounts[idx];
101101
}
102102

103-
return new HistogramAccumulation(previousPoint.buckets.boundaries, {
103+
return new HistogramAccumulation(previousValue.buckets.boundaries, {
104104
buckets: {
105-
boundaries: previousPoint.buckets.boundaries,
105+
boundaries: previousValue.buckets.boundaries,
106106
counts: mergedCounts,
107107
},
108-
count: previousPoint.count + deltaPoint.count,
109-
sum: previousPoint.sum + deltaPoint.sum,
108+
count: previousValue.count + deltaValue.count,
109+
sum: previousValue.sum + deltaValue.sum,
110110
});
111111
}
112112

113113
/**
114114
* Returns a new DELTA aggregation by comparing two cumulative measurements.
115115
*/
116116
diff(previous: HistogramAccumulation, current: HistogramAccumulation): HistogramAccumulation {
117-
const previousPoint = previous.toPoint();
118-
const currentPoint = current.toPoint();
117+
const previousValue = previous.toPointValue();
118+
const currentValue = current.toPointValue();
119119

120-
const previousCounts = previousPoint.buckets.counts;
121-
const currentCounts = currentPoint.buckets.counts;
120+
const previousCounts = previousValue.buckets.counts;
121+
const currentCounts = currentValue.buckets.counts;
122122

123123
const diffedCounts = new Array(previousCounts.length);
124124
for (let idx = 0; idx < previousCounts.length; idx++) {
125125
diffedCounts[idx] = currentCounts[idx] - previousCounts[idx];
126126
}
127127

128-
return new HistogramAccumulation(previousPoint.buckets.boundaries, {
128+
return new HistogramAccumulation(previousValue.buckets.boundaries, {
129129
buckets: {
130-
boundaries: previousPoint.buckets.boundaries,
130+
boundaries: previousValue.buckets.boundaries,
131131
counts: diffedCounts,
132132
},
133-
count: currentPoint.count - previousPoint.count,
134-
sum: currentPoint.sum - previousPoint.sum,
133+
count: currentValue.count - previousValue.count,
134+
sum: currentValue.sum - previousValue.sum,
135135
});
136136
}
137137

138138
toMetricData(
139-
metricDescriptor: InstrumentDescriptor,
139+
descriptor: InstrumentDescriptor,
140140
accumulationByAttributes: AccumulationRecord<HistogramAccumulation>[],
141141
startTime: HrTime,
142142
endTime: HrTime): Maybe<HistogramMetricData> {
143143
return {
144-
instrumentDescriptor: metricDescriptor,
145-
pointDataType: PointDataType.HISTOGRAM,
146-
pointData: accumulationByAttributes.map(([attributes, accumulation]) => {
144+
descriptor,
145+
dataPointType: DataPointType.HISTOGRAM,
146+
dataPoints: accumulationByAttributes.map(([attributes, accumulation]) => {
147147
return {
148148
attributes,
149149
startTime,
150150
endTime,
151-
point: accumulation.toPoint(),
151+
value: accumulation.toPointValue(),
152152
};
153153
})
154154
};

experimental/packages/opentelemetry-sdk-metrics-base/src/aggregator/LastValue.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import { LastValue, AggregatorKind, Aggregator, Accumulation, AccumulationRecord } from './types';
1818
import { HrTime } from '@opentelemetry/api';
1919
import { hrTime, hrTimeToMicroseconds } from '@opentelemetry/core';
20-
import { PointDataType, SingularMetricData } from '../export/MetricData';
20+
import { DataPointType, SingularMetricData } from '../export/MetricData';
2121
import { InstrumentDescriptor } from '../InstrumentDescriptor';
2222
import { Maybe } from '../utils';
2323

@@ -29,7 +29,7 @@ export class LastValueAccumulation implements Accumulation {
2929
this.sampleTime = hrTime();
3030
}
3131

32-
toPoint(): LastValue {
32+
toPointValue(): LastValue {
3333
return this._current;
3434
}
3535
}
@@ -50,7 +50,7 @@ export class LastValueAggregator implements Aggregator<LastValueAccumulation> {
5050
merge(previous: LastValueAccumulation, delta: LastValueAccumulation): LastValueAccumulation {
5151
// nanoseconds may lose precisions.
5252
const latestAccumulation = hrTimeToMicroseconds(delta.sampleTime) >= hrTimeToMicroseconds(previous.sampleTime) ? delta : previous;
53-
return new LastValueAccumulation(latestAccumulation.toPoint(), latestAccumulation.sampleTime);
53+
return new LastValueAccumulation(latestAccumulation.toPointValue(), latestAccumulation.sampleTime);
5454
}
5555

5656
/**
@@ -62,23 +62,23 @@ export class LastValueAggregator implements Aggregator<LastValueAccumulation> {
6262
diff(previous: LastValueAccumulation, current: LastValueAccumulation): LastValueAccumulation {
6363
// nanoseconds may lose precisions.
6464
const latestAccumulation = hrTimeToMicroseconds(current.sampleTime) >= hrTimeToMicroseconds(previous.sampleTime) ? current : previous;
65-
return new LastValueAccumulation(latestAccumulation.toPoint(), latestAccumulation.sampleTime);
65+
return new LastValueAccumulation(latestAccumulation.toPointValue(), latestAccumulation.sampleTime);
6666
}
6767

6868
toMetricData(
69-
instrumentDescriptor: InstrumentDescriptor,
69+
descriptor: InstrumentDescriptor,
7070
accumulationByAttributes: AccumulationRecord<LastValueAccumulation>[],
7171
startTime: HrTime,
7272
endTime: HrTime): Maybe<SingularMetricData> {
7373
return {
74-
instrumentDescriptor,
75-
pointDataType: PointDataType.SINGULAR,
76-
pointData: accumulationByAttributes.map(([attributes, accumulation]) => {
74+
descriptor,
75+
dataPointType: DataPointType.SINGULAR,
76+
dataPoints: accumulationByAttributes.map(([attributes, accumulation]) => {
7777
return {
7878
attributes,
7979
startTime,
8080
endTime,
81-
point: accumulation.toPoint(),
81+
value: accumulation.toPointValue(),
8282
};
8383
})
8484
};

experimental/packages/opentelemetry-sdk-metrics-base/src/aggregator/Sum.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import { Sum, AggregatorKind, Aggregator, Accumulation, AccumulationRecord } from './types';
1818
import { HrTime } from '@opentelemetry/api';
19-
import { PointDataType, SingularMetricData } from '../export/MetricData';
19+
import { DataPointType, SingularMetricData } from '../export/MetricData';
2020
import { InstrumentDescriptor } from '../InstrumentDescriptor';
2121
import { Maybe } from '../utils';
2222

@@ -27,7 +27,7 @@ export class SumAccumulation implements Accumulation {
2727
this._current += value;
2828
}
2929

30-
toPoint(): Sum {
30+
toPointValue(): Sum {
3131
return this._current;
3232
}
3333
}
@@ -44,30 +44,30 @@ export class SumAggregator implements Aggregator<SumAccumulation> {
4444
* Returns the result of the merge of the given accumulations.
4545
*/
4646
merge(previous: SumAccumulation, delta: SumAccumulation): SumAccumulation {
47-
return new SumAccumulation(previous.toPoint() + delta.toPoint());
47+
return new SumAccumulation(previous.toPointValue() + delta.toPointValue());
4848
}
4949

5050
/**
5151
* Returns a new DELTA aggregation by comparing two cumulative measurements.
5252
*/
5353
diff(previous: SumAccumulation, current: SumAccumulation): SumAccumulation {
54-
return new SumAccumulation(current.toPoint() - previous.toPoint());
54+
return new SumAccumulation(current.toPointValue() - previous.toPointValue());
5555
}
5656

5757
toMetricData(
58-
instrumentDescriptor: InstrumentDescriptor,
58+
descriptor: InstrumentDescriptor,
5959
accumulationByAttributes: AccumulationRecord<SumAccumulation>[],
6060
startTime: HrTime,
6161
endTime: HrTime): Maybe<SingularMetricData> {
6262
return {
63-
instrumentDescriptor,
64-
pointDataType: PointDataType.SINGULAR,
65-
pointData: accumulationByAttributes.map(([attributes, accumulation]) => {
63+
descriptor,
64+
dataPointType: DataPointType.SINGULAR,
65+
dataPoints: accumulationByAttributes.map(([attributes, accumulation]) => {
6666
return {
6767
attributes,
6868
startTime,
6969
endTime,
70-
point: accumulation.toPoint(),
70+
value: accumulation.toPointValue(),
7171
};
7272
})
7373
};

experimental/packages/opentelemetry-sdk-metrics-base/src/aggregator/types.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ export enum AggregatorKind {
2828
HISTOGRAM,
2929
}
3030

31-
/** Point type for SumAggregation. */
31+
/** DataPoint value type for SumAggregation. */
3232
export type Sum = number;
3333

34-
/** Point type for LastValueAggregation. */
34+
/** DataPoint value type for LastValueAggregation. */
3535
export type LastValue = number;
3636

37-
/** Point type for HistogramAggregation. */
37+
/** DataPoint value type for HistogramAggregation. */
3838
export interface Histogram {
3939
/**
4040
* Buckets are implemented using two different arrays:
@@ -106,15 +106,13 @@ export interface Aggregator<T> {
106106
/**
107107
* Returns the {@link MetricData} that this {@link Aggregator} will produce.
108108
*
109-
* @param resource the resource producing the metric.
110-
* @param instrumentationLibrary the library that instrumented the metric
111-
* @param instrumentDescriptor the metric instrument descriptor.
109+
* @param descriptor the metric instrument descriptor.
112110
* @param accumulationByAttributes the array of attributes and accumulation pairs.
113111
* @param startTime the start time of the metric data.
114112
* @param endTime the end time of the metric data.
115113
* @return the {@link MetricData} that this {@link Aggregator} will produce.
116114
*/
117-
toMetricData(instrumentDescriptor: InstrumentDescriptor,
115+
toMetricData(descriptor: InstrumentDescriptor,
118116
accumulationByAttributes: AccumulationRecord<T>[],
119117
startTime: HrTime,
120118
endTime: HrTime): Maybe<MetricData>;

experimental/packages/opentelemetry-sdk-metrics-base/src/export/MetricData.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,28 @@ import { Histogram } from '../aggregator/types';
2525
* Basic metric data fields.
2626
*/
2727
export interface BaseMetricData {
28-
readonly instrumentDescriptor: InstrumentDescriptor;
28+
readonly descriptor: InstrumentDescriptor;
2929
/**
30-
* PointDataType of the metric instrument.
30+
* DataPointType of the metric instrument.
3131
*/
32-
readonly pointDataType: PointDataType;
32+
readonly dataPointType: DataPointType;
3333
}
3434

3535
/**
3636
* Represents a metric data aggregated by either a LastValueAggregation or
3737
* SumAggregation.
3838
*/
3939
export interface SingularMetricData extends BaseMetricData {
40-
readonly pointDataType: PointDataType.SINGULAR;
41-
readonly pointData: PointData<number>[];
40+
readonly dataPointType: DataPointType.SINGULAR;
41+
readonly dataPoints: DataPoint<number>[];
4242
}
4343

4444
/**
4545
* Represents a metric data aggregated by a HistogramAggregation.
4646
*/
4747
export interface HistogramMetricData extends BaseMetricData {
48-
readonly pointDataType: PointDataType.HISTOGRAM;
49-
readonly pointData: PointData<Histogram>[];
48+
readonly dataPointType: DataPointType.HISTOGRAM;
49+
readonly dataPoints: DataPoint<Histogram>[];
5050
}
5151

5252
/**
@@ -67,7 +67,7 @@ export interface ResourceMetrics {
6767
/**
6868
* The aggregated point data type.
6969
*/
70-
export enum PointDataType {
70+
export enum DataPointType {
7171
SINGULAR,
7272
HISTOGRAM,
7373
EXPONENTIAL_HISTOGRAM,
@@ -77,9 +77,9 @@ export enum PointDataType {
7777
* Represents an aggregated point data with start time, end time and their
7878
* associated attributes and points.
7979
*/
80-
export interface PointData<T> {
80+
export interface DataPoint<T> {
8181
/**
82-
* The start epoch timestamp of the PointData, usually the time when
82+
* The start epoch timestamp of the DataPoint, usually the time when
8383
* the metric was created when the preferred AggregationTemporality is
8484
* CUMULATIVE, or last collection time otherwise.
8585
*/
@@ -90,11 +90,11 @@ export interface PointData<T> {
9090
*/
9191
readonly endTime: HrTime;
9292
/**
93-
* The attributes associated with this PointData.
93+
* The attributes associated with this DataPoint.
9494
*/
9595
readonly attributes: Attributes;
9696
/**
97-
* The data points for this metric.
97+
* The value for this DataPoint.
9898
*/
99-
readonly point: T;
99+
readonly value: T;
100100
}

0 commit comments

Comments
 (0)