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

Add flag to enable span size metrics reporting #3782

Merged

Conversation

ymtdzzz
Copy link
Contributor

@ymtdzzz ymtdzzz commented Jun 26, 2022

Which problem is this PR solving?

Resolves #2126

Short description of the changes

  • add --collector.enable-span-size-metrics that enables processed span metrics even if --collector.queue-size-memory is disabled

Details

  • --collector.enable-span-size-metrics is enabled but --collector.queue-size-memory is disabled
apiVersion: jaegertracing.io/v1
kind: Jaeger
metadata:
  name: jaeger
spec:
  strategy: AllInOne
  imagePullPolicy: Never
  allInOne:
    image: jaegeraio:wip
    options:
      collector:
        enable-span-size-metrics: true

image

  • --collector.enable-processed-span-metrics is disabled but --collector.queue-size-memory is enabled (no change)
apiVersion: jaegertracing.io/v1
kind: Jaeger
metadata:
  name: jaeger
spec:
  strategy: AllInOne
  imagePullPolicy: Never
  allInOne:
    image: jaegeraio:wip
    options:
      collector:
        queue-size-memory: 10

image

@ymtdzzz ymtdzzz marked this pull request as ready for review June 27, 2022 00:16
@ymtdzzz ymtdzzz requested a review from a team as a code owner June 27, 2022 00:16
@ymtdzzz ymtdzzz requested a review from pavolloffay June 27, 2022 00:16
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)
Copy link
Contributor Author

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.

flagNumWorkers = "collector.num-workers"
flagQueueSize = "collector.queue-size"
flagCollectorTags = "collector.tags"
flagProcessedSpanMetricsEnabled = "collector.enable-processed-span-metrics"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
flagProcessedSpanMetricsEnabled = "collector.enable-processed-span-metrics"
flagProcessedSpanMetricsEnabled = "collector.enable-span-size-metrics"

@@ -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.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.")

@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ProcessedSpanMetricsEnabled bool
SpanSizeMetricsEnabled bool

flagNumWorkers = "collector.num-workers"
flagQueueSize = "collector.queue-size"
flagCollectorTags = "collector.tags"
flagProcessedSpanMetricsEnabled = "collector.enable-span-size-metrics"
Copy link
Member

@yurishkuro yurishkuro Jun 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
flagProcessedSpanMetricsEnabled = "collector.enable-span-size-metrics"
flagSpanSizeMetricsEnabled = "collector.enable-span-size-metrics"

let's keep consistent naming

Copy link
Contributor Author

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

reportBusy bool
extraFormatTypes []processor.SpanFormat
collectorTags map[string]string
processedSpanMetricsEnabled bool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please keep naming consistent

@@ -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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please keep naming consistent

@ymtdzzz ymtdzzz force-pushed the feature/collector/add-span-metrics-param branch from 61b230b to c4282bf Compare June 28, 2022 10:13
if tt.expectedUpdateGauge {
assert.Fail(t, "gauge hasn't been updated within a reasonable amount of time")
}
assert.NoError(t, p.Close())
Copy link
Member

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",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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++ {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@yurishkuro yurishkuro changed the title Add parameter to enable processed span metrics Add flag to enable span size metrics reporting Jun 29, 2022
@yurishkuro yurishkuro enabled auto-merge (squash) June 29, 2022 01:10
@codecov
Copy link

codecov bot commented Jun 29, 2022

Codecov Report

Merging #3782 (32c8209) into main (9b4bbf4) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@            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              
Impacted Files Coverage Δ
cmd/collector/app/flags/flags.go 96.80% <100.00%> (+0.06%) ⬆️
cmd/collector/app/options.go 100.00% <100.00%> (ø)
cmd/collector/app/span_handler_builder.go 100.00% <100.00%> (ø)
cmd/collector/app/span_processor.go 100.00% <100.00%> (ø)
pkg/config/tlscfg/cert_watcher.go 94.68% <0.00%> (+2.12%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9b4bbf4...32c8209. Read the comment docs.

@yurishkuro yurishkuro merged commit 10af8ec into jaegertracing:main Jun 29, 2022
@ymtdzzz ymtdzzz deleted the feature/collector/add-span-metrics-param branch June 29, 2022 01:40
albertteoh pushed a commit to albertteoh/jaeger that referenced this pull request Jul 13, 2022
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

jaeger_collector_spans_bytes is always 0
2 participants