-
Notifications
You must be signed in to change notification settings - Fork 328
Conversation
/cc @bogdandrutu @savaki |
trace/config.go
Outdated
@@ -0,0 +1,36 @@ | |||
// Copyright 2017, OpenCensus Authors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2018
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
if !hasParent { | ||
span.spanContext.TraceID = newTraceIDLocked() | ||
} | ||
span.spanContext.SpanID = newSpanIDLocked() | ||
sampler := defaultSampler | ||
sampler := config.DefaultSampler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this thread safe? Shouldn't you use something like this: https://golang.org/pkg/sync/atomic/#Value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole block is guarded by a mutex right now.
If you are asking about the reference, in Go, things are pass by value. User cannot mutate the config.DefaultSampler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you prefer atomic values for all the global state, I added a TODO for that.
trace.Config allows to set global configuration for tracing and deprecating the global default sampler setter. Fixes census-instrumentation#652.
trace.Config allows to set global configuration for tracing
and deprecating the global default sampler setter.
Fixes #652.