From b558ae96a71e394af61dbfe9f9d3d3bda59caa62 Mon Sep 17 00:00:00 2001 From: rahulguptajss Date: Mon, 25 Nov 2024 18:06:55 +0530 Subject: [PATCH] fix: partial aggregation handling in plugins --- cmd/collectors/keyperf/keyperf_test.go | 10 +++++----- cmd/collectors/rest/rest.go | 4 ++++ cmd/collectors/restperf/restperf.go | 4 ++++ cmd/collectors/restperf/restperf_test.go | 6 +++--- cmd/collectors/zapiperf/zapiperf.go | 5 ++++- cmd/collectors/zapiperf/zapiperf_test.go | 6 +++--- 6 files changed, 23 insertions(+), 12 deletions(-) diff --git a/cmd/collectors/keyperf/keyperf_test.go b/cmd/collectors/keyperf/keyperf_test.go index c534edc54..42b08ccd9 100644 --- a/cmd/collectors/keyperf/keyperf_test.go +++ b/cmd/collectors/keyperf/keyperf_test.go @@ -32,11 +32,11 @@ func TestPartialAggregationSequence(t *testing.T) { // Partial Poll t.Log("Running Partial Poll") - kp.testPollInstanceAndDataWithMetrics(t, "testdata/partialAggregation/volume-poll-partial.json", 4, 36) + kp.testPollInstanceAndDataWithMetrics(t, "testdata/partialAggregation/volume-poll-partial.json", 3, 36) // Partial Poll 2 t.Log("Running Partial Poll 2") - kp.testPollInstanceAndDataWithMetrics(t, "testdata/partialAggregation/volume-poll-partial.json", 4, 36) + kp.testPollInstanceAndDataWithMetrics(t, "testdata/partialAggregation/volume-poll-partial.json", 3, 36) if t.Failed() { t.Fatal("Partial Poll 2 failed") } @@ -49,15 +49,15 @@ func TestPartialAggregationSequence(t *testing.T) { } // Second Complete Poll After Partial - t.Log("Running First Complete Poll After Partial") + t.Log("Running Second Complete Poll After Partial") kp.testPollInstanceAndDataWithMetrics(t, "testdata/partialAggregation/volume-poll-3.json", 4, 48) if t.Failed() { - t.Fatal("First Complete Poll After Partial failed") + t.Fatal("Second Complete Poll After Partial failed") } // Partial Poll 3 t.Log("Running Partial Poll 3") - kp.testPollInstanceAndDataWithMetrics(t, "testdata/partialAggregation/volume-poll-partial-2.json", 4, 36) + kp.testPollInstanceAndDataWithMetrics(t, "testdata/partialAggregation/volume-poll-partial-2.json", 3, 36) if t.Failed() { t.Fatal("Partial Poll 3 failed") } diff --git a/cmd/collectors/rest/rest.go b/cmd/collectors/rest/rest.go index 85e7cf06a..d694f6ba5 100644 --- a/cmd/collectors/rest/rest.go +++ b/cmd/collectors/rest/rest.go @@ -601,7 +601,11 @@ func (r *Rest) HandleResults(mat *matrix.Matrix, result []gjson.Result, prop *pr status := instanceData.Get("statistics.status") if status.Exists() && status.ClonedString() != "ok" { instance.SetPartial(true) + instance.SetExportable(false) numPartials++ + } else { + instance.SetPartial(false) + instance.SetExportable(true) } } diff --git a/cmd/collectors/restperf/restperf.go b/cmd/collectors/restperf/restperf.go index 6d26e5528..48a24b9c6 100644 --- a/cmd/collectors/restperf/restperf.go +++ b/cmd/collectors/restperf/restperf.go @@ -914,7 +914,11 @@ func (r *RestPerf) pollData(startTime time.Time, perfRecords []rest.PerfRecord) // check for partial aggregation if instanceData.Get("aggregation.complete").ClonedString() == "false" { instance.SetPartial(true) + instance.SetExportable(false) numPartials++ + } else { + instance.SetPartial(false) + instance.SetExportable(true) } for label, display := range r.Prop.InstanceLabels { diff --git a/cmd/collectors/restperf/restperf_test.go b/cmd/collectors/restperf/restperf_test.go index 19632078d..e0b47196e 100644 --- a/cmd/collectors/restperf/restperf_test.go +++ b/cmd/collectors/restperf/restperf_test.go @@ -315,11 +315,11 @@ func TestPartialAggregationSequence(t *testing.T) { // Partial Poll t.Log("Running Partial Poll") - r.testPollInstanceAndDataWithMetrics(t, "testdata/partialAggregation/qos-poll-data-2.json", 2, 0) + r.testPollInstanceAndDataWithMetrics(t, "testdata/partialAggregation/qos-poll-data-2.json", 0, 0) // Partial Poll 2 t.Log("Running Partial Poll 2") - r.testPollInstanceAndDataWithMetrics(t, "testdata/partialAggregation/qos-poll-data-2.json", 2, 0) + r.testPollInstanceAndDataWithMetrics(t, "testdata/partialAggregation/qos-poll-data-2.json", 0, 0) if t.Failed() { t.Fatal("Partial Poll 2 failed") } @@ -340,7 +340,7 @@ func TestPartialAggregationSequence(t *testing.T) { // Partial Poll 3 t.Log("Running Partial Poll 3") - r.testPollInstanceAndDataWithMetrics(t, "testdata/partialAggregation/qos-poll-data-2.json", 2, 0) + r.testPollInstanceAndDataWithMetrics(t, "testdata/partialAggregation/qos-poll-data-2.json", 0, 0) if t.Failed() { t.Fatal("Partial Poll 3 failed") } diff --git a/cmd/collectors/zapiperf/zapiperf.go b/cmd/collectors/zapiperf/zapiperf.go index 4472ca1b5..9c25a8640 100644 --- a/cmd/collectors/zapiperf/zapiperf.go +++ b/cmd/collectors/zapiperf/zapiperf.go @@ -596,10 +596,13 @@ func (z *ZapiPerf) PollData() (map[string]*matrix.Matrix, error) { if z.isPartialAggregation(i) { instance.SetPartial(true) + instance.SetExportable(false) numPartials++ + } else { + instance.SetPartial(false) + instance.SetExportable(true) } - instance.SetExportable(true) counters := i.GetChildS("counters") if counters == nil { z.Logger.Debug("Skip instance key, no data counters", slog.String("key", key)) diff --git a/cmd/collectors/zapiperf/zapiperf_test.go b/cmd/collectors/zapiperf/zapiperf_test.go index 61ae5dc0c..12a3f1114 100644 --- a/cmd/collectors/zapiperf/zapiperf_test.go +++ b/cmd/collectors/zapiperf/zapiperf_test.go @@ -105,14 +105,14 @@ func TestPartialAggregationSequence(t *testing.T) { // Partial Poll t.Log("Running Partial Poll") - z.testPollInstanceAndDataWithMetrics(t, "testdata/partialAggregation/pollData2.xml", 2, 0) + z.testPollInstanceAndDataWithMetrics(t, "testdata/partialAggregation/pollData2.xml", 0, 0) if t.Failed() { t.Fatal("Partial Poll failed") } // Partial Poll 2 t.Log("Running Partial Poll 2") - z.testPollInstanceAndDataWithMetrics(t, "testdata/partialAggregation/pollData2.xml", 2, 0) + z.testPollInstanceAndDataWithMetrics(t, "testdata/partialAggregation/pollData2.xml", 0, 0) if t.Failed() { t.Fatal("Partial Poll 2 failed") } @@ -133,7 +133,7 @@ func TestPartialAggregationSequence(t *testing.T) { // Partial Poll 3 t.Log("Running Partial Poll 3") - z.testPollInstanceAndDataWithMetrics(t, "testdata/partialAggregation/pollData2.xml", 2, 0) + z.testPollInstanceAndDataWithMetrics(t, "testdata/partialAggregation/pollData2.xml", 0, 0) if t.Failed() { t.Fatal("Partial Poll 3 failed") }