Skip to content

Commit

Permalink
Use the correct instrument type while creating aysnchronous instrument
Browse files Browse the repository at this point in the history
  • Loading branch information
hunguyenaxon committed Oct 9, 2023
1 parent 8d6fa74 commit 6a5265d
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 51 deletions.
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
//
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
//
//

import Foundation
import OpenTelemetryApi

public class DoubleCounterMeterBuilderSdk : DoubleCounterBuilder, InstrumentBuilder {

var meterSharedState: StableMeterSharedState
public class DoubleCounterMeterBuilderSdk: DoubleCounterBuilder, InstrumentBuilder {
var meterSharedState: StableMeterSharedState

var meterProviderSharedState: MeterProviderSharedState

let type: InstrumentType = .counter

let valueType: InstrumentValueType = .double

var instrumentName: String

var description: String

var unit: String

var instrumentName: String

init(meterProviderSharedState : MeterProviderSharedState, meterSharedState : StableMeterSharedState, name : String, description: String, unit: String) {
init(meterProviderSharedState: MeterProviderSharedState,
meterSharedState: StableMeterSharedState,
name: String,
description: String,
unit: String) {
self.meterProviderSharedState = meterProviderSharedState
self.meterSharedState = meterSharedState
self.unit = unit
self.description = description
self.instrumentName = name
self.instrumentName = name
}

public func build() -> OpenTelemetryApi.DoubleCounter {
buildSynchronousInstrument(DoubleCounterSdk.init)
}

public func buildWithCallback(_ callback: @escaping (OpenTelemetryApi.ObservableDoubleMeasurement) -> Void) -> OpenTelemetryApi.ObservableDoubleCounter {
registerDoubleAsynchronousInstrument(type: .counter, updater: callback)
public func buildWithCallback(_ callback: @escaping (OpenTelemetryApi.ObservableDoubleMeasurement) -> Void)
-> OpenTelemetryApi.ObservableDoubleCounter {
registerDoubleAsynchronousInstrument(type: .observableCounter, updater: callback)
}




}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
//
//

import Foundation
import OpenTelemetryApi

public class DoubleUpDownCounterBuilderSdk : DoubleUpDownCounterBuilder, InstrumentBuilder {
public class DoubleUpDownCounterBuilderSdk: DoubleUpDownCounterBuilder, InstrumentBuilder {
var meterSharedState: StableMeterSharedState

var meterProviderSharedState: MeterProviderSharedState
Expand All @@ -15,28 +15,30 @@ public class DoubleUpDownCounterBuilderSdk : DoubleUpDownCounterBuilder, Instrum

let valueType: InstrumentValueType = .double

var instrumentName: String

var description: String

var unit: String

var instrumentName: String

init(meterProviderSharedState : MeterProviderSharedState, meterSharedState : StableMeterSharedState, name : String, description: String, unit: String) {
init(meterProviderSharedState: MeterProviderSharedState,
meterSharedState: StableMeterSharedState,
name: String,
description: String,
unit: String) {
self.meterProviderSharedState = meterProviderSharedState
self.meterSharedState = meterSharedState
self.unit = unit
self.description = description
self.instrumentName = name
self.instrumentName = name
}

public func build() -> OpenTelemetryApi.DoubleUpDownCounter {
buildSynchronousInstrument(DoubleUpDownCounterSdk.init)
}

public func buildWithCallback(_ callback: @escaping (OpenTelemetryApi.ObservableDoubleMeasurement) -> Void) -> OpenTelemetryApi.ObservableDoubleUpDownCounter {
registerDoubleAsynchronousInstrument(type: type, updater: callback)
public func buildWithCallback(_ callback: @escaping (OpenTelemetryApi.ObservableDoubleMeasurement) -> Void)
-> OpenTelemetryApi.ObservableDoubleUpDownCounter {
registerDoubleAsynchronousInstrument(type: .observableUpDownCounter, updater: callback)
}



}
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
//
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
//
//

import Foundation
import OpenTelemetryApi

public class LongCounterMeterBuilderSdk : LongCounterBuilder, InstrumentBuilder {

public class LongCounterMeterBuilderSdk: LongCounterBuilder, InstrumentBuilder {
var meterProviderSharedState: MeterProviderSharedState

var meterSharedState: StableMeterSharedState

var type: InstrumentType
let type: InstrumentType = .counter

var valueType: InstrumentValueType
let valueType: InstrumentValueType = .long

var instrumentName: String

var description: String = ""

var unit: String = ""

var instrumentName: String

internal init(meterProviderSharedState: inout MeterProviderSharedState, meterSharedState: inout StableMeterSharedState, name: String) {
init(meterProviderSharedState: inout MeterProviderSharedState,
meterSharedState: inout StableMeterSharedState,
name: String) {
self.meterProviderSharedState = meterProviderSharedState
self.meterSharedState = meterSharedState
self.instrumentName = name
type = .counter
valueType = .long

}

public func ofDoubles() -> OpenTelemetryApi.DoubleCounterBuilder {
Expand All @@ -39,10 +37,8 @@ public class LongCounterMeterBuilderSdk : LongCounterBuilder, InstrumentBuilder
return buildSynchronousInstrument(LongCounterSdk.init)
}

public func buildWithCallback(_ callback: @escaping (OpenTelemetryApi.ObservableLongMeasurement) -> Void) -> OpenTelemetryApi.ObservableLongCounter {
registerLongAsynchronousInstrument(type: type, updater: callback)
public func buildWithCallback(_ callback: @escaping (OpenTelemetryApi.ObservableLongMeasurement) -> Void)
-> OpenTelemetryApi.ObservableLongCounter {
registerLongAsynchronousInstrument(type: .observableCounter, updater: callback)
}


}

Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
//
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
//
//

import Foundation
import OpenTelemetryApi

public class LongUpDownCounterBuilderSdk : LongUpDownCounterBuilder, InstrumentBuilder {

var instrumentName: String

public class LongUpDownCounterBuilderSdk: LongUpDownCounterBuilder, InstrumentBuilder {
var meterSharedState: StableMeterSharedState

var meterProviderSharedState: MeterProviderSharedState
Expand All @@ -18,11 +15,15 @@ public class LongUpDownCounterBuilderSdk : LongUpDownCounterBuilder, InstrumentB

let valueType: InstrumentValueType = .long

var instrumentName: String

var description: String = ""

var unit: String = ""

init(meterProviderSharedState: inout MeterProviderSharedState, meterSharedState: inout StableMeterSharedState, name : String) {
init(meterProviderSharedState: inout MeterProviderSharedState,
meterSharedState: inout StableMeterSharedState,
name: String) {
self.meterSharedState = meterSharedState
self.meterProviderSharedState = meterProviderSharedState
self.instrumentName = name
Expand All @@ -36,9 +37,8 @@ public class LongUpDownCounterBuilderSdk : LongUpDownCounterBuilder, InstrumentB
buildSynchronousInstrument(LongUpDownCounterSdk.init)
}

public func buildWithCallback(_ callback: @escaping (OpenTelemetryApi.ObservableLongMeasurement) -> Void) -> OpenTelemetryApi.ObservableLongUpDownCounter {
registerLongAsynchronousInstrument(type: type, updater: callback)
public func buildWithCallback(_ callback: @escaping (OpenTelemetryApi.ObservableLongMeasurement) -> Void)
-> OpenTelemetryApi.ObservableLongUpDownCounter {
registerLongAsynchronousInstrument(type: .observableUpDownCounter, updater: callback)
}


}

0 comments on commit 6a5265d

Please sign in to comment.