From aa77d9c351d5173770a31a62583590aa64ab5c36 Mon Sep 17 00:00:00 2001 From: Tyler Burdsall Date: Wed, 20 Mar 2024 16:21:13 -0700 Subject: [PATCH] chore: expose ability to switch distribution mode for top-level consumers creating a ConfiguredMetrics object --- .../src/main/kotlin/goodmetrics/MetricsSetups.kt | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/kotlin/goodmetrics/src/main/kotlin/goodmetrics/MetricsSetups.kt b/kotlin/goodmetrics/src/main/kotlin/goodmetrics/MetricsSetups.kt index 2aba21b..7a673be 100644 --- a/kotlin/goodmetrics/src/main/kotlin/goodmetrics/MetricsSetups.kt +++ b/kotlin/goodmetrics/src/main/kotlin/goodmetrics/MetricsSetups.kt @@ -96,6 +96,7 @@ class MetricsSetups private constructor() { * So I'll default the special lightstep configuration to use gzip compression. You can disable this if you want. */ compressionMode: CompressionMode = CompressionMode.Gzip, + distributionMode: DistributionMode = DistributionMode.Histogram, ): ConfiguredMetrics { val client = opentelemetryClient( lightstepAccessToken, @@ -119,7 +120,8 @@ class MetricsSetups private constructor() { preaggregatedBatchMaxMetricsCount, preaggregatedBatchMaxAge, onSendUnary, - onSendPreaggregated + onSendPreaggregated, + distributionMode, ) } @@ -196,6 +198,7 @@ class MetricsSetups private constructor() { */ logRawPayload: (ResourceMetrics) -> Unit = {}, compressionMode: CompressionMode = CompressionMode.Gzip, + distributionMode: DistributionMode = DistributionMode.Histogram, ): ConfiguredMetrics { val client = opentelemetryClient( accessToken, @@ -219,7 +222,8 @@ class MetricsSetups private constructor() { preaggregatedBatchMaxMetricsCount, preaggregatedBatchMaxAge, onSendUnary, - onSendPreaggregated + onSendPreaggregated, + distributionMode, ) } @@ -276,10 +280,11 @@ class MetricsSetups private constructor() { preaggregatedBatchMaxMetricsCount: Int, preaggregatedBatchMaxAge: Duration, onSendUnary: (List) -> Unit, - onSendPreaggregated: (List) -> Unit + onSendPreaggregated: (List) -> Unit, + distributionMode: DistributionMode, ): ConfiguredMetrics { val unarySink = configureBatchedUnaryOtlpSink(unaryBatchSizeMaxMetricsCount, unaryBatchMaxAge, client, logError, onSendUnary) - val preaggregatedSink = configureBatchedPreaggregatedOtlpSink(aggregationWidth, preaggregatedBatchMaxMetricsCount, preaggregatedBatchMaxAge, client, logError, onSendPreaggregated) + val preaggregatedSink = configureBatchedPreaggregatedOtlpSink(aggregationWidth, preaggregatedBatchMaxMetricsCount, preaggregatedBatchMaxAge, client, logError, onSendPreaggregated, distributionMode) val unaryFactory = MetricsFactory( sink = unarySink, @@ -363,8 +368,7 @@ class MetricsSetups private constructor() { client: OpentelemetryClient, logError: (message: String, exception: Exception) -> Unit, onSendPreaggregated: (List) -> Unit, - // By default, use Histogram distribution mode since ExponentialHistograms are not frequently used - distributionMode: DistributionMode = DistributionMode.Histogram, + distributionMode: DistributionMode, ): Aggregator { val sink = Aggregator(aggregationWidth = aggregationWidth, distributionMode = distributionMode) val batcher = Batcher(