Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Yuri Shkuro <github@ysh.us>
  • Loading branch information
yurishkuro committed May 10, 2022
1 parent b510ab6 commit 3f433fd
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cmd/agent/app/reporter/grpc/reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()...),
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/jaegertracing/jaeger/model"
)

var (
const (
serviceNameReplacement = "empty-service-name"
nullProcessServiceName = "null-process-and-service-name"
)
Expand Down
8 changes: 5 additions & 3 deletions cmd/collector/app/sanitizer/sanitizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 6 additions & 5 deletions cmd/collector/app/sanitizer/zipkin/span_sanitizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 5 additions & 1 deletion cmd/collector/app/span_handler_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
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 @@ -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)
}
Expand Down

0 comments on commit 3f433fd

Please sign in to comment.