Skip to content

Commit

Permalink
fix: partial aggregation handling in plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulguptajss committed Nov 25, 2024
1 parent db58b0b commit b558ae9
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 12 deletions.
10 changes: 5 additions & 5 deletions cmd/collectors/keyperf/keyperf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand All @@ -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")
}
Expand Down
4 changes: 4 additions & 0 deletions cmd/collectors/rest/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
4 changes: 4 additions & 0 deletions cmd/collectors/restperf/restperf.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions cmd/collectors/restperf/restperf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand All @@ -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")
}
Expand Down
5 changes: 4 additions & 1 deletion cmd/collectors/zapiperf/zapiperf.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
6 changes: 3 additions & 3 deletions cmd/collectors/zapiperf/zapiperf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand All @@ -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")
}
Expand Down

0 comments on commit b558ae9

Please sign in to comment.