diff --git a/cmd/collector/app/flags/flags.go b/cmd/collector/app/flags/flags.go index 56b8ae97a6d..05f5a190151 100644 --- a/cmd/collector/app/flags/flags.go +++ b/cmd/collector/app/flags/flags.go @@ -30,11 +30,11 @@ import ( ) const ( - flagDynQueueSizeMemory = "collector.queue-size-memory" - flagNumWorkers = "collector.num-workers" - flagQueueSize = "collector.queue-size" - flagCollectorTags = "collector.tags" - flagProcessedSpanMetricsEnabled = "collector.enable-processed-span-metrics" + flagDynQueueSizeMemory = "collector.queue-size-memory" + flagNumWorkers = "collector.num-workers" + flagQueueSize = "collector.queue-size" + flagCollectorTags = "collector.tags" + flagSpanSizeMetricsEnabled = "collector.enable-span-size-metrics" flagSuffixHostPort = "host-port" @@ -125,8 +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 + // SpanSizeMetricsEnabled determines whether to enable metrics based on processed span size + SpanSizeMetricsEnabled bool } type serverFlagsConfig struct { @@ -166,7 +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.") + flags.Bool(flagSpanSizeMetricsEnabled, false, "Enables metrics based on processed span size, which are more expensive to calculate.") addHTTPFlags(flags, httpServerFlagsCfg, ports.PortToHostPort(ports.CollectorHTTP)) addGRPCFlags(flags, grpcServerFlagsCfg, ports.PortToHostPort(ports.CollectorGRPC)) @@ -243,7 +243,7 @@ func (cOpts *CollectorOptions) InitFromViper(v *viper.Viper, logger *zap.Logger) cOpts.NumWorkers = v.GetInt(flagNumWorkers) cOpts.QueueSize = v.GetInt(flagQueueSize) cOpts.DynQueueSizeMemory = v.GetUint(flagDynQueueSizeMemory) * 1024 * 1024 // we receive in MiB and store in bytes - cOpts.ProcessedSpanMetricsEnabled = v.GetBool(flagProcessedSpanMetricsEnabled) + cOpts.SpanSizeMetricsEnabled = v.GetBool(flagSpanSizeMetricsEnabled) if err := cOpts.HTTP.initFromViper(v, logger, httpServerFlagsCfg); err != nil { return cOpts, fmt.Errorf("failed to parse HTTP server options: %w", err) diff --git a/cmd/collector/app/options.go b/cmd/collector/app/options.go index 46ea5f0e519..4f2f6134d09 100644 --- a/cmd/collector/app/options.go +++ b/cmd/collector/app/options.go @@ -26,22 +26,22 @@ import ( ) type options struct { - logger *zap.Logger - serviceMetrics metrics.Factory - hostMetrics metrics.Factory - preProcessSpans ProcessSpans // see docs in PreProcessSpans option. - sanitizer sanitizer.SanitizeSpan - preSave ProcessSpan - spanFilter FilterSpan - numWorkers int - blockingSubmit bool - queueSize int - dynQueueSizeWarmup uint - dynQueueSizeMemory uint - reportBusy bool - extraFormatTypes []processor.SpanFormat - collectorTags map[string]string - processedSpanMetricsEnabled bool + logger *zap.Logger + serviceMetrics metrics.Factory + hostMetrics metrics.Factory + preProcessSpans ProcessSpans // see docs in PreProcessSpans option. + sanitizer sanitizer.SanitizeSpan + preSave ProcessSpan + spanFilter FilterSpan + numWorkers int + blockingSubmit bool + queueSize int + dynQueueSizeWarmup uint + dynQueueSizeMemory uint + reportBusy bool + extraFormatTypes []processor.SpanFormat + collectorTags map[string]string + spanSizeMetricsEnabled bool } // Option is a function that sets some option on StorageBuilder. @@ -157,10 +157,10 @@ func (options) CollectorTags(extraTags map[string]string) Option { } } -// ProcessedSpanMetricsEnabled creates an Option that initializes the processedSpanMetrics boolean -func (options) ProcessedSpanMetricsEnabled(processedSpanMetrics bool) Option { +// SpanSizeMetricsEnabled creates an Option that initializes the spanSizeMetrics boolean +func (options) SpanSizeMetricsEnabled(spanSizeMetrics bool) Option { return func(b *options) { - b.processedSpanMetricsEnabled = processedSpanMetrics + b.spanSizeMetricsEnabled = spanSizeMetrics } } diff --git a/cmd/collector/app/options_test.go b/cmd/collector/app/options_test.go index 94732be0b89..ecbf4d10bef 100644 --- a/cmd/collector/app/options_test.go +++ b/cmd/collector/app/options_test.go @@ -45,14 +45,14 @@ func TestAllOptionSet(t *testing.T) { Options.DynQueueSizeMemory(1024), Options.PreSave(func(span *model.Span, tenant string) {}), Options.CollectorTags(map[string]string{"extra": "tags"}), - Options.ProcessedSpanMetricsEnabled(true), + Options.SpanSizeMetricsEnabled(true), ) assert.EqualValues(t, 5, opts.numWorkers) assert.EqualValues(t, 10, opts.queueSize) assert.EqualValues(t, map[string]string{"extra": "tags"}, opts.collectorTags) assert.EqualValues(t, 1000, opts.dynQueueSizeWarmup) assert.EqualValues(t, 1024, opts.dynQueueSizeMemory) - assert.True(t, opts.processedSpanMetricsEnabled) + assert.True(t, opts.spanSizeMetricsEnabled) } func TestNoOptionsSet(t *testing.T) { @@ -68,5 +68,5 @@ func TestNoOptionsSet(t *testing.T) { span := model.Span{} assert.EqualValues(t, &span, opts.sanitizer(&span)) assert.EqualValues(t, 0, opts.dynQueueSizeWarmup) - assert.False(t, opts.processedSpanMetricsEnabled) + assert.False(t, opts.spanSizeMetricsEnabled) } diff --git a/cmd/collector/app/span_handler_builder.go b/cmd/collector/app/span_handler_builder.go index 258efdfc792..7a314e80b95 100644 --- a/cmd/collector/app/span_handler_builder.go +++ b/cmd/collector/app/span_handler_builder.go @@ -63,7 +63,7 @@ func (b *SpanHandlerBuilder) BuildSpanProcessor(additional ...ProcessSpan) proce Options.CollectorTags(b.CollectorOpts.CollectorTags), Options.DynQueueSizeWarmup(uint(b.CollectorOpts.QueueSize)), // same as queue size for now Options.DynQueueSizeMemory(b.CollectorOpts.DynQueueSizeMemory), - Options.ProcessedSpanMetricsEnabled(b.CollectorOpts.ProcessedSpanMetricsEnabled), + Options.SpanSizeMetricsEnabled(b.CollectorOpts.SpanSizeMetricsEnabled), ) } diff --git a/cmd/collector/app/span_processor.go b/cmd/collector/app/span_processor.go index 61e3548f26f..00f73e44548 100644 --- a/cmd/collector/app/span_processor.go +++ b/cmd/collector/app/span_processor.go @@ -127,7 +127,7 @@ func newSpanProcessor(spanWriter spanstore.Writer, additional []ProcessSpan, opt zap.Uint("memory-mib", options.dynQueueSizeMemory/1024/1024), zap.Uint("queue-size-warmup", options.dynQueueSizeWarmup)) } - if options.dynQueueSizeMemory > 0 || options.processedSpanMetricsEnabled { + if options.dynQueueSizeMemory > 0 || options.spanSizeMetricsEnabled { // add to processSpanFuncs processSpanFuncs = append(processSpanFuncs, sp.countSpan) } diff --git a/cmd/collector/app/span_processor_test.go b/cmd/collector/app/span_processor_test.go index 78d342a2866..a38d3fb6fa6 100644 --- a/cmd/collector/app/span_processor_test.go +++ b/cmd/collector/app/span_processor_test.go @@ -438,7 +438,7 @@ func TestSpanProcessorCountSpan(t *testing.T) { m := mb.Namespace(metrics.NSOptions{}) w := &fakeSpanWriter{} - opts := []Option{Options.HostMetrics(m), Options.ProcessedSpanMetricsEnabled(tt.enableSpanMetrics)} + opts := []Option{Options.HostMetrics(m), Options.SpanSizeMetricsEnabled(tt.enableSpanMetrics)} if tt.enableDynQueueSizeMem { opts = append(opts, Options.DynQueueSizeMemory(1000)) } else {