Skip to content

Commit

Permalink
chore: refactor service benchmark telemetry provider to use new abstr…
Browse files Browse the repository at this point in the history
…actions (awslabs#1291)
  • Loading branch information
ianbotsf authored May 1, 2024
1 parent 7e5ae40 commit 6181ecc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 64 deletions.
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.2.1"
smithy-kotlin-codegen-version = "0.32.1"
smithy-kotlin-runtime-version = "1.2.2"
smithy-kotlin-codegen-version = "0.32.2"

# codegen
smithy-version = "1.47.0"
Expand Down
5 changes: 5 additions & 0 deletions services/s3/e2eTest/src/S3TestUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import aws.sdk.kotlin.services.s3.model.LifecycleRule
import aws.sdk.kotlin.services.s3.model.LifecycleRuleFilter
import aws.sdk.kotlin.services.s3.paginators.listObjectsV2Paginated
import aws.sdk.kotlin.services.s3.waiters.waitUntilBucketExists
import aws.sdk.kotlin.services.s3.waiters.waitUntilBucketNotExists
import aws.sdk.kotlin.services.s3control.*
import aws.sdk.kotlin.services.s3control.model.*
import aws.sdk.kotlin.services.sts.StsClient
Expand Down Expand Up @@ -159,6 +160,10 @@ object S3TestUtils {
jobs.joinAll()

client.deleteBucket { bucket = bucketName }

client.waitUntilBucketNotExists {
bucket = bucketName
}
} catch (ex: Exception) {
println("Failed to delete bucket: $bucketName")
throw ex
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
}
}

Expand Down Expand Up @@ -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?) { }
}

0 comments on commit 6181ecc

Please sign in to comment.