Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow async instrument to close via observable #472

Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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) {}
Expand All @@ -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) {}
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
import Foundation

public protocol ObservableDoubleCounter {
func close()
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
import Foundation

public protocol ObservableDoubleGauge {
func close()
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
import Foundation

public protocol ObservableDoubleUpDownCounter {
func close()
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
import Foundation

public protocol ObservableLongCounter {
func close()
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
import Foundation

public protocol ObservableLongGauge {
func close()
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
import Foundation

public protocol ObservableLongUpDownCounter {
func close()
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Loading