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

redact host and instance tags for internal metrics #237

Merged
merged 2 commits into from
Oct 27, 2023
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
6 changes: 5 additions & 1 deletion m3/reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ const (
DefaultHistogramBucketIDName = "bucketid"
// DefaultHistogramBucketName is the default histogram bucket name tag name
DefaultHistogramBucketName = "bucket"
// DefaultTagRedactValue is the default tag value to use when redacting
DefaultTagRedactValue = "global"
// DefaultHistogramBucketTagPrecision is the default
// precision to use when formatting the metric tag
// with the histogram bucket bound values.
Expand Down Expand Up @@ -287,7 +289,9 @@ func NewReporter(opts Options) (Reporter, error) {
}

internalTags := map[string]string{
"version": tally.Version,
"version": tally.Version,
"host": DefaultTagRedactValue,
"instance": DefaultTagRedactValue,
}

for k, v := range opts.InternalTags {
Expand Down
7 changes: 5 additions & 2 deletions m3/reporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -599,15 +599,18 @@ func TestReporterCommmonTagsInternal(t *testing.T) {
for k, v := range internalTags {
require.True(t, tagEquals(metric.Tags, k, v))
}

// The following tags should be redacted.
require.True(t, tagEquals(metric.Tags, "host", DefaultTagRedactValue))
require.True(t, tagEquals(metric.Tags, "instance", DefaultTagRedactValue))
} else {
require.Equal(t, "testCounter1", metric.Name)
require.False(t, tagIncluded(metric.Tags, "internal1"))
require.False(t, tagIncluded(metric.Tags, "internal2"))
}

// The following tags should not be present as part of the individual metrics
// as they are common tags.
require.False(t, tagIncluded(metric.Tags, "host"))
require.False(t, tagIncluded(metric.Tags, "instance"))
require.False(t, tagIncluded(metric.Tags, "service"))
}
require.Equal(t, internalMetrics, numInternalMetricsActual)
Expand Down
Loading