-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Add flag to enable span size metrics reporting #3782
Add flag to enable span size metrics reporting #3782
Conversation
Signed-off-by: Yosuke Matsuda <[email protected]>
options.logger.Info("Dynamically adjusting the queue size at runtime.", | ||
zap.Uint("memory-mib", options.dynQueueSizeMemory/1024/1024), | ||
zap.Uint("queue-size-warmup", options.dynQueueSizeWarmup)) | ||
} | ||
if options.dynQueueSizeMemory > 0 || options.processedSpanMetricsEnabled { | ||
// add to processSpanFuncs | ||
processSpanFuncs = append(processSpanFuncs, sp.countSpan) |
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.
As mentioned in #2126 (comment) , sp.spansProcessed.Inc()
could be independent but I didn't change this for simplicity.
cmd/collector/app/flags/flags.go
Outdated
flagNumWorkers = "collector.num-workers" | ||
flagQueueSize = "collector.queue-size" | ||
flagCollectorTags = "collector.tags" | ||
flagProcessedSpanMetricsEnabled = "collector.enable-processed-span-metrics" |
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.
flagProcessedSpanMetricsEnabled = "collector.enable-processed-span-metrics" | |
flagProcessedSpanMetricsEnabled = "collector.enable-span-size-metrics" |
cmd/collector/app/flags/flags.go
Outdated
@@ -163,6 +166,7 @@ func AddFlags(flags *flag.FlagSet) { | |||
flags.Int(flagQueueSize, DefaultQueueSize, "The queue size of the collector") | |||
flags.Uint(flagDynQueueSizeMemory, 0, "(experimental) The max memory size in MiB to use for the dynamic queue.") | |||
flags.String(flagCollectorTags, "", "One or more tags to be added to the Process tags of all spans passing through this collector. Ex: key1=value1,key2=${envVar:defaultValue}") | |||
flags.Bool(flagProcessedSpanMetricsEnabled, false, "Enables processed span metrics.") |
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.
flags.Bool(flagProcessedSpanMetricsEnabled, false, "Enables processed span metrics.") | |
flags.Bool(flagProcessedSpanMetricsEnabled, false, "Enables metrics based on processed span size, which are more expensive to calculate.") |
cmd/collector/app/flags/flags.go
Outdated
@@ -124,6 +125,8 @@ type CollectorOptions struct { | |||
} | |||
// CollectorTags is the string representing collector tags to append to each and every span | |||
CollectorTags map[string]string | |||
// ProcessedSpanMetricsEnabled determines whether to enable processed span metrics | |||
ProcessedSpanMetricsEnabled bool |
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.
ProcessedSpanMetricsEnabled bool | |
SpanSizeMetricsEnabled bool |
cmd/collector/app/flags/flags.go
Outdated
flagNumWorkers = "collector.num-workers" | ||
flagQueueSize = "collector.queue-size" | ||
flagCollectorTags = "collector.tags" | ||
flagProcessedSpanMetricsEnabled = "collector.enable-span-size-metrics" |
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.
flagProcessedSpanMetricsEnabled = "collector.enable-span-size-metrics" | |
flagSpanSizeMetricsEnabled = "collector.enable-span-size-metrics" |
let's keep consistent naming
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.
oh ok, I will check it all again
cmd/collector/app/options.go
Outdated
reportBusy bool | ||
extraFormatTypes []processor.SpanFormat | ||
collectorTags map[string]string | ||
processedSpanMetricsEnabled bool |
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.
please keep naming consistent
cmd/collector/app/options.go
Outdated
@@ -156,6 +157,13 @@ func (options) CollectorTags(extraTags map[string]string) Option { | |||
} | |||
} | |||
|
|||
// ProcessedSpanMetricsEnabled creates an Option that initializes the processedSpanMetrics boolean | |||
func (options) ProcessedSpanMetricsEnabled(processedSpanMetrics bool) Option { |
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.
please keep naming consistent
Signed-off-by: Yosuke Matsuda <[email protected]>
61b230b
to
c4282bf
Compare
if tt.expectedUpdateGauge { | ||
assert.Fail(t, "gauge hasn't been updated within a reasonable amount of time") | ||
} | ||
assert.NoError(t, p.Close()) |
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.
this won't be executed if you return in L460. I suggest using defer to close p.
expectedUpdateGauge bool | ||
}{ | ||
{ | ||
name: "enable-dyn-queue-size-enable-metrics", |
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.
name: "enable-dyn-queue-size-enable-metrics", | |
name: "enable dyn-queue-size, enable metrics", |
nit: remove dashes for better readability, separate with commas
p.processSpan(&model.Span{}, "") | ||
assert.NotEqual(t, uint64(0), p.bytesProcessed) | ||
|
||
for i := 0; i < 15; i++ { |
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.
for i := 0; i < 15; i++ { | |
for i := 0; i < 10000; i++ { |
doesn't affect test speed in most cases, but makes it more resilient in case of VM freezes
Signed-off-by: Yosuke Matsuda <[email protected]>
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.
thanks!
Codecov Report
@@ Coverage Diff @@
## main #3782 +/- ##
==========================================
+ Coverage 97.57% 97.59% +0.01%
==========================================
Files 288 288
Lines 16765 16774 +9
==========================================
+ Hits 16359 16370 +11
+ Misses 321 319 -2
Partials 85 85
Continue to review full report at Codecov.
|
* Add parameter to enable processed span metrics Signed-off-by: Yosuke Matsuda <[email protected]> * Rename some fields `processedSpanMetrics` to `spanSizeMetrics` Signed-off-by: Yosuke Matsuda <[email protected]> * Improve test reliability and readability Signed-off-by: Yosuke Matsuda <[email protected]> Signed-off-by: Albert Teoh <[email protected]>
Which problem is this PR solving?
Resolves #2126
Short description of the changes
--collector.enable-span-size-metrics
that enables processed span metrics even if--collector.queue-size-memory
is disabledDetails
--collector.enable-span-size-metrics
is enabled but--collector.queue-size-memory
is disabled--collector.enable-processed-span-metrics
is disabled but--collector.queue-size-memory
is enabled (no change)