diff --git a/Sources/OpenTelemetryApi/Metrics/Stable/DefaultStableMeter.swift b/Sources/OpenTelemetryApi/Metrics/Stable/DefaultStableMeter.swift index 50300ed1..f13a20ae 100644 --- a/Sources/OpenTelemetryApi/Metrics/Stable/DefaultStableMeter.swift +++ b/Sources/OpenTelemetryApi/Metrics/Stable/DefaultStableMeter.swift @@ -66,9 +66,13 @@ public class DefaultStableMeter : StableMeter { } } - private struct NoopObservableLongGauge : ObservableLongGauge {} + private struct NoopObservableLongGauge : ObservableLongGauge { + func close() {} + } - private struct NoopObservableDoubleGauge : ObservableDoubleGauge {} + private struct NoopObservableDoubleGauge : ObservableDoubleGauge { + func close() {} + } private class NoopDoubleUpDownCounterBuilder : DoubleUpDownCounterBuilder { func build() -> DoubleUpDownCounter { @@ -80,7 +84,9 @@ public class DefaultStableMeter : StableMeter { } } - private struct NoopObservableDoubleUpDownCounter : ObservableDoubleUpDownCounter {} + private struct NoopObservableDoubleUpDownCounter : ObservableDoubleUpDownCounter { + func close() {} + } private struct NoopDoubleUpDownCounter : DoubleUpDownCounter { mutating func add(value: Double) {} @@ -103,7 +109,9 @@ public class DefaultStableMeter : StableMeter { mutating func record(value: Int, attributes: [String : AttributeValue]) {} } - private class NoopObservableLongUpDownCounter : ObservableLongUpDownCounter {} + private class NoopObservableLongUpDownCounter : ObservableLongUpDownCounter { + func close() {} + } private class NoopDoubleHistogram : DoubleHistogram { func record(value: Double) {} @@ -139,8 +147,13 @@ public class DefaultStableMeter : StableMeter { } } - private class NoopObservableLongCounter : ObservableLongCounter {} - private class NoopObservableDoubleCounter: ObservableDoubleCounter {} + private class NoopObservableLongCounter : ObservableLongCounter { + func close() {} + } + + private class NoopObservableDoubleCounter: ObservableDoubleCounter { + func close() {} + } private class StableNoopDoubleCounterBuilder : DoubleCounterBuilder { func build() -> DoubleCounter { diff --git a/Sources/OpenTelemetryApi/Metrics/Stable/ObservableDoubleCounter.swift b/Sources/OpenTelemetryApi/Metrics/Stable/ObservableDoubleCounter.swift index de10ef26..00355435 100644 --- a/Sources/OpenTelemetryApi/Metrics/Stable/ObservableDoubleCounter.swift +++ b/Sources/OpenTelemetryApi/Metrics/Stable/ObservableDoubleCounter.swift @@ -6,4 +6,5 @@ import Foundation public protocol ObservableDoubleCounter { + func close() } diff --git a/Sources/OpenTelemetryApi/Metrics/Stable/ObservableDoubleGauge.swift b/Sources/OpenTelemetryApi/Metrics/Stable/ObservableDoubleGauge.swift index 89f8482a..bfadf9ed 100644 --- a/Sources/OpenTelemetryApi/Metrics/Stable/ObservableDoubleGauge.swift +++ b/Sources/OpenTelemetryApi/Metrics/Stable/ObservableDoubleGauge.swift @@ -6,4 +6,5 @@ import Foundation public protocol ObservableDoubleGauge { + func close() } diff --git a/Sources/OpenTelemetryApi/Metrics/Stable/ObservableDoubleUpDownCounter.swift b/Sources/OpenTelemetryApi/Metrics/Stable/ObservableDoubleUpDownCounter.swift index a3ce7657..43d4b2b7 100644 --- a/Sources/OpenTelemetryApi/Metrics/Stable/ObservableDoubleUpDownCounter.swift +++ b/Sources/OpenTelemetryApi/Metrics/Stable/ObservableDoubleUpDownCounter.swift @@ -6,4 +6,5 @@ import Foundation public protocol ObservableDoubleUpDownCounter { + func close() } diff --git a/Sources/OpenTelemetryApi/Metrics/Stable/ObservableLongCounter.swift b/Sources/OpenTelemetryApi/Metrics/Stable/ObservableLongCounter.swift index 234f2c86..0696b6a8 100644 --- a/Sources/OpenTelemetryApi/Metrics/Stable/ObservableLongCounter.swift +++ b/Sources/OpenTelemetryApi/Metrics/Stable/ObservableLongCounter.swift @@ -6,4 +6,5 @@ import Foundation public protocol ObservableLongCounter { + func close() } diff --git a/Sources/OpenTelemetryApi/Metrics/Stable/ObservableLongGauge.swift b/Sources/OpenTelemetryApi/Metrics/Stable/ObservableLongGauge.swift index 8a0b72b0..0ce4c488 100644 --- a/Sources/OpenTelemetryApi/Metrics/Stable/ObservableLongGauge.swift +++ b/Sources/OpenTelemetryApi/Metrics/Stable/ObservableLongGauge.swift @@ -6,4 +6,5 @@ import Foundation public protocol ObservableLongGauge { + func close() } diff --git a/Sources/OpenTelemetryApi/Metrics/Stable/ObservableLongUpDownCounter.swift b/Sources/OpenTelemetryApi/Metrics/Stable/ObservableLongUpDownCounter.swift index 9b89dc61..7a663440 100644 --- a/Sources/OpenTelemetryApi/Metrics/Stable/ObservableLongUpDownCounter.swift +++ b/Sources/OpenTelemetryApi/Metrics/Stable/ObservableLongUpDownCounter.swift @@ -6,4 +6,5 @@ import Foundation public protocol ObservableLongUpDownCounter { + func close() } diff --git a/Sources/OpenTelemetrySdk/Metrics/Stable/ObservableInstrumentSdk.swift b/Sources/OpenTelemetrySdk/Metrics/Stable/ObservableInstrumentSdk.swift index a534d09a..9fc56c10 100644 --- a/Sources/OpenTelemetrySdk/Metrics/Stable/ObservableInstrumentSdk.swift +++ b/Sources/OpenTelemetrySdk/Metrics/Stable/ObservableInstrumentSdk.swift @@ -16,4 +16,7 @@ public struct ObservableInstrumentSdk : ObservableDoubleCounter, ObservableLongC } // todo: Java implementation uses closeables to remove this from the meterSharedState.callback Registation. investigate alternative? + public func close() { + meterSharedState.removeCallback(callback: callbackRegistration) + } }