Skip to content

Commit

Permalink
fix name tag for movingMedian
Browse files Browse the repository at this point in the history
  • Loading branch information
npazosmendez committed Jul 31, 2024
1 parent 7b0616b commit 8b60211
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion expr/functions/movingMedian/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ func (f *movingMedian) Do(ctx context.Context, eval interfaces.Evaluator, e pars

result := make([]*types.MetricData, len(arg))
for n, a := range arg {
r := a.CopyName("movingMedian(" + a.Name + "," + argstr + ")")
r := a.CopyLink()
r.Name = "movingMedian(" + a.Name + "," + argstr + ")"

if windowSize == 0 {
if *f.config.ReturnNaNsIfStepMismatch {
Expand Down
10 changes: 5 additions & 5 deletions expr/functions/movingMedian/function_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,39 +34,39 @@ func TestMovingMedian(t *testing.T) {
{Metric: "metric1", From: 0, Until: 1}: {types.MakeMetricData("metric1", []float64{1, 1, 1, 1, 2, 2, 2, 4, 6, 4, 6, 8}, 1, now32)},
},
[]*types.MetricData{types.MakeMetricData("movingMedian(metric1,4)", []float64{math.NaN(), math.NaN(), math.NaN(), 1, 1, 1.5, 2, 2, 3, 4, 5, 6},
1, 0).SetTag("movingMedian", "4").SetNameTag("movingMedian(metric1,4)")}, // StartTime = from
1, 0).SetTag("movingMedian", "4").SetNameTag("metric1")}, // StartTime = from
},
{
"movingMedian(metric1,5)",
map[parser.MetricRequest][]*types.MetricData{
{Metric: "metric1", From: 0, Until: 1}: {types.MakeMetricData("metric1", []float64{1, 1, 1, 1, 2, 2, 2, 4, 6, 4, 6, 8, 1, 2, math.NaN()}, 1, now32)},
},
[]*types.MetricData{types.MakeMetricData("movingMedian(metric1,5)", []float64{math.NaN(), math.NaN(), math.NaN(), math.NaN(), 1, 1, 2, 2, 2, 4, 4, 6, 6, 4, 2},
1, 0).SetTag("movingMedian", "5").SetNameTag("movingMedian(metric1,5)")}, // StartTime = from
1, 0).SetTag("movingMedian", "5").SetNameTag("metric1")}, // StartTime = from
},
{
"movingMedian(metric1,\"1s\")",
map[parser.MetricRequest][]*types.MetricData{
{Metric: "metric1", From: -1, Until: 1}: {types.MakeMetricData("metric1", []float64{1, 1, 1, 1, 1, 2, 2, 2, 4, 6, 4, 6, 8, 1, 2, 0}, 1, now32)},
},
[]*types.MetricData{types.MakeMetricData("movingMedian(metric1,'1s')", []float64{1, 1, 1, 1, 2, 2, 2, 4, 6, 4, 6, 8, 1, 2, 0},
1, 0).SetTag("movingMedian", "'1s'").SetNameTag("movingMedian(metric1,'1s')")}, // StartTime = from
1, 0).SetTag("movingMedian", "'1s'").SetNameTag("metric1")}, // StartTime = from
},
{
"movingMedian(metric1,\"3s\")",
map[parser.MetricRequest][]*types.MetricData{
{Metric: "metric1", From: -3, Until: 1}: {types.MakeMetricData("metric1", []float64{0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 4, 6, 4, 6, 8, 1, 2}, 1, now32)},
},
[]*types.MetricData{types.MakeMetricData("movingMedian(metric1,'3s')", []float64{0, 1, 1, 1, 1, 2, 2, 2, 4, 4, 6, 6, 6, 2},
1, 0).SetTag("movingMedian", "'3s'").SetNameTag("movingMedian(metric1,'3s')")}, // StartTime = from
1, 0).SetTag("movingMedian", "'3s'").SetNameTag("metric1")}, // StartTime = from
},
{
"movingMedian(metric1,\"5s\")",
map[parser.MetricRequest][]*types.MetricData{
{Metric: "metric1", From: -5, Until: 1}: {types.MakeMetricData("metric1", []float64{1, 2, 3}, 10, now32)}, // step > windowSize
},
[]*types.MetricData{types.MakeMetricData("movingMedian(metric1,'5s')", []float64{math.NaN(), math.NaN(), math.NaN()},
10, now32).SetTag("movingMedian", "'5s'").SetNameTag("movingMedian(metric1,'5s')")}, // StartTime = from
10, now32).SetTag("movingMedian", "'5s'").SetNameTag("metric1")}, // StartTime = from
},
}

Expand Down

0 comments on commit 8b60211

Please sign in to comment.