Issue happens on DoubleCounterMeterBuilderSdk, DoubleUpDownCounterBuilderSdk, LongCounterMeterBuilderSdk and LongUpDownCounterBuilderSdk.
The buildWithCallback(..) need to provide the correct InstrumentType of asynchronous counter, instead of synchronous counter. Otherwise the registerObservableMeasurement(...) will crash with forced cast.
public class DoubleCounterMeterBuilderSdk : DoubleCounterBuilder, InstrumentBuilder {
let type: InstrumentType = .counter
let valueType: InstrumentValueType = .double
...
public func buildWithCallback(_ callback: @escaping (OpenTelemetryApi.ObservableDoubleMeasurement) -> Void) -> OpenTelemetryApi.ObservableDoubleCounter {
registerDoubleAsynchronousInstrument(type: .counter, updater: callback) // <~~~ supposed to be .observableCounter
}
}
Issue happens on
DoubleCounterMeterBuilderSdk
,DoubleUpDownCounterBuilderSdk
,LongCounterMeterBuilderSdk
andLongUpDownCounterBuilderSdk
.The
buildWithCallback(..)
need to provide the correct InstrumentType of asynchronous counter, instead of synchronous counter. Otherwise theregisterObservableMeasurement(...)
will crash with forced cast.