-
Notifications
You must be signed in to change notification settings - Fork 118
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
fix broken internal metrics names and make them optional #203
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright (c) 2022 Uber Technologies, Inc. | ||
// Copyright (c) 2023 Uber Technologies, Inc. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
|
@@ -34,9 +34,9 @@ var ( | |
|
||
// Metrics related. | ||
internalTags = map[string]string{"version": Version} | ||
counterCardinalityName = "tally.internal.counter-cardinality" | ||
gaugeCardinalityName = "tally.internal.gauge-cardinality" | ||
histogramCardinalityName = "tally.internal.histogram-cardinality" | ||
counterCardinalityName = "tally-internal-counter-cardinality" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think either dots or dashes are accepted by prometheus reporter. At least they not legal characters according to Prom data model There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will change to underscore |
||
gaugeCardinalityName = "tally-internal-gauge-cardinality" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we please have a test for that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll have the scope's sanitizer process it during runtime instead. This way we can be agnostic about whatever scope/reporter/sanitizer is underneath. |
||
histogramCardinalityName = "tally-internal-histogram-cardinality" | ||
) | ||
|
||
type scopeRegistry struct { | ||
|
@@ -45,24 +45,28 @@ type scopeRegistry struct { | |
// We need a subscope per GOPROC so that we can take advantage of all the cpu available to the application. | ||
subscopes []*scopeBucket | ||
// Toggles internal metrics reporting. | ||
skipInternalMetrics bool | ||
internalMetricsOption InternalMetricOption | ||
} | ||
|
||
type scopeBucket struct { | ||
mu sync.RWMutex | ||
s map[string]*scope | ||
} | ||
|
||
func newScopeRegistryWithShardCount(root *scope, shardCount uint, skipInternalMetrics bool) *scopeRegistry { | ||
func newScopeRegistryWithShardCount( | ||
root *scope, | ||
shardCount uint, | ||
internalMetricsOption InternalMetricOption, | ||
) *scopeRegistry { | ||
if shardCount == 0 { | ||
shardCount = uint(runtime.GOMAXPROCS(-1)) | ||
} | ||
|
||
r := &scopeRegistry{ | ||
root: root, | ||
subscopes: make([]*scopeBucket, shardCount), | ||
seed: maphash.MakeSeed(), | ||
skipInternalMetrics: skipInternalMetrics, | ||
root: root, | ||
subscopes: make([]*scopeBucket, shardCount), | ||
seed: maphash.MakeSeed(), | ||
internalMetricsOption: internalMetricsOption, | ||
} | ||
for i := uint(0); i < shardCount; i++ { | ||
r.subscopes[i] = &scopeBucket{ | ||
|
@@ -227,7 +231,7 @@ func (r *scopeRegistry) removeWithRLock(subscopeBucket *scopeBucket, key string) | |
|
||
// Records internal Metrics' cardinalities. | ||
func (r *scopeRegistry) reportInternalMetrics() { | ||
if r.skipInternalMetrics { | ||
if r.internalMetricsOption != SendInternalMetrics { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can eventually set a default option if it's unset |
||
return | ||
} | ||
|
||
|
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.
The fact that this can cause a panic is not great. We should handle an invalid metric names gracefully. We could add sanitazation to the code where the metric is being registered. Though it probably makes sense to have it as a separate PR.
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.
created #204 to track this request