From ba6b66dc588a18032f813f83a41ac8801b9cacaf Mon Sep 17 00:00:00 2001 From: v-zhuravlev Date: Mon, 20 Oct 2025 15:54:34 +0300 Subject: [PATCH 1/3] fix(signal): No longer aggregates histogram signals after histogram_quantile() as it is pointless aggregation. Aggregation before applying histogram_quantile() is kept and works as expected --- common-lib/CHANGELOG.md | 4 ++++ common-lib/common/signal/test_histogram.libsonnet | 6 +++--- common-lib/common/signal/utils.libsonnet | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/common-lib/CHANGELOG.md b/common-lib/CHANGELOG.md index 9774efde5..12cef842f 100644 --- a/common-lib/CHANGELOG.md +++ b/common-lib/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.4.3 + +- [Signal] fix: No longer aggregates histogram signals after histogram_quantile() as it is pointless aggregation. Aggregation before applying histogram_quantile() is kept and works as expected. + # 0.4.0 - [Signal] Add defaultSignalSource param to set default signal source. diff --git a/common-lib/common/signal/test_histogram.libsonnet b/common-lib/common/signal/test_histogram.libsonnet index f9000cc0a..a7d969c60 100644 --- a/common-lib/common/signal/test_histogram.libsonnet +++ b/common-lib/common/signal/test_histogram.libsonnet @@ -34,7 +34,7 @@ local m1 = signal.init( }, testExpression: { actual: raw.expr, - expect: 'avg by (job) (\n histogram_quantile(0.95, sum(rate(apiserver_request_duration_seconds_bucket{job="abc",job=~"$job",instance=~"$instance"}[10m])) by (le,job))\n)', + expect: 'histogram_quantile(0.95, sum(rate(apiserver_request_duration_seconds_bucket{job="abc",job=~"$job",instance=~"$instance"}[10m])) by (le,job))', }, }), }, @@ -92,11 +92,11 @@ local m1 = signal.init( testResult: test.suite({ testDefaultQuantile: { actual: customHistogram.asTarget().expr, - expect: 'avg by (job,handler) (\n histogram_quantile(0.99, sum(rate(http_request_duration_seconds_bucket{job="abc",job=~"$job",instance=~"$instance"}[10m])) by (le,job,handler))\n)', + expect: 'histogram_quantile(0.99, sum(rate(http_request_duration_seconds_bucket{job="abc",job=~"$job",instance=~"$instance"}[10m])) by (le,job,handler))', }, testCustomQuantile: { actual: customHistogram.withQuantile(quantile=0.50).asTarget().expr, - expect: 'avg by (job,handler) (\n histogram_quantile(0.50, sum(rate(http_request_duration_seconds_bucket{job="abc",job=~"$job",instance=~"$instance"}[10m])) by (le,job,handler))\n)', + expect: 'histogram_quantile(0.50, sum(rate(http_request_duration_seconds_bucket{job="abc",job=~"$job",instance=~"$instance"}[10m])) by (le,job,handler))', }, }), }, diff --git a/common-lib/common/signal/utils.libsonnet b/common-lib/common/signal/utils.libsonnet index 3102ea976..53836406c 100644 --- a/common-lib/common/signal/utils.libsonnet +++ b/common-lib/common/signal/utils.libsonnet @@ -4,7 +4,7 @@ // additional templates to wrap base expression functionTemplates:: ( - if aggLevel != 'none' && (type == 'counter' || type == 'gauge' || type == 'histogram' || type == 'info') + if aggLevel != 'none' && (type == 'counter' || type == 'gauge' || type == 'info') then [ ['%(aggFunction)s by (%(agg)s) (', ')'], From 91d5c1dd72a863b8c5207880668ba2039cd9691d Mon Sep 17 00:00:00 2001 From: Emily <1282515+Dasomeone@users.noreply.github.com> Date: Thu, 23 Oct 2025 16:42:19 +0200 Subject: [PATCH 2/3] Update common-lib/CHANGELOG.md --- common-lib/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common-lib/CHANGELOG.md b/common-lib/CHANGELOG.md index 12cef842f..b6b781f74 100644 --- a/common-lib/CHANGELOG.md +++ b/common-lib/CHANGELOG.md @@ -1,4 +1,4 @@ -# 0.4.3 +# 0.4.1 - [Signal] fix: No longer aggregates histogram signals after histogram_quantile() as it is pointless aggregation. Aggregation before applying histogram_quantile() is kept and works as expected. From 388a63a7db6f12efbe91f1c2e01be28cf185bfa7 Mon Sep 17 00:00:00 2001 From: Emily <1282515+Dasomeone@users.noreply.github.com> Date: Thu, 23 Oct 2025 16:51:17 +0200 Subject: [PATCH 3/3] Apply suggestion from @Dasomeone --- common-lib/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common-lib/CHANGELOG.md b/common-lib/CHANGELOG.md index b6b781f74..12cef842f 100644 --- a/common-lib/CHANGELOG.md +++ b/common-lib/CHANGELOG.md @@ -1,4 +1,4 @@ -# 0.4.1 +# 0.4.3 - [Signal] fix: No longer aggregates histogram signals after histogram_quantile() as it is pointless aggregation. Aggregation before applying histogram_quantile() is kept and works as expected.