Skip to content

Commit

Permalink
Rename some fields processedSpanMetrics to spanSizeMetrics
Browse files Browse the repository at this point in the history
Signed-off-by: Yosuke Matsuda <[email protected]>
  • Loading branch information
ymtdzzz committed Jun 28, 2022
1 parent 1b22e9e commit c4282bf
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 34 deletions.
18 changes: 9 additions & 9 deletions cmd/collector/app/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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)
Expand Down
38 changes: 19 additions & 19 deletions cmd/collector/app/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
}
}

Expand Down
6 changes: 3 additions & 3 deletions cmd/collector/app/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
}
2 changes: 1 addition & 1 deletion cmd/collector/app/span_handler_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/collector/app/span_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/collector/app/span_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit c4282bf

Please sign in to comment.