diff --git a/instrumentation/ktor/ktor-2-common/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/common/AbstractKtorClientTelemetryBuilder.kt b/instrumentation/ktor/ktor-2-common/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/common/AbstractKtorClientTelemetryBuilder.kt index ddb10c6bc68b..f07d5c6764ed 100644 --- a/instrumentation/ktor/ktor-2-common/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/common/AbstractKtorClientTelemetryBuilder.kt +++ b/instrumentation/ktor/ktor-2-common/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/common/AbstractKtorClientTelemetryBuilder.kt @@ -27,17 +27,19 @@ abstract class AbstractKtorClientTelemetryBuilder( } internal lateinit var openTelemetry: OpenTelemetry - internal lateinit var internalBuilder: DefaultHttpClientInstrumenterBuilder protected lateinit var builder: DefaultHttpClientInstrumenterBuilder + internal fun builder(): DefaultHttpClientInstrumenterBuilder { + return builder + } + fun setOpenTelemetry(openTelemetry: OpenTelemetry) { this.openTelemetry = openTelemetry - this.internalBuilder = DefaultHttpClientInstrumenterBuilder.create( + this.builder = DefaultHttpClientInstrumenterBuilder.create( instrumentationName, openTelemetry, KtorHttpClientAttributesGetter ) - this.builder = internalBuilder } protected fun getOpenTelemetry(): OpenTelemetry { diff --git a/instrumentation/ktor/ktor-2-common/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/common/internal/Experimental.kt b/instrumentation/ktor/ktor-2-common/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/common/internal/Experimental.kt index 2add55107800..9fc388d14254 100644 --- a/instrumentation/ktor/ktor-2-common/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/common/internal/Experimental.kt +++ b/instrumentation/ktor/ktor-2-common/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/common/internal/Experimental.kt @@ -12,7 +12,7 @@ class Experimental private constructor() { companion object { fun emitExperimentalTelemetry(builder: AbstractKtorClientTelemetryBuilder) { - builder.internalBuilder.setEmitExperimentalHttpClientMetrics(true) + builder.builder().setEmitExperimentalHttpClientMetrics(true) } fun emitExperimentalTelemetry(builder: AbstractKtorServerTelemetryBuilder) {