From aaa9b453c7e2bc71ea9d0f545f3569ffef366fe8 Mon Sep 17 00:00:00 2001 From: legendecas Date: Thu, 20 Jan 2022 11:45:59 +0800 Subject: [PATCH 1/3] feat(sdk-metrics-base): document and export basic APIs --- .../src/InstrumentDescriptor.ts | 13 +++++- .../src/Instruments.ts | 34 +++++++++------ .../src/Meter.ts | 41 ++++++++++++++----- .../src/MeterProvider.ts | 25 ++++++++--- .../src/ObservableResult.ts | 9 ++++ .../src/export/AggregationTemporality.ts | 2 +- .../src/export/MetricData.ts | 32 +++++++++++++++ .../src/index.ts | 11 ++++- .../src/view/Aggregation.ts | 37 +++++++++++++---- .../src/view/InstrumentSelector.ts | 2 +- .../test/util.ts | 4 +- .../test/view/Aggregation.test.ts | 3 +- .../test/view/ViewRegistry.test.ts | 2 +- 13 files changed, 171 insertions(+), 44 deletions(-) diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/src/InstrumentDescriptor.ts b/experimental/packages/opentelemetry-sdk-metrics-base/src/InstrumentDescriptor.ts index 8aa57c9f68d..ecb7543a5a5 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/src/InstrumentDescriptor.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/src/InstrumentDescriptor.ts @@ -15,9 +15,20 @@ */ import { MetricOptions, ValueType } from '@opentelemetry/api-metrics-wip'; -import { InstrumentType } from './Instruments'; import { View } from './view/View'; +/** + * Supported types of metric instruments. + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#instrument + */ + export enum InstrumentType { + COUNTER = 'COUNTER', + HISTOGRAM = 'HISTOGRAM', + UP_DOWN_COUNTER = 'UP_DOWN_COUNTER', + OBSERVABLE_COUNTER = 'OBSERVABLE_COUNTER', + OBSERVABLE_GAUGE = 'OBSERVABLE_GAUGE', + OBSERVABLE_UP_DOWN_COUNTER = 'OBSERVABLE_UP_DOWN_COUNTER', +} export interface InstrumentDescriptor { readonly name: string; diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/src/Instruments.ts b/experimental/packages/opentelemetry-sdk-metrics-base/src/Instruments.ts index decf7047945..309bea68059 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/src/Instruments.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/src/Instruments.ts @@ -19,17 +19,6 @@ import * as metrics from '@opentelemetry/api-metrics-wip'; import { InstrumentDescriptor } from './InstrumentDescriptor'; import { WritableMetricStorage } from './state/WritableMetricStorage'; -// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#instrument - -export enum InstrumentType { - COUNTER = 'COUNTER', - HISTOGRAM = 'HISTOGRAM', - UP_DOWN_COUNTER = 'UP_DOWN_COUNTER', - OBSERVABLE_COUNTER = 'OBSERVABLE_COUNTER', - OBSERVABLE_GAUGE = 'OBSERVABLE_GAUGE', - OBSERVABLE_UP_DOWN_COUNTER = 'OBSERVABLE_UP_DOWN_COUNTER', -} - export class SyncInstrument { constructor(private _writableMetricStorage: WritableMetricStorage, private _descriptor: InstrumentDescriptor) { } @@ -42,13 +31,27 @@ export class SyncInstrument { } } -export class UpDownCounter extends SyncInstrument implements metrics.Counter { +/** + * The class implements {@link metrics.UpDownCounter} interface. + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#updowncounter + */ +export class UpDownCounter extends SyncInstrument implements metrics.UpDownCounter { + /** + * Increment value of counter by the input. Inputs may be negative. + */ add(value: number, attributes?: metrics.Attributes, ctx?: api.Context): void { this.aggregate(value, attributes, ctx); } } +/** + * The class implements {@link metrics.Counter} interface. + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#counter + */ export class Counter extends SyncInstrument implements metrics.Counter { + /** + * Increment value of counter by the input. Inputs may not be negative. + */ add(value: number, attributes?: metrics.Attributes, ctx?: api.Context): void { if (value < 0) { api.diag.warn(`negative value provided to counter ${this.getName()}: ${value}`); @@ -59,7 +62,14 @@ export class Counter extends SyncInstrument implements metrics.Counter { } } +/** + * The class implements {@link metrics.Histogram} interface. + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#histogram + */ export class Histogram extends SyncInstrument implements metrics.Histogram { + /** + * Records a measurement. Value of the measurement must not be negative. + */ record(value: number, attributes?: metrics.Attributes, ctx?: api.Context): void { this.aggregate(value, attributes, ctx); } diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/src/Meter.ts b/experimental/packages/opentelemetry-sdk-metrics-base/src/Meter.ts index 7808db28e26..de09deb3910 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/src/Meter.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/src/Meter.ts @@ -16,8 +16,8 @@ import * as metrics from '@opentelemetry/api-metrics-wip'; import { InstrumentationLibrary } from '@opentelemetry/core'; -import { createInstrumentDescriptor, InstrumentDescriptor } from './InstrumentDescriptor'; -import { Counter, Histogram, InstrumentType, UpDownCounter } from './Instruments'; +import { createInstrumentDescriptor, InstrumentDescriptor, InstrumentType } from './InstrumentDescriptor'; +import { Counter, Histogram, UpDownCounter } from './Instruments'; import { MeterProviderSharedState } from './state/MeterProviderSharedState'; import { MultiMetricStorage } from './state/MultiWritableMetricStorage'; import { SyncMetricStorage } from './state/SyncMetricStorage'; @@ -28,40 +28,47 @@ import { MetricCollectorHandle } from './state/MetricCollector'; import { HrTime } from '@opentelemetry/api'; import { AsyncMetricStorage } from './state/AsyncMetricStorage'; -// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#meter - +/** + * This class implements the {@link metrics.Meter} interface. + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#meter + */ export class Meter implements metrics.Meter { private _metricStorageRegistry = new Map(); - // instrumentation library required by spec to be on meter - // spec requires provider config changes to apply to previously created meters, achieved by holding a reference to the provider constructor(private _meterProviderSharedState: MeterProviderSharedState, private _instrumentationLibrary: InstrumentationLibrary) { this._meterProviderSharedState.meters.push(this); } - /** this exists just to prevent ts errors from unused variables and may be removed */ - getInstrumentationLibrary(): InstrumentationLibrary { - return this._instrumentationLibrary; - } - + /** + * Create a {@link metrics.Histogram} instrument. + */ createHistogram(name: string, options?: metrics.HistogramOptions): metrics.Histogram { const descriptor = createInstrumentDescriptor(name, InstrumentType.HISTOGRAM, options); const storage = this._registerMetricStorage(descriptor); return new Histogram(storage, descriptor); } + /** + * Create a {@link metrics.Counter} instrument. + */ createCounter(name: string, options?: metrics.CounterOptions): metrics.Counter { const descriptor = createInstrumentDescriptor(name, InstrumentType.COUNTER, options); const storage = this._registerMetricStorage(descriptor); return new Counter(storage, descriptor); } + /** + * Create a {@link metrics.UpDownCounter} instrument. + */ createUpDownCounter(name: string, options?: metrics.UpDownCounterOptions): metrics.UpDownCounter { const descriptor = createInstrumentDescriptor(name, InstrumentType.UP_DOWN_COUNTER, options); const storage = this._registerMetricStorage(descriptor); return new UpDownCounter(storage, descriptor); } + /** + * Create a ObservableGauge instrument. + */ createObservableGauge( name: string, callback: metrics.ObservableCallback, @@ -71,6 +78,9 @@ export class Meter implements metrics.Meter { this._registerAsyncMetricStorage(descriptor, callback); } + /** + * Create a ObservableCounter instrument. + */ createObservableCounter( name: string, callback: metrics.ObservableCallback, @@ -80,6 +90,9 @@ export class Meter implements metrics.Meter { this._registerAsyncMetricStorage(descriptor, callback); } + /** + * Create a ObservableUpDownCounter instrument. + */ createObservableUpDownCounter( name: string, callback: metrics.ObservableCallback, @@ -112,6 +125,12 @@ export class Meter implements metrics.Meter { }); } + /** + * @internal + * @param collector opaque handle of {@link MetricCollector} which initiated the collection. + * @param collectionTime the HrTime at which the collection was initiated. + * @returns the list of {@link MetricData} collected. + */ async collect(collector: MetricCollectorHandle, collectionTime: HrTime): Promise { const result = await Promise.all(Array.from(this._metricStorageRegistry.values()).map(metricStorage => { return metricStorage.collect( diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/src/MeterProvider.ts b/experimental/packages/opentelemetry-sdk-metrics-base/src/MeterProvider.ts index d7b30e30814..a72deacf3e8 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/src/MeterProvider.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/src/MeterProvider.ts @@ -25,13 +25,19 @@ import { MeterSelector } from './view/MeterSelector'; import { View } from './view/View'; import { MetricCollector } from './state/MetricCollector'; -// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#meterprovider - -export type MeterProviderOptions = { +/** + * MeterProviderOptions provides an interface for configuring a MeterProvider. + */ +export interface MeterProviderOptions { + /** Resource associated with metric telemetry */ resource?: Resource; -}; +} -export class MeterProvider { +/** + * This class implements the {@link metrics.MeterProvider} interface. + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#meterprovider + */ +export class MeterProvider implements metrics.MeterProvider { private _sharedState: MeterProviderSharedState; private _shutdown = false; @@ -39,6 +45,9 @@ export class MeterProvider { this._sharedState = new MeterProviderSharedState(options?.resource ?? Resource.empty()); } + /** + * Get a meter with the configuration of the MeterProvider. + */ getMeter(name: string, version = '', options: metrics.MeterOptions = {}): metrics.Meter { // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#meter-creation if (this._shutdown) { @@ -49,6 +58,12 @@ export class MeterProvider { return new Meter(this._sharedState, { name, version, schemaUrl: options.schemaUrl }); } + /** + * Register a {@link MetricReader} to the meter provider. After the + * registration, the MetricReader can start metrics collection. + * + * @param metricReader the metric reader to be registered. + */ addMetricReader(metricReader: MetricReader) { const collector = new MetricCollector(this._sharedState, metricReader); metricReader.setMetricProducer(collector); diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/src/ObservableResult.ts b/experimental/packages/opentelemetry-sdk-metrics-base/src/ObservableResult.ts index c10bf7514ed..7ca9f9aea1d 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/src/ObservableResult.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/src/ObservableResult.ts @@ -17,9 +17,18 @@ import * as metrics from '@opentelemetry/api-metrics-wip'; import { AttributeHashMap } from './state/HashMap'; +/** + * The class implements {@link metrics.observableResult} interface. + */ export class ObservableResult implements metrics.ObservableResult { + /** + * @internal + */ buffer = new AttributeHashMap(); + /** + * Observe a measurement of the value associated with the given attributes. + */ observe(value: number, attributes: metrics.Attributes = {}): void { this.buffer.set(attributes, value); } diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/src/export/AggregationTemporality.ts b/experimental/packages/opentelemetry-sdk-metrics-base/src/export/AggregationTemporality.ts index 744d936d012..6ecb2bb9734 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/src/export/AggregationTemporality.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/src/export/AggregationTemporality.ts @@ -17,7 +17,7 @@ /** * AggregationTemporality indicates the way additive quantities are expressed. * - * https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/datamodel.md#temporality + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/datamodel.md#temporality */ export enum AggregationTemporality { DELTA, diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/src/export/MetricData.ts b/experimental/packages/opentelemetry-sdk-metrics-base/src/export/MetricData.ts index d989baa0b7d..e8d9c71a5ef 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/src/export/MetricData.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/src/export/MetricData.ts @@ -21,31 +21,63 @@ import { Resource } from '@opentelemetry/resources'; import { InstrumentDescriptor } from '../InstrumentDescriptor'; import { Histogram } from '../aggregator/types'; +/** + * Basic metric data fields. + */ export interface BaseMetricData { + /** + * Resource associated with metric telemetry + */ readonly resource: Resource; + /** + * InstrumentationLibrary which created the metric instrument. + */ readonly instrumentationLibrary: InstrumentationLibrary; + /** + * InstrumentDescriptor which describes the metric instrument. + */ readonly instrumentDescriptor: InstrumentDescriptor; + /** + * PointDataType of the metric instrument. + */ readonly pointDataType: PointDataType, } +/** + * Represents a metric data aggregated by either a LastValueAggregation or + * SumAggregation. + */ export interface SingularMetricData extends BaseMetricData { readonly pointDataType: PointDataType.SINGULAR, readonly pointData: PointData[], } +/** + * Represents a metric data aggregated by a HistogramAggregation. + */ export interface HistogramMetricData extends BaseMetricData { readonly pointDataType: PointDataType.HISTOGRAM, readonly pointData: PointData[], } +/** + * Represents an aggregated metric data. + */ export type MetricData = SingularMetricData | HistogramMetricData; +/** + * The aggregated point data type + */ export enum PointDataType { SINGULAR, HISTOGRAM, EXPONENTIAL_HISTOGRAM, } +/** + * Represents an aggregated point data with start time, end time and their + * associated attributes and points. + */ export interface PointData { /** * The start epoch timestamp of the PointData, usually the time when diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/src/index.ts b/experimental/packages/opentelemetry-sdk-metrics-base/src/index.ts index 35622792a2f..ba9b60de026 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/src/index.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/src/index.ts @@ -14,6 +14,15 @@ * limitations under the License. */ -export { MeterProvider, MeterProviderOptions } from './MeterProvider'; +export * from './export/AggregationTemporality'; +export * from './export/MetricData'; export * from './export/MetricExporter'; +export * from './export/MetricProducer'; export * from './export/MetricReader'; +export * from './export/PeriodicExportingMetricReader'; +export { InstrumentDescriptor, InstrumentType } from './InstrumentDescriptor'; +export * from './Instruments'; +export * from './Meter'; +export * from './MeterProvider'; +export * from './ObservableResult'; +export { TimeoutError } from './utils'; diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/src/view/Aggregation.ts b/experimental/packages/opentelemetry-sdk-metrics-base/src/view/Aggregation.ts index b2b7b6a32ce..923126b146a 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/src/view/Aggregation.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/src/view/Aggregation.ts @@ -17,16 +17,15 @@ import * as api from '@opentelemetry/api'; import { Aggregator, SumAggregator, DropAggregator, LastValueAggregator, HistogramAggregator } from '../aggregator'; import { Accumulation } from '../aggregator/types'; -import { InstrumentDescriptor } from '../InstrumentDescriptor'; -import { InstrumentType } from '../Instruments'; +import { InstrumentDescriptor, InstrumentType } from '../InstrumentDescriptor'; import { Maybe } from '../utils'; -// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#aggregation - /** - * Configures how measurements are combined into metrics for {@link View}s. + * Configures how measurements are combined into metrics for views. * * Aggregation provides a set of built-in aggregations via static methods. + * + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#aggregation */ export abstract class Aggregation { abstract createAggregator(instrument: InstrumentDescriptor): Aggregator>; @@ -52,6 +51,10 @@ export abstract class Aggregation { } } +/** + * The default drop aggregation. + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#drop-aggregation + */ export class DropAggregation extends Aggregation { private static DEFAULT_INSTANCE = new DropAggregator(); createAggregator(_instrument: InstrumentDescriptor) { @@ -59,6 +62,10 @@ export class DropAggregation extends Aggregation { } } +/** + * The default sum aggregation. + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#sum-aggregation + */ export class SumAggregation extends Aggregation { private static DEFAULT_INSTANCE = new SumAggregator(); createAggregator(_instrument: InstrumentDescriptor) { @@ -66,6 +73,10 @@ export class SumAggregation extends Aggregation { } } +/** + * The default last value aggregation. + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#last-value-aggregation + */ export class LastValueAggregation extends Aggregation { private static DEFAULT_INSTANCE = new LastValueAggregator(); createAggregator(_instrument: InstrumentDescriptor) { @@ -73,15 +84,25 @@ export class LastValueAggregation extends Aggregation { } } +/** + * The default histogram aggregation. + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#histogram-aggregation + */ export class HistogramAggregation extends Aggregation { - // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#histogram-aggregation private static DEFAULT_INSTANCE = new HistogramAggregator([0, 5, 10, 25, 50, 75, 100, 250, 500, 1000]); createAggregator(_instrument: InstrumentDescriptor) { return HistogramAggregation.DEFAULT_INSTANCE; } } +/** + * The explicit bucket histogram aggregation. + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#explicit-bucket-histogram-aggregation + */ export class ExplicitBucketHistogramAggregation extends Aggregation { + /** + * @param _boundaries the bucket boundaries of the histogram aggregation + */ constructor(private _boundaries: number[]) { super(); } @@ -91,7 +112,9 @@ export class ExplicitBucketHistogramAggregation extends Aggregation { } } -// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#default-aggregation +/** + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#default-aggregation + */ export class DefaultAggregation extends Aggregation { private _resolve(instrument: InstrumentDescriptor): Aggregation { // cast to unknown to disable complaints on the (unreachable) fallback. diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/src/view/InstrumentSelector.ts b/experimental/packages/opentelemetry-sdk-metrics-base/src/view/InstrumentSelector.ts index c7dc6fa28e5..e7bec3a44a2 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/src/view/InstrumentSelector.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/src/view/InstrumentSelector.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { InstrumentType } from '../Instruments'; +import { InstrumentType } from '../InstrumentDescriptor'; import { PatternPredicate, Predicate } from './Predicate'; export interface InstrumentSelectorCriteria { diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/test/util.ts b/experimental/packages/opentelemetry-sdk-metrics-base/test/util.ts index 301a2a9e447..917277e4363 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/test/util.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/test/util.ts @@ -18,8 +18,8 @@ import { Attributes, ValueType } from '@opentelemetry/api-metrics'; import { InstrumentationLibrary } from '@opentelemetry/core'; import { Resource } from '@opentelemetry/resources'; import * as assert from 'assert'; -import { InstrumentDescriptor } from '../src/InstrumentDescriptor'; -import { Histogram, InstrumentType } from '../src/Instruments'; +import { InstrumentDescriptor, InstrumentType } from '../src/InstrumentDescriptor'; +import { Histogram } from '../src/Instruments'; import { MetricData, PointData, PointDataType } from '../src/export/MetricData'; import { Measurement } from '../src/Measurement'; import { isNotNullish } from '../src/utils'; diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/test/view/Aggregation.test.ts b/experimental/packages/opentelemetry-sdk-metrics-base/test/view/Aggregation.test.ts index 717c74a1ad0..6ce420a5114 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/test/view/Aggregation.test.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/test/view/Aggregation.test.ts @@ -22,8 +22,7 @@ import { LastValueAggregator, SumAggregator, } from '../../src/aggregator'; -import { InstrumentDescriptor } from '../../src/InstrumentDescriptor'; -import { InstrumentType } from '../../src/Instruments'; +import { InstrumentDescriptor, InstrumentType } from '../../src/InstrumentDescriptor'; import { Aggregation, DefaultAggregation, diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/test/view/ViewRegistry.test.ts b/experimental/packages/opentelemetry-sdk-metrics-base/test/view/ViewRegistry.test.ts index dd1321a400c..db5e0cf3808 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/test/view/ViewRegistry.test.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/test/view/ViewRegistry.test.ts @@ -15,7 +15,7 @@ */ import * as assert from 'assert'; -import { InstrumentType } from '../../src/Instruments'; +import { InstrumentType } from '../../src/InstrumentDescriptor'; import { ViewRegistry } from '../../src/view/ViewRegistry'; import { View } from '../../src/view/View'; import { InstrumentSelector } from '../../src/view/InstrumentSelector'; From 8d77102927d0cf173dd051312c7eabb0f758f90a Mon Sep 17 00:00:00 2001 From: legendecas Date: Mon, 24 Jan 2022 11:01:50 +0800 Subject: [PATCH 2/3] fixup! --- .../opentelemetry-sdk-metrics-base/src/Instruments.ts | 3 --- .../packages/opentelemetry-sdk-metrics-base/src/Meter.ts | 1 - .../opentelemetry-sdk-metrics-base/src/MeterProvider.ts | 1 - .../exemplar/AlignedHistogramBucketExemplarReservoir.ts | 3 +-- .../src/export/AggregationTemporality.ts | 2 -- .../src/export/MetricData.ts | 4 ++-- .../src/view/Aggregation.ts | 9 +-------- 7 files changed, 4 insertions(+), 19 deletions(-) diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/src/Instruments.ts b/experimental/packages/opentelemetry-sdk-metrics-base/src/Instruments.ts index 309bea68059..60dbc9e364a 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/src/Instruments.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/src/Instruments.ts @@ -33,7 +33,6 @@ export class SyncInstrument { /** * The class implements {@link metrics.UpDownCounter} interface. - * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#updowncounter */ export class UpDownCounter extends SyncInstrument implements metrics.UpDownCounter { /** @@ -46,7 +45,6 @@ export class UpDownCounter extends SyncInstrument implements metrics.UpDownCount /** * The class implements {@link metrics.Counter} interface. - * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#counter */ export class Counter extends SyncInstrument implements metrics.Counter { /** @@ -64,7 +62,6 @@ export class Counter extends SyncInstrument implements metrics.Counter { /** * The class implements {@link metrics.Histogram} interface. - * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#histogram */ export class Histogram extends SyncInstrument implements metrics.Histogram { /** diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/src/Meter.ts b/experimental/packages/opentelemetry-sdk-metrics-base/src/Meter.ts index de09deb3910..cc4c54545c3 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/src/Meter.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/src/Meter.ts @@ -30,7 +30,6 @@ import { AsyncMetricStorage } from './state/AsyncMetricStorage'; /** * This class implements the {@link metrics.Meter} interface. - * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#meter */ export class Meter implements metrics.Meter { private _metricStorageRegistry = new Map(); diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/src/MeterProvider.ts b/experimental/packages/opentelemetry-sdk-metrics-base/src/MeterProvider.ts index a72deacf3e8..d9e6d951a1e 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/src/MeterProvider.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/src/MeterProvider.ts @@ -35,7 +35,6 @@ export interface MeterProviderOptions { /** * This class implements the {@link metrics.MeterProvider} interface. - * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#meterprovider */ export class MeterProvider implements metrics.MeterProvider { private _sharedState: MeterProviderSharedState; diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/src/exemplar/AlignedHistogramBucketExemplarReservoir.ts b/experimental/packages/opentelemetry-sdk-metrics-base/src/exemplar/AlignedHistogramBucketExemplarReservoir.ts index 9c09abf9cfe..f69487ec066 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/src/exemplar/AlignedHistogramBucketExemplarReservoir.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/src/exemplar/AlignedHistogramBucketExemplarReservoir.ts @@ -22,9 +22,8 @@ import { FixedSizeExemplarReservoirBase } from './ExemplarReservoir'; /** * AlignedHistogramBucketExemplarReservoir takes the same boundaries - * configuration of a Histogram. This alogorithm keeps the last seen measurement + * configuration of a Histogram. This algorithm keeps the last seen measurement * that falls within a histogram bucket. - * https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#exemplar-defaults */ export class AlignedHistogramBucketExemplarReservoir extends FixedSizeExemplarReservoirBase { private _boundaries: number[]; diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/src/export/AggregationTemporality.ts b/experimental/packages/opentelemetry-sdk-metrics-base/src/export/AggregationTemporality.ts index 6ecb2bb9734..6cc6d1231bf 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/src/export/AggregationTemporality.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/src/export/AggregationTemporality.ts @@ -16,8 +16,6 @@ /** * AggregationTemporality indicates the way additive quantities are expressed. - * - * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/datamodel.md#temporality */ export enum AggregationTemporality { DELTA, diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/src/export/MetricData.ts b/experimental/packages/opentelemetry-sdk-metrics-base/src/export/MetricData.ts index e8d9c71a5ef..736c83034ac 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/src/export/MetricData.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/src/export/MetricData.ts @@ -26,7 +26,7 @@ import { Histogram } from '../aggregator/types'; */ export interface BaseMetricData { /** - * Resource associated with metric telemetry + * Resource associated with metric telemetry. */ readonly resource: Resource; /** @@ -66,7 +66,7 @@ export interface HistogramMetricData extends BaseMetricData { export type MetricData = SingularMetricData | HistogramMetricData; /** - * The aggregated point data type + * The aggregated point data type. */ export enum PointDataType { SINGULAR, diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/src/view/Aggregation.ts b/experimental/packages/opentelemetry-sdk-metrics-base/src/view/Aggregation.ts index 923126b146a..601461238a3 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/src/view/Aggregation.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/src/view/Aggregation.ts @@ -24,8 +24,6 @@ import { Maybe } from '../utils'; * Configures how measurements are combined into metrics for views. * * Aggregation provides a set of built-in aggregations via static methods. - * - * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#aggregation */ export abstract class Aggregation { abstract createAggregator(instrument: InstrumentDescriptor): Aggregator>; @@ -53,7 +51,6 @@ export abstract class Aggregation { /** * The default drop aggregation. - * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#drop-aggregation */ export class DropAggregation extends Aggregation { private static DEFAULT_INSTANCE = new DropAggregator(); @@ -64,7 +61,6 @@ export class DropAggregation extends Aggregation { /** * The default sum aggregation. - * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#sum-aggregation */ export class SumAggregation extends Aggregation { private static DEFAULT_INSTANCE = new SumAggregator(); @@ -75,7 +71,6 @@ export class SumAggregation extends Aggregation { /** * The default last value aggregation. - * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#last-value-aggregation */ export class LastValueAggregation extends Aggregation { private static DEFAULT_INSTANCE = new LastValueAggregator(); @@ -86,7 +81,6 @@ export class LastValueAggregation extends Aggregation { /** * The default histogram aggregation. - * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#histogram-aggregation */ export class HistogramAggregation extends Aggregation { private static DEFAULT_INSTANCE = new HistogramAggregator([0, 5, 10, 25, 50, 75, 100, 250, 500, 1000]); @@ -97,7 +91,6 @@ export class HistogramAggregation extends Aggregation { /** * The explicit bucket histogram aggregation. - * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#explicit-bucket-histogram-aggregation */ export class ExplicitBucketHistogramAggregation extends Aggregation { /** @@ -113,7 +106,7 @@ export class ExplicitBucketHistogramAggregation extends Aggregation { } /** - * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#default-aggregation + * The default aggregation. */ export class DefaultAggregation extends Aggregation { private _resolve(instrument: InstrumentDescriptor): Aggregation { From b7774be08de7a72e307969b2fd37129356769289 Mon Sep 17 00:00:00 2001 From: legendecas Date: Mon, 24 Jan 2022 11:11:40 +0800 Subject: [PATCH 3/3] fixup! --- .../opentelemetry-sdk-metrics-base/src/InstrumentDescriptor.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/src/InstrumentDescriptor.ts b/experimental/packages/opentelemetry-sdk-metrics-base/src/InstrumentDescriptor.ts index ecb7543a5a5..92ba0f70174 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/src/InstrumentDescriptor.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/src/InstrumentDescriptor.ts @@ -19,7 +19,6 @@ import { View } from './view/View'; /** * Supported types of metric instruments. - * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#instrument */ export enum InstrumentType { COUNTER = 'COUNTER',