Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: expose ability to switch distribution mode for top-level consumers creating a ConfiguredMetrics object #40

Merged
merged 1 commit into from
Mar 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions kotlin/goodmetrics/src/main/kotlin/goodmetrics/MetricsSetups.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -119,7 +120,8 @@ class MetricsSetups private constructor() {
preaggregatedBatchMaxMetricsCount,
preaggregatedBatchMaxAge,
onSendUnary,
onSendPreaggregated
onSendPreaggregated,
distributionMode,
)
}

Expand Down Expand Up @@ -196,6 +198,7 @@ class MetricsSetups private constructor() {
*/
logRawPayload: (ResourceMetrics) -> Unit = {},
compressionMode: CompressionMode = CompressionMode.Gzip,
distributionMode: DistributionMode = DistributionMode.Histogram,
): ConfiguredMetrics {
val client = opentelemetryClient(
accessToken,
Expand All @@ -219,7 +222,8 @@ class MetricsSetups private constructor() {
preaggregatedBatchMaxMetricsCount,
preaggregatedBatchMaxAge,
onSendUnary,
onSendPreaggregated
onSendPreaggregated,
distributionMode,
)
}

Expand Down Expand Up @@ -276,10 +280,11 @@ class MetricsSetups private constructor() {
preaggregatedBatchMaxMetricsCount: Int,
preaggregatedBatchMaxAge: Duration,
onSendUnary: (List<Metrics>) -> Unit,
onSendPreaggregated: (List<AggregatedBatch>) -> Unit
onSendPreaggregated: (List<AggregatedBatch>) -> 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,
Expand Down Expand Up @@ -363,8 +368,7 @@ class MetricsSetups private constructor() {
client: OpentelemetryClient,
logError: (message: String, exception: Exception) -> Unit,
onSendPreaggregated: (List<AggregatedBatch>) -> 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(
Expand Down
Loading