diff --git a/cmd/agent/app/reporter/grpc/reporter.go b/cmd/agent/app/reporter/grpc/reporter.go index 217c5ae42f2..cb14cf0e3e4 100644 --- a/cmd/agent/app/reporter/grpc/reporter.go +++ b/cmd/agent/app/reporter/grpc/reporter.go @@ -44,7 +44,7 @@ func NewReporter(conn *grpc.ClientConn, agentTags map[string]string, logger *zap collector: api_v2.NewCollectorServiceClient(conn), agentTags: makeModelKeyValue(agentTags), logger: logger, - sanitizer: zipkin2.NewChainedSanitizer(zipkin2.StandardSanitizers...), + sanitizer: zipkin2.NewChainedSanitizer(zipkin2.NewStandardSanitizers()...), } } diff --git a/cmd/collector/app/sanitizer/empty_service_name_sanitizer.go b/cmd/collector/app/sanitizer/empty_service_name_sanitizer.go index 85db9913fa3..9e94acfdd79 100644 --- a/cmd/collector/app/sanitizer/empty_service_name_sanitizer.go +++ b/cmd/collector/app/sanitizer/empty_service_name_sanitizer.go @@ -18,7 +18,7 @@ import ( "github.com/jaegertracing/jaeger/model" ) -var ( +const ( serviceNameReplacement = "empty-service-name" nullProcessServiceName = "null-process-and-service-name" ) diff --git a/cmd/collector/app/sanitizer/sanitizer.go b/cmd/collector/app/sanitizer/sanitizer.go index a17b1351aac..3ccebda82d4 100644 --- a/cmd/collector/app/sanitizer/sanitizer.go +++ b/cmd/collector/app/sanitizer/sanitizer.go @@ -23,9 +23,11 @@ import ( // span should implement this interface. type SanitizeSpan func(span *model.Span) *model.Span -// StandardSanitizers are automatically applied by SpanProcessor. -var StandardSanitizers []SanitizeSpan = []SanitizeSpan{ - NewEmptyServiceNameSanitizer(), +// NewStandardSanitizers are automatically applied by SpanProcessor. +func NewStandardSanitizers() []SanitizeSpan { + return []SanitizeSpan{ + NewEmptyServiceNameSanitizer(), + } } // NewChainedSanitizer creates a Sanitizer from the variadic list of passed Sanitizers. diff --git a/cmd/collector/app/sanitizer/zipkin/span_sanitizer.go b/cmd/collector/app/sanitizer/zipkin/span_sanitizer.go index 94d25a1fc7a..71b707f90b2 100644 --- a/cmd/collector/app/sanitizer/zipkin/span_sanitizer.go +++ b/cmd/collector/app/sanitizer/zipkin/span_sanitizer.go @@ -27,16 +27,17 @@ const ( zeroParentIDTag = "errZeroParentID" ) -var ( - defaultDuration = int64(1) - // StandardSanitizers is a list of standard zipkin sanitizers. - StandardSanitizers = []Sanitizer{ +var defaultDuration = int64(1) // not a const because we take its address + +// NewStandardSanitizers is a list of standard zipkin sanitizers. +func NewStandardSanitizers() []Sanitizer { + return []Sanitizer{ NewSpanStartTimeSanitizer(), NewSpanDurationSanitizer(), NewParentIDSanitizer(), NewErrorTagSanitizer(), } -) +} // Sanitizer interface for sanitizing spans. Any business logic that needs to be applied to normalize the contents of a // span should implement this interface. diff --git a/cmd/collector/app/span_handler_builder.go b/cmd/collector/app/span_handler_builder.go index 301cecfbf5d..69e5aac865e 100644 --- a/cmd/collector/app/span_handler_builder.go +++ b/cmd/collector/app/span_handler_builder.go @@ -67,7 +67,11 @@ func (b *SpanHandlerBuilder) BuildSpanProcessor(additional ...ProcessSpan) proce // BuildHandlers builds span handlers (Zipkin, Jaeger) func (b *SpanHandlerBuilder) BuildHandlers(spanProcessor processor.SpanProcessor) *SpanHandlers { return &SpanHandlers{ - handler.NewZipkinSpanHandler(b.Logger, spanProcessor, zs.NewChainedSanitizer(zs.StandardSanitizers...)), + handler.NewZipkinSpanHandler( + b.Logger, + spanProcessor, + zs.NewChainedSanitizer(zs.NewStandardSanitizers()...), + ), handler.NewJaegerSpanHandler(b.Logger, spanProcessor), handler.NewGRPCHandler(b.Logger, spanProcessor), } diff --git a/cmd/collector/app/span_processor.go b/cmd/collector/app/span_processor.go index 816f5b4837b..abb7a322a9b 100644 --- a/cmd/collector/app/span_processor.go +++ b/cmd/collector/app/span_processor.go @@ -96,7 +96,7 @@ func newSpanProcessor(spanWriter spanstore.Writer, additional []ProcessSpan, opt } boundedQueue := queue.NewBoundedQueue(options.queueSize, droppedItemHandler) - sanitizers := append([]sanitizer.SanitizeSpan{}, sanitizer.StandardSanitizers...) + sanitizers := sanitizer.NewStandardSanitizers() if options.sanitizer != nil { sanitizers = append(sanitizers, options.sanitizer) }