-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Metricbeat] gcp: allow service metric prefix override (#26960)
- Loading branch information
Showing
8 changed files
with
168 additions
and
10 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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
// or more contributor license agreements. Licensed under the Elastic License; | ||
// you may not use this file except in compliance with the Elastic License. | ||
|
||
package metrics | ||
|
||
import "testing" | ||
|
||
var fakeMetricsConfig = []metricsConfig{ | ||
{"billing", "", []string{}, ""}, | ||
{"billing", "foobar/", []string{}, ""}, | ||
{"billing", "foobar", []string{}, ""}, | ||
} | ||
|
||
func Test_metricsConfig_AddPrefixTo(t *testing.T) { | ||
metric := "awesome/metric" | ||
tests := []struct { | ||
name string | ||
fields metricsConfig | ||
want string | ||
}{ | ||
{ | ||
name: "only service name", | ||
fields: fakeMetricsConfig[0], | ||
want: "billing.googleapis.com/" + metric, | ||
}, | ||
{ | ||
name: "service metric prefix override", | ||
fields: fakeMetricsConfig[1], | ||
want: "foobar/" + metric, | ||
}, | ||
{ | ||
name: "service metric prefix override (without trailing /)", | ||
fields: fakeMetricsConfig[2], | ||
want: "foobar/" + metric, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if got := tt.fields.AddPrefixTo(metric); got != tt.want { | ||
t.Errorf("metricsConfig.AddPrefixTo(%s) = %v, want %v", metric, got, tt.want) | ||
} | ||
}) | ||
} | ||
} |
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