-
Notifications
You must be signed in to change notification settings - Fork 482
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
Work around high cardinality metrics from otelcol receivers #4769
Merged
ptodev
merged 27 commits into
grafana:main
from
glindstedt:otel-metric-cardinality-workaround
Sep 1, 2023
Merged
Changes from 6 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
a1fc6a6
Work around high cardinality metrics from otelcol receivers
glindstedt 5db2161
Update CHANGELOG.md
glindstedt f2bd40f
Merge branch 'main' into otel-metric-cardinality-workaround
glindstedt 2302c89
Add `debug_metrics` configuration block to otelcol components
glindstedt 20a5252
Revert "Update CHANGELOG.md"
glindstedt 53c3d73
fix nilpointer
glindstedt 4f5c09e
refactor to not use pointers for debug_metrics block
glindstedt a06d0b1
Update component/otelcol/internal/views/views.go
glindstedt 97a7bd2
add docs
glindstedt 8be5079
fix lint
glindstedt de21b71
add debug_metrics into some component tests
glindstedt d4fe925
Merge remote-tracking branch 'origin/main' into otel-metric-cardinali…
glindstedt 8f9c91e
Merge branch 'main' into otel-metric-cardinality-workaround
glindstedt 583fbc1
align shared docs references with changes made in #4921
glindstedt 387a6fd
Update docs/sources/flow/reference/components/otelcol.exporter.jaeger.md
glindstedt bdbd420
Update docs/sources/flow/reference/components/otelcol.exporter.loadba…
glindstedt 1474782
Update docs/sources/flow/reference/components/otelcol.exporter.loggin…
glindstedt ad4771b
Update docs/sources/flow/reference/components/otelcol.exporter.otlp.md
glindstedt 929ce4b
Update docs/sources/flow/reference/components/otelcol.exporter.otlpht…
glindstedt 778ec08
Update docs/sources/flow/reference/components/otelcol.receiver.jaeger.md
glindstedt e793d65
Update docs/sources/flow/reference/components/otelcol.receiver.opence…
glindstedt 6d04ee7
Update docs/sources/flow/reference/components/otelcol.receiver.otlp.md
glindstedt d99b62d
Update docs/sources/flow/reference/components/otelcol.receiver.zipkin.md
glindstedt 93534fe
Update docs/sources/shared/flow/reference/components/otelcol-debug-me…
glindstedt a95aafd
Update docs/sources/shared/flow/reference/components/otelcol-debug-me…
glindstedt 93fbef2
Update docs/sources/shared/flow/reference/components/otelcol-debug-me…
glindstedt bdc9fa2
Update CHANGELOG.md
glindstedt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package otelcol | ||
|
||
// DebugMetricsArguments configures internal metrics of the components | ||
type DebugMetricsArguments struct { | ||
DisableHighCardinalityMetrics bool `river:"disable_high_cardinality_metrics,attr,optional"` | ||
} | ||
|
||
// DefaultDebugMetricsArguments holds default settings for DebugMetricsArguments. | ||
var DefaultDebugMetricsArguments = DebugMetricsArguments{ | ||
DisableHighCardinalityMetrics: false, | ||
} | ||
|
||
// SetToDefault implements river.Defaulter. | ||
func (args *DebugMetricsArguments) SetToDefault() { | ||
*args = DefaultDebugMetricsArguments | ||
} |
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
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,53 @@ | ||
package views | ||
|
||
import ( | ||
semconv "go.opentelemetry.io/collector/semconv/v1.13.0" | ||
"go.opentelemetry.io/otel/attribute" | ||
"go.opentelemetry.io/otel/sdk/instrumentation" | ||
"go.opentelemetry.io/otel/sdk/metric" | ||
) | ||
|
||
var ( | ||
grpcScope = "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc" | ||
// grpcUnacceptableKeyValues is a list of high cardinality grpc attributes that should be filtered out. | ||
grpcUnacceptableKeyValues = []attribute.KeyValue{ | ||
attribute.String(semconv.AttributeNetSockPeerAddr, ""), | ||
attribute.String(semconv.AttributeNetSockPeerPort, ""), | ||
attribute.String(semconv.AttributeNetSockPeerName, ""), | ||
} | ||
|
||
httpScope = "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" | ||
// httpUnacceptableKeyValues is a list of high cardinality http attributes that should be filtered out. | ||
httpUnacceptableKeyValues = []attribute.KeyValue{ | ||
attribute.String(semconv.AttributeNetHostName, ""), | ||
attribute.String(semconv.AttributeNetHostPort, ""), | ||
attribute.String(semconv.AttributeNetSockPeerPort, ""), | ||
attribute.String(semconv.AttributeNetSockPeerAddr, ""), | ||
attribute.String(semconv.AttributeHTTPClientIP, ""), | ||
} | ||
) | ||
|
||
func cardinalityFilter(kvs ...attribute.KeyValue) attribute.Filter { | ||
filter := attribute.NewSet(kvs...) | ||
return func(kv attribute.KeyValue) bool { | ||
return !filter.HasValue(kv.Key) | ||
} | ||
} | ||
|
||
// DropHighCardinalityServerAttributes drops certain high cardinality attributes from grpc/http server metrics | ||
// | ||
// This is a hopefully temporary fix to this upstream issue https://github.com/open-telemetry/opentelemetry-go-contrib/issues/3765 | ||
glindstedt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
func DropHighCardinalityServerAttributes() []metric.View { | ||
var views []metric.View | ||
|
||
views = append(views, metric.NewView( | ||
metric.Instrument{Scope: instrumentation.Scope{Name: grpcScope}}, | ||
metric.Stream{AttributeFilter: cardinalityFilter(grpcUnacceptableKeyValues...)})) | ||
|
||
views = append(views, metric.NewView( | ||
metric.Instrument{Scope: instrumentation.Scope{Name: httpScope}}, | ||
metric.Stream{AttributeFilter: cardinalityFilter(httpUnacceptableKeyValues...)}, | ||
)) | ||
|
||
return views | ||
} |
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH I'm not sure if we should just call this
high_cardinality_metrics
. IMO we can merge this as it is for now, and I'll have a discussion with the other people on the team if they'd be in favour of changing it prior to the next release.