-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #838 from go-graphite/njpm/aliasByNode-name-tag
fix(functions): fix `"name"` tag overrides in various functions
- Loading branch information
Showing
19 changed files
with
87 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,94 +56,94 @@ func TestAliasByNode(t *testing.T) { | |
types.MakeMetricData("a.b.c.d.e", []float64{8, 2, 4}, 1, now32), | ||
}, | ||
}, | ||
[]*types.MetricData{types.MakeMetricData("2", []float64{8, 2, 4}, 1, now32)}, | ||
[]*types.MetricData{types.MakeMetricData("2", []float64{8, 2, 4}, 1, now32).SetNameTag("a.b.c.d.e")}, | ||
}, | ||
{ | ||
Target: "aliasByNode(aliasSub(a.b.c.d.e, '(.*)', '[email protected]'), 2)", | ||
M: map[parser.MetricRequest][]*types.MetricData{ | ||
{Metric: "a.b.c.d.e", From: 0, Until: 1}: {types.MakeMetricData("a.b.c.d.e", []float64{1, 2, 3, 4, 5}, 1, now32)}, | ||
}, | ||
Want: []*types.MetricData{types.MakeMetricData("2", []float64{1, 2, 3, 4, 5}, 1, now32)}, | ||
Want: []*types.MetricData{types.MakeMetricData("2", []float64{1, 2, 3, 4, 5}, 1, now32).SetNameTag("a.b.c.d.e")}, | ||
}, | ||
{ | ||
Target: "aliasByNode(aliasSub(transformNull(metric1.foo.bar.ba*, 0), 'baz', 'word'), 2, 3)", | ||
M: map[parser.MetricRequest][]*types.MetricData{ | ||
{Metric: "metric1.foo.bar.ba*", From: 0, Until: 1}: {types.MakeMetricData("metric1.foo.bar.baz", []float64{1, 2, 3, 4, 5}, 1, now32)}, | ||
}, | ||
Want: []*types.MetricData{types.MakeMetricData("bar.word", []float64{1, 2, 3, 4, 5}, 1, now32).SetTag("transformNull", "0")}, | ||
Want: []*types.MetricData{types.MakeMetricData("bar.word", []float64{1, 2, 3, 4, 5}, 1, now32).SetTag("transformNull", "0").SetNameTag("metric1.foo.bar.baz")}, | ||
}, | ||
{ | ||
Target: "aliasByNode(metric1.foo.bar.baz,1)", | ||
M: map[parser.MetricRequest][]*types.MetricData{ | ||
{Metric: "metric1.foo.bar.baz", From: 0, Until: 1}: {types.MakeMetricData("metric1.foo.bar.baz", []float64{1, 2, 3, 4, 5}, 1, now32)}, | ||
}, | ||
Want: []*types.MetricData{types.MakeMetricData("foo", []float64{1, 2, 3, 4, 5}, 1, now32)}, | ||
Want: []*types.MetricData{types.MakeMetricData("foo", []float64{1, 2, 3, 4, 5}, 1, now32).SetNameTag("metric1.foo.bar.baz")}, | ||
}, | ||
{ | ||
Target: "aliasByNode(metric1.foo.bar.baz,1,3)", | ||
M: map[parser.MetricRequest][]*types.MetricData{ | ||
{Metric: "metric1.foo.bar.baz", From: 0, Until: 1}: {types.MakeMetricData("metric1.foo.bar.baz", []float64{1, 2, 3, 4, 5}, 1, now32)}, | ||
}, | ||
Want: []*types.MetricData{types.MakeMetricData("foo.baz", | ||
[]float64{1, 2, 3, 4, 5}, 1, now32)}, | ||
[]float64{1, 2, 3, 4, 5}, 1, now32).SetNameTag("metric1.foo.bar.baz")}, | ||
}, | ||
{ | ||
Target: "aliasByNode(metric1.foo.bar.baz,1,-2)", | ||
M: map[parser.MetricRequest][]*types.MetricData{ | ||
{Metric: "metric1.foo.bar.baz", From: 0, Until: 1}: {types.MakeMetricData("metric1.foo.bar.baz", []float64{1, 2, 3, 4, 5}, 1, now32)}, | ||
}, | ||
Want: []*types.MetricData{types.MakeMetricData("foo.bar", | ||
[]float64{1, 2, 3, 4, 5}, 1, now32)}, | ||
[]float64{1, 2, 3, 4, 5}, 1, now32).SetNameTag("metric1.foo.bar.baz")}, | ||
}, | ||
{ | ||
Target: `aliasByTags(*, "foo")`, | ||
M: map[parser.MetricRequest][]*types.MetricData{ | ||
{Metric: "*", From: 0, Until: 1}: {types.MakeMetricData("metric1.foo.bar.baz;foo=bar;baz=bam", []float64{1, 2, 3, 4, 5}, 1, now32)}, | ||
}, | ||
Want: []*types.MetricData{types.MakeMetricData("bar", []float64{1, 2, 3, 4, 5}, 1, now32).SetTag("foo", "bar").SetTag("baz", "bam")}, | ||
Want: []*types.MetricData{types.MakeMetricData("bar", []float64{1, 2, 3, 4, 5}, 1, now32).SetTag("foo", "bar").SetTag("baz", "bam").SetNameTag("metric1.foo.bar.baz")}, | ||
}, | ||
{ | ||
Target: `aliasByTags(*, "foo", "name")`, | ||
M: map[parser.MetricRequest][]*types.MetricData{ | ||
{Metric: "*", From: 0, Until: 1}: {types.MakeMetricData("metric1;foo=bar", []float64{1, 2, 3, 4, 5}, 1, now32)}, | ||
}, | ||
Want: []*types.MetricData{types.MakeMetricData("bar.metric1", []float64{1, 2, 3, 4, 5}, 1, now32).SetTag("foo", "bar")}, | ||
Want: []*types.MetricData{types.MakeMetricData("bar.metric1", []float64{1, 2, 3, 4, 5}, 1, now32).SetTag("foo", "bar").SetNameTag("metric1")}, | ||
}, | ||
{ | ||
Target: `aliasByTags(*, 2, "blah", "foo", 1)`, | ||
M: map[parser.MetricRequest][]*types.MetricData{ | ||
{Metric: "*", From: 0, Until: 1}: {types.MakeMetricData("base.metric1;foo=bar;baz=bam", []float64{1, 2, 3, 4, 5}, 1, now32)}, | ||
}, | ||
Want: []*types.MetricData{types.MakeMetricData(".bar.metric1", []float64{1, 2, 3, 4, 5}, 1, now32).SetTag("foo", "bar").SetTag("baz", "bam")}, | ||
Want: []*types.MetricData{types.MakeMetricData(".bar.metric1", []float64{1, 2, 3, 4, 5}, 1, now32).SetTag("foo", "bar").SetTag("baz", "bam").SetNameTag("base.metric1")}, | ||
}, | ||
{ | ||
Target: `aliasByTags(*, 2, "baz", "foo", 1)`, | ||
M: map[parser.MetricRequest][]*types.MetricData{ | ||
{Metric: "*", From: 0, Until: 1}: {types.MakeMetricData("base.metric1;foo=bar;baz=bam", []float64{1, 2, 3, 4, 5}, 1, now32)}, | ||
}, | ||
Want: []*types.MetricData{types.MakeMetricData("bam.bar.metric1", []float64{1, 2, 3, 4, 5}, 1, now32).SetTag("foo", "bar").SetTag("baz", "bam")}, | ||
Want: []*types.MetricData{types.MakeMetricData("bam.bar.metric1", []float64{1, 2, 3, 4, 5}, 1, now32).SetTag("foo", "bar").SetTag("baz", "bam").SetNameTag("base.metric1")}, | ||
}, | ||
{ | ||
Target: `aliasByTags(perSecond(*), 'name')`, | ||
M: map[parser.MetricRequest][]*types.MetricData{ | ||
{Metric: "*", From: 0, Until: 1}: {types.MakeMetricData("base.metric1;foo=bar;baz=bam", []float64{1, 2, 3, 4, 5}, 1, now32)}, | ||
}, | ||
Want: []*types.MetricData{types.MakeMetricData("base.metric1", []float64{math.NaN(), 1, 1, 1, 1}, 1, now32).SetTag("foo", "bar").SetTag("baz", "bam").SetTag("perSecond", "1")}, | ||
Want: []*types.MetricData{types.MakeMetricData("base.metric1", []float64{math.NaN(), 1, 1, 1, 1}, 1, now32).SetTag("foo", "bar").SetTag("baz", "bam").SetTag("perSecond", "1").SetNameTag("base.metric1")}, | ||
}, | ||
{ | ||
Target: "aliasByNode(metric1.fo*.bar.baz,1,3)", | ||
M: map[parser.MetricRequest][]*types.MetricData{ | ||
{Metric: "metric1.fo*.bar.baz", From: 0, Until: 1}: {types.MakeMetricData("metric1.foo==.bar.baz", []float64{1, 2, 3, 4, 5}, 1, now32)}, | ||
}, | ||
Want: []*types.MetricData{types.MakeMetricData("foo==.baz", | ||
[]float64{1, 2, 3, 4, 5}, 1, now32)}, | ||
[]float64{1, 2, 3, 4, 5}, 1, now32).SetNameTag("metric1.foo==.bar.baz")}, | ||
}, | ||
{ | ||
Target: `aliasByTags(*, 2, "baz", "foo", 1)`, | ||
M: map[parser.MetricRequest][]*types.MetricData{ | ||
{Metric: "*", From: 0, Until: 1}: {types.MakeMetricData("base.metric1;foo=bar=;baz=bam==", []float64{1, 2, 3, 4, 5}, 1, now32)}, | ||
}, | ||
Want: []*types.MetricData{types.MakeMetricData("bam==.bar=.metric1", []float64{1, 2, 3, 4, 5}, 1, now32).SetTag("foo", "bar=").SetTag("baz", "bam==")}, | ||
Want: []*types.MetricData{types.MakeMetricData("bam==.bar=.metric1", []float64{1, 2, 3, 4, 5}, 1, now32).SetTag("foo", "bar=").SetTag("baz", "bam==").SetNameTag("base.metric1")}, | ||
}, | ||
// extract nodes with sumSeries | ||
{ | ||
|
@@ -155,7 +155,7 @@ func TestAliasByNode(t *testing.T) { | |
types.MakeMetricData("metric.c2.b", []float64{3, math.NaN(), 4, 5, 6, math.NaN()}, 1, now32), | ||
}, | ||
}, | ||
Want: []*types.MetricData{types.MakeMetricData("{a,b}*.b", []float64{6, math.NaN(), 9, 8, 15, 11}, 1, now32).SetTag("aggregatedBy", "sum")}, | ||
Want: []*types.MetricData{types.MakeMetricData("{a,b}*.b", []float64{6, math.NaN(), 9, 8, 15, 11}, 1, now32).SetTag("aggregatedBy", "sum").SetNameTag("metric.{a,b}*.b")}, | ||
}, | ||
// extract tags from seriesByTag | ||
{ | ||
|
@@ -170,7 +170,7 @@ func TestAliasByNode(t *testing.T) { | |
}, | ||
// Want: []*types.MetricData{types.MakeMetricData("value____.metric", []float64{6, math.NaN(), 9, 8, 15, 11}, 1, now32)}, | ||
Want: []*types.MetricData{ | ||
types.MakeMetricData("value21.metric", []float64{6, math.NaN(), 9, 8, 15, 11}, 1, now32).SetTag("aggregatedBy", "sum").SetTag("tag2", "value21")}, | ||
types.MakeMetricData("value21.metric", []float64{6, math.NaN(), 9, 8, 15, 11}, 1, now32).SetTag("aggregatedBy", "sum").SetTag("tag2", "value21").SetNameTag("metric")}, | ||
}, | ||
// TODO msaf1980: tests with extractTagsFromArgs = true | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.