nh support for metrics aggregation#7359
Conversation
Signed-off-by: Shvejan Mutheboyina <shvejan@amazon.com>
Signed-off-by: Shvejan <49836470+Shvejan@users.noreply.github.com>
Signed-off-by: Shvejan Mutheboyina <shvejan@amazon.com>
3b84c49 to
4740331
Compare
Signed-off-by: Friedrich Gonzalez <1517449+friedrichg@users.noreply.github.com>
Co-authored-by: Friedrich Gonzalez <1517449+friedrichg@users.noreply.github.com> Signed-off-by: Friedrich Gonzalez <1517449+friedrichg@users.noreply.github.com>
Signed-off-by: Shvejan <49836470+Shvejan@users.noreply.github.com>
| if isNative(h1) || isNative(h2) { | ||
| // Use schema/threshold from whichever side has native data (they should match). | ||
| if !isNative(h1) { | ||
| schema := h2.GetSchema() | ||
| h1.Schema = &schema | ||
| zt := h2.GetZeroThreshold() | ||
| h1.ZeroThreshold = &zt | ||
| } |
There was a problem hiding this comment.
I wonder if h1 and h2 always have the same schema.
There was a problem hiding this comment.
For this usecase for aggregating in SendSumOfHistograms, they should have the same schema as we aggregate the same histogram exposed by prometheus client go library.
yeya24
left a comment
There was a problem hiding this comment.
I'd like to also see an integration test that validates this code could by exposing both classic and NH metrics. Unit tests alone is not sufficient here
pkg/util/metrics_helper.go
Outdated
|
|
||
| // Sentinel span for native histograms with no observations. | ||
| // This is required to distinguish an empty native histogram from a classic histogram. | ||
| // This matches the prometheus behavior (histogram.go:1958) |
There was a problem hiding this comment.
Let's add the code link instead of just file and line.
| if isNative(h1) || isNative(h2) { | ||
| // Use schema/threshold from whichever side has native data (they should match). | ||
| if !isNative(h1) { | ||
| schema := h2.GetSchema() | ||
| h1.Schema = &schema | ||
| zt := h2.GetZeroThreshold() | ||
| h1.ZeroThreshold = &zt | ||
| } |
There was a problem hiding this comment.
For this usecase for aggregating in SendSumOfHistograms, they should have the same schema as we aggregate the same histogram exposed by prometheus client go library.
pkg/util/metrics_helper.go
Outdated
| // spans+deltas encoding used by the native histogram proto representation. | ||
| // | ||
| // This implementation is the same as makeBucketsFromMap from prometheus | ||
| // (histogram.go:2006) to include the gap-filling optimization |
pkg/util/metrics_helper_test.go
Outdated
| } | ||
|
|
||
| // TestHistogramData_AddHistogram_Multiple tests merging multiple histograms | ||
| func TestHistogramData_AddHistogram_Multiple(t *testing.T) { |
There was a problem hiding this comment.
Can we consolidate all TestHistogramData_AddHistogram tests? Seems they test similar things. Let's simplify the tests by consolidating them
| } | ||
|
|
||
| // TestMergeHistogram tests the mergeHistogram function | ||
| func TestMergeHistogram(t *testing.T) { |
There was a problem hiding this comment.
We need more coverage for this test case like merging native and classic or merging only classic ones
There was a problem hiding this comment.
added some unit tests to merge classic + native metrics
Signed-off-by: Shvejan Mutheboyina <shvejan@amazon.com>
Signed-off-by: Shvejan <49836470+Shvejan@users.noreply.github.com>
a554ea2 to
9d15b5c
Compare
| // Testing Native histogram fields | ||
| require.Equal(t, int32(3), h.GetSchema()) | ||
| require.NotNil(t, h.GetZeroThreshold()) | ||
| require.Equal(t, uint64(0), h.GetZeroCount()) |
There was a problem hiding this comment.
Can we validate the actual spans and buckets of native histogram? Validating these fields might not be useful
Signed-off-by: Shvejan Mutheboyina <shvejan@amazon.com>
9d15b5c to
c62f5c6
Compare
What this PR does:
makeBucketsFromMapandnativeHistogramMetricare copied from Prometheus implementation to follow the same patterns.Which issue(s) this PR fixes:
Fixes #6489
Checklist
CHANGELOG.mdupdated - the order of entries should be[CHANGE],[FEATURE],[ENHANCEMENT],[BUGFIX]