Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SVLS-6016] Filter high cardinality tags from the metric agent #31440

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/serverless-init/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ func setupMetricAgent(tags map[string]string, tagger tagger.Component) *metrics.
SketchesBucketOffset: time.Second * 0,
Tagger: tagger,
}
// we don't want to add the container_id tag to metrics for cardinality reasons
tags = serverlessInitTag.WithoutContainerID(tags)
// we don't want to add certain tags to metrics for cardinality reasons
tags = serverlessInitTag.WithoutHighCardinalityTags(tags)
metricAgent.Start(5*time.Second, &metrics.MetricConfig{}, &metrics.MetricDogStatsD{})
metricAgent.SetExtraTags(serverlessTag.MapToArray(tags))
return metricAgent
Expand Down
10 changes: 7 additions & 3 deletions cmd/serverless-init/tag/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,15 @@ func GetBaseTagsMapWithMetadata(metadata map[string]string, versionMode string)
return tagsMap
}

// WithoutContainerID creates a new tag map without the `container_id` tag
func WithoutContainerID(tags map[string]string) map[string]string {
// WithoutHihCardinalityTags creates a new tag map without high cardinality tags we use on traces
func WithoutHighCardinalityTags(tags map[string]string) map[string]string {
newTags := make(map[string]string, len(tags))
for k, v := range tags {
if k != "container_id" {
if k != "container_id" &&
k != "gcr.container_id" &&
k != "gcrfx.container_id" &&
k != "replica_name" &&
k != "aca.replica.name" {
duncanpharvey marked this conversation as resolved.
Show resolved Hide resolved
newTags[k] = v
}
}
Expand Down
6 changes: 6 additions & 0 deletions cmd/serverless-init/tag/tag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,9 @@ func TestDdTags(t *testing.T) {
assert.Equal(t, "value5", mergedTags["key5"])
assert.Equal(t, "value6", mergedTags["key6"])
}

func TestWithoutHighCardinalityTags(t *testing.T) {
tags := map[string]string{"key1": "value1", "key2": "value2", "container_id": "abc", "replica_name": "abc"}
filteredTags := WithoutHighCardinalityTags(tags)
assert.Equal(t, map[string]string{"key1": "value1", "key2": "value2"}, filteredTags)
}
Loading