From c7c1867c829b92e23f8793422ab8b42979cdc2d7 Mon Sep 17 00:00:00 2001 From: Marc Pichler Date: Wed, 8 Nov 2023 12:56:29 +0100 Subject: [PATCH] fix(sdk-metrics): hand-roll MetricAdvice type as older API versions do not include it (#4260) --- CHANGELOG.md | 2 ++ .../sdk-metrics/src/InstrumentDescriptor.ts | 18 +++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bb8571e31dd..328a51e341a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ For experimental package changes, see the [experimental CHANGELOG](experimental/ ### :bug: (Bug Fix) +fix(sdk-metrics): hand-roll MetricAdvice type as older API versions do not include it #4260 + ### :books: (Refine Doc) ### :house: (Internal) diff --git a/packages/sdk-metrics/src/InstrumentDescriptor.ts b/packages/sdk-metrics/src/InstrumentDescriptor.ts index ed036eb4dbc..b8797e2c4dc 100644 --- a/packages/sdk-metrics/src/InstrumentDescriptor.ts +++ b/packages/sdk-metrics/src/InstrumentDescriptor.ts @@ -14,12 +14,7 @@ * limitations under the License. */ -import { - MetricAdvice, - MetricOptions, - ValueType, - diag, -} from '@opentelemetry/api'; +import { MetricOptions, ValueType, diag } from '@opentelemetry/api'; import { View } from './view/View'; import { equalsCaseInsensitive } from './utils'; @@ -49,8 +44,17 @@ export interface InstrumentDescriptor { readonly valueType: ValueType; /** * @experimental + * + * This is intentionally not using the API's type as it's only available from @opentelemetry/api 1.7.0 and up. + * In SDK 2.0 we'll be able to bump the minimum API version and remove this workaround. */ - readonly advice: MetricAdvice; + readonly advice: { + /** + * Hint the explicit bucket boundaries for SDK if the metric has been + * aggregated with a HistogramAggregator. + */ + explicitBucketBoundaries?: number[]; + }; } export function createInstrumentDescriptor(