From 14afcc1f7bf3d9e33cdfc1aee8d83455eb7630ab Mon Sep 17 00:00:00 2001 From: Daniel Dyla Date: Sat, 27 Nov 2021 07:59:45 -0500 Subject: [PATCH] chore: Update wip metrics references (#2638) --- .../src/InstrumentDescriptor.ts | 2 +- .../src/Instruments.ts | 2 +- .../src/Measurement.ts | 2 +- .../src/Meter.ts | 20 +++++++++++++++---- .../src/MeterProvider.ts | 2 +- .../src/state/MultiWritableMetricStorage.ts | 2 +- .../src/state/WritableMetricStorage.ts | 2 +- .../src/view/AttributesProcessor.ts | 2 +- .../src/view/Predicate.ts | 5 +++-- .../test/view/ViewRegistry.test.ts | 2 +- 10 files changed, 27 insertions(+), 14 deletions(-) diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/src/InstrumentDescriptor.ts b/experimental/packages/opentelemetry-sdk-metrics-base/src/InstrumentDescriptor.ts index 452356e3cc3..d62b0710a61 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/src/InstrumentDescriptor.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/src/InstrumentDescriptor.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { MetricOptions, ValueType } from '@opentelemetry/api-metrics'; +import { MetricOptions, ValueType } from '@opentelemetry/api-metrics-wip'; import { InstrumentType } from './Instruments'; export interface InstrumentDescriptor { diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/src/Instruments.ts b/experimental/packages/opentelemetry-sdk-metrics-base/src/Instruments.ts index 3953c9ecff0..decf7047945 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/src/Instruments.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/src/Instruments.ts @@ -15,7 +15,7 @@ */ import * as api from '@opentelemetry/api'; -import * as metrics from '@opentelemetry/api-metrics'; +import * as metrics from '@opentelemetry/api-metrics-wip'; import { InstrumentDescriptor } from './InstrumentDescriptor'; import { WritableMetricStorage } from './state/WritableMetricStorage'; diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/src/Measurement.ts b/experimental/packages/opentelemetry-sdk-metrics-base/src/Measurement.ts index 215426f9d76..4ea34a6b6bd 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/src/Measurement.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/src/Measurement.ts @@ -15,7 +15,7 @@ */ import * as api from '@opentelemetry/api' -import { Attributes } from '@opentelemetry/api-metrics' +import { Attributes } from '@opentelemetry/api-metrics-wip' // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#measurement diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/src/Meter.ts b/experimental/packages/opentelemetry-sdk-metrics-base/src/Meter.ts index 1fa967e6a48..20c57308789 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/src/Meter.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/src/Meter.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import * as metrics from '@opentelemetry/api-metrics'; +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'; @@ -54,15 +54,27 @@ export class Meter implements metrics.Meter { return new UpDownCounter(storage, descriptor); } - createObservableGauge(_name: string, _options?: metrics.MetricOptions, _callback?: (observableResult: metrics.ObservableResult) => void): metrics.ObservableBase { + createObservableGauge( + _name: string, + _callback: (observableResult: metrics.ObservableResult) => void, + _options?: metrics.MetricOptions, + ): metrics.ObservableGauge { throw new Error('Method not implemented.'); } - createObservableCounter(_name: string, _options?: metrics.MetricOptions, _callback?: (observableResult: metrics.ObservableResult) => void): metrics.ObservableBase { + createObservableCounter( + _name: string, + _callback: (observableResult: metrics.ObservableResult) => void, + _options?: metrics.MetricOptions, + ): metrics.ObservableBase { throw new Error('Method not implemented.'); } - createObservableUpDownCounter(_name: string, _options?: metrics.MetricOptions, _callback?: (observableResult: metrics.ObservableResult) => void): metrics.ObservableBase { + createObservableUpDownCounter( + _name: string, + _callback: (observableResult: metrics.ObservableResult) => void, + _options?: metrics.MetricOptions, + ): metrics.ObservableBase { throw new Error('Method not implemented.'); } diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/src/MeterProvider.ts b/experimental/packages/opentelemetry-sdk-metrics-base/src/MeterProvider.ts index 501c9bf2393..28b66806baf 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/src/MeterProvider.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/src/MeterProvider.ts @@ -15,7 +15,7 @@ */ import * as api from '@opentelemetry/api'; -import * as metrics from '@opentelemetry/api-metrics'; +import * as metrics from '@opentelemetry/api-metrics-wip'; import { Resource } from '@opentelemetry/resources'; import { Meter } from './Meter'; import { MetricExporter } from './MetricExporter'; diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/src/state/MultiWritableMetricStorage.ts b/experimental/packages/opentelemetry-sdk-metrics-base/src/state/MultiWritableMetricStorage.ts index 43c064828fd..3dc76048dc9 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/src/state/MultiWritableMetricStorage.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/src/state/MultiWritableMetricStorage.ts @@ -15,7 +15,7 @@ */ import { Context } from '@opentelemetry/api'; -import { Attributes } from '@opentelemetry/api-metrics'; +import { Attributes } from '@opentelemetry/api-metrics-wip'; import { WritableMetricStorage } from './WritableMetricStorage'; export class MultiMetricStorage implements WritableMetricStorage { diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/src/state/WritableMetricStorage.ts b/experimental/packages/opentelemetry-sdk-metrics-base/src/state/WritableMetricStorage.ts index 147cc216546..b72ecb66372 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/src/state/WritableMetricStorage.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/src/state/WritableMetricStorage.ts @@ -15,7 +15,7 @@ */ import { Context } from '@opentelemetry/api'; -import { Attributes } from '@opentelemetry/api-metrics'; +import { Attributes } from '@opentelemetry/api-metrics-wip'; export interface WritableMetricStorage { record(value: number, attributes: Attributes, context: Context): void; diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/src/view/AttributesProcessor.ts b/experimental/packages/opentelemetry-sdk-metrics-base/src/view/AttributesProcessor.ts index 5cdfa2dda44..15b46f53e0d 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/src/view/AttributesProcessor.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/src/view/AttributesProcessor.ts @@ -15,7 +15,7 @@ */ import { Context } from '@opentelemetry/api'; -import { Attributes } from '@opentelemetry/api-metrics'; +import { Attributes } from '@opentelemetry/api-metrics-wip'; /** * The {@link AttributesProcessor} is responsible for customizing which diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/src/view/Predicate.ts b/experimental/packages/opentelemetry-sdk-metrics-base/src/view/Predicate.ts index dd86990da67..5dfbb101a0b 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/src/view/Predicate.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/src/view/Predicate.ts @@ -28,11 +28,12 @@ export interface Predicate { */ export class PatternPredicate implements Predicate { private _matchAll: boolean; - private _regexp?: RegExp; + private _regexp: RegExp; constructor(pattern: string) { if (pattern === '*') { this._matchAll = true; + this._regexp = /.*/; } else { this._matchAll = false; this._regexp = new RegExp(PatternPredicate.escapePattern(pattern)); @@ -44,7 +45,7 @@ export class PatternPredicate implements Predicate { return true; } - return this._regexp!.test(str); + return this._regexp.test(str); } static escapePattern(pattern: string): string { 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 9aae44dea2e..e3c21a3b66f 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 { ValueType } from '@opentelemetry/api-metrics'; +import { ValueType } from '@opentelemetry/api-metrics-wip'; import { InstrumentationLibrary } from '@opentelemetry/core'; import { InstrumentType } from '../../src/Instruments'; import { ViewRegistry } from '../../src/view/ViewRegistry';