From 5329277c79871de318fa2043ad4f588e2d978186 Mon Sep 17 00:00:00 2001 From: Ian Botsford <83236726+ianbotsf@users.noreply.github.com> Date: Wed, 24 Apr 2024 19:24:07 +0000 Subject: [PATCH] chore: refactor service benchmark telemetry provider to use new abstractions --- gradle/libs.versions.toml | 4 +- .../telemetry/BenchmarkTelemetryProvider.kt | 67 ++----------------- 2 files changed, 7 insertions(+), 64 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index a864227fadb..c2e4d4ca7bf 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -9,8 +9,8 @@ coroutines-version = "1.7.3" atomicfu-version = "0.23.1" # smithy-kotlin codegen and runtime are versioned separately -smithy-kotlin-runtime-version = "1.1.5" -smithy-kotlin-codegen-version = "0.31.5" +smithy-kotlin-runtime-version = "1.1.6-SNAPSHOT" +smithy-kotlin-codegen-version = "0.31.6-SNAPSHOT" # codegen smithy-version = "1.47.0" diff --git a/tests/benchmarks/service-benchmarks/jvm/src/aws/sdk/kotlin/benchmarks/service/telemetry/BenchmarkTelemetryProvider.kt b/tests/benchmarks/service-benchmarks/jvm/src/aws/sdk/kotlin/benchmarks/service/telemetry/BenchmarkTelemetryProvider.kt index 5a031679b83..803458f6e11 100644 --- a/tests/benchmarks/service-benchmarks/jvm/src/aws/sdk/kotlin/benchmarks/service/telemetry/BenchmarkTelemetryProvider.kt +++ b/tests/benchmarks/service-benchmarks/jvm/src/aws/sdk/kotlin/benchmarks/service/telemetry/BenchmarkTelemetryProvider.kt @@ -6,12 +6,9 @@ package aws.sdk.kotlin.benchmarks.service.telemetry import aws.smithy.kotlin.runtime.ExperimentalApi import aws.smithy.kotlin.runtime.collections.Attributes -import aws.smithy.kotlin.runtime.telemetry.TelemetryProvider +import aws.smithy.kotlin.runtime.telemetry.AbstractTelemetryProvider import aws.smithy.kotlin.runtime.telemetry.context.Context -import aws.smithy.kotlin.runtime.telemetry.context.ContextManager -import aws.smithy.kotlin.runtime.telemetry.logging.LoggerProvider import aws.smithy.kotlin.runtime.telemetry.metrics.* -import aws.smithy.kotlin.runtime.telemetry.trace.TracerProvider private val capturedMetrics = mapOf( "smithy.client.call.attempt_overhead_duration" to "Overhead", @@ -23,45 +20,11 @@ private val capturedMetrics = mapOf( ) @ExperimentalApi -class BenchmarkTelemetryProvider(private val metricAggregator: MetricAggregator) : TelemetryProvider { - override val contextManager = ContextManager.None - override val loggerProvider = LoggerProvider.None - override val tracerProvider = TracerProvider.None - - override val meterProvider = object : MeterProvider { - override fun getOrCreateMeter(scope: String) = object : Meter { - override fun createUpDownCounter(name: String, units: String?, description: String?) = - NoOpUpDownCounter - - override fun createAsyncUpDownCounter( - name: String, - callback: LongUpDownCounterCallback, - units: String?, - description: String?, - ) = NoOpAsyncMeasurementHandle - - override fun createMonotonicCounter(name: String, units: String?, description: String?) = - NoOpMonotonicCounter - - override fun createLongHistogram(name: String, units: String?, description: String?) = - NoOpLongHistogram - +class BenchmarkTelemetryProvider(private val metricAggregator: MetricAggregator) : AbstractTelemetryProvider() { + override val meterProvider = object : AbstractMeterProvider() { + override fun getOrCreateMeter(scope: String) = object : AbstractMeter() { override fun createDoubleHistogram(name: String, units: String?, description: String?) = - capturedMetrics[name]?.let { BenchmarkDoubleHistogram(it, units) } ?: NoOpDoubleHistogram - - override fun createLongGauge( - name: String, - callback: LongGaugeCallback, - units: String?, - description: String?, - ) = NoOpAsyncMeasurementHandle - - override fun createDoubleGauge( - name: String, - callback: DoubleGaugeCallback, - units: String?, - description: String?, - ) = NoOpAsyncMeasurementHandle + capturedMetrics[name]?.let { BenchmarkDoubleHistogram(it, units) } ?: Histogram.DoubleNone } } @@ -92,23 +55,3 @@ class BenchmarkTelemetryProvider(private val metricAggregator: MetricAggregator) } } } - -private object NoOpAsyncMeasurementHandle : AsyncMeasurementHandle { - override fun stop() { } -} - -private object NoOpDoubleHistogram : DoubleHistogram { - override fun record(value: Double, attributes: Attributes, context: Context?) { } -} - -private object NoOpLongHistogram : LongHistogram { - override fun record(value: Long, attributes: Attributes, context: Context?) { } -} - -private object NoOpMonotonicCounter : MonotonicCounter { - override fun add(value: Long, attributes: Attributes, context: Context?) { } -} - -private object NoOpUpDownCounter : UpDownCounter { - override fun add(value: Long, attributes: Attributes, context: Context?) { } -}