From f31a0ee95a48e740087d80daa9e85aab4d46ed14 Mon Sep 17 00:00:00 2001 From: Chengzhong Wu Date: Mon, 19 Dec 2022 15:11:55 +0800 Subject: [PATCH] fix(api): declare this parameter type in observable callbacks --- api/CHANGELOG.md | 1 + api/src/metrics/ObservableResult.ts | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/api/CHANGELOG.md b/api/CHANGELOG.md index eb11d5c2f94..66db7dfe374 100644 --- a/api/CHANGELOG.md +++ b/api/CHANGELOG.md @@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file. * fix(api): deprecate MetricAttributes and MetricAttributeValue [#3406](https://github.com/open-telemetry/opentelemetry-js/pull/3406) @blumamir * test(api): disable module concatenation in tree-shaking test [#3409](https://github.com/open-telemetry/opentelemetry-js/pull/3409) @legendecas * fix(api): use active context as default in NoopTracer [#3476](https://github.com/open-telemetry/opentelemetry-js/pull/3476) @flarna +* fix(api): declare this parameter type in observable callbacks @legendecas ## [1.3.0](https://www.github.com/open-telemetry/opentelemetry-js-api/compare/v1.2.0...v1.3.0) diff --git a/api/src/metrics/ObservableResult.ts b/api/src/metrics/ObservableResult.ts index 70d0eff1dc9..5b4f9e962b3 100644 --- a/api/src/metrics/ObservableResult.ts +++ b/api/src/metrics/ObservableResult.ts @@ -30,7 +30,11 @@ export interface ObservableResult< * one values associated with the same attributes values, SDK may pick the * last one or simply drop the entire observable result. */ - observe(value: number, attributes?: AttributesTypes): void; + observe( + this: ObservableResult, + value: number, + attributes?: AttributesTypes + ): void; } /** @@ -49,6 +53,7 @@ export interface BatchObservableResult< * last one or simply drop the entire observable result. */ observe( + this: BatchObservableResult, metric: Observable, value: number, attributes?: AttributesTypes