-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Named tracer prototype #227
Conversation
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.
Looks good, especially nice to see all the globals disappear from the SDK.
I have a few thoughts about how naming might improve, in light of the proposal in #216, but don't want to block this from merging.
sdk/trace/benchmark_test.go
Outdated
@@ -144,6 +145,7 @@ func BenchmarkSpanWithAttributes_all_2x(b *testing.B) { | |||
} | |||
|
|||
func BenchmarkTraceID_DotString(b *testing.B) { | |||
getTracer(b, "Benchmark traceID to string") |
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 needed?
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.
yes. Without this tracer doesn't have a reference to the provider which has the config.
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.
It just doesn't look like the tracer is used in this benchmark. No big deal.
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.
I was looking in the wrong place. Yes, it is not needed. I have removed it.
sdk/trace/benchmark_test.go
Outdated
@@ -157,6 +159,7 @@ func BenchmarkTraceID_DotString(b *testing.B) { | |||
} | |||
|
|||
func BenchmarkSpanID_DotString(b *testing.B) { | |||
getTracer(b, "Benchmark spanID to string") |
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.
(same)
// GetTracer creates a named tracer that implements Tracer interface. | ||
// If name is an empty string then default name from the manager | ||
// is used. | ||
GetTracer(name string) Tracer |
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.
I wonder if this should just be Get(name string) Tracer
.
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.
I'll fix this in another PR when I move the provider interface to global package.
My concern about naming is that
is fairly long. Renaming
the |
} | ||
|
||
func main() { | ||
initTracer() | ||
tr := trace.GlobalProvider().GetTracer("stackdriver/example/server") |
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.
Should this be /client
?
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.
yes. changed.
plugin/othttp/server_example_test.go
Outdated
// For the example, use sdktrace.AlwaysSample sampler to sample all traces. | ||
// In a production application, use sdktrace.ProbabilitySampler with a desired probability. | ||
sdktrace.ApplyConfig(sdktrace.Config{DefaultSampler: sdktrace.AlwaysSample()}) | ||
//import sdktrace "go.opentelemetry.io/sdk/trace" |
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 comment doesn't make sense anymore.
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.
removed.
@@ -181,16 +178,16 @@ func createAndRegisterBatchSP(t *testing.T, option testOption, te *testBatchExpo | |||
if ssp == nil { | |||
t.Errorf("%s: Error creating new instance of BatchSpanProcessor, error: %v\n", option.name, err) | |||
} | |||
sdktrace.RegisterSpanProcessor(ssp) | |||
//sdktrace.RegisterSpanProcessor(ssp) |
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.
delete this comment
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.
removed.
sdk/trace/provider.go
Outdated
} | ||
|
||
// UnregisterSpanProcessor removes from the list of SpanProcessors the SpanProcessor that was | ||
// registered with the given name. |
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 comment is quite stuttery.
Suggestion:
UnregisterSpanProcessor removes the given SpanProcessor from the list of SpanProcessors
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.
sdk/trace/span_processor_test.go
Outdated
@@ -48,10 +42,13 @@ func (t *testSpanProcesor) Shutdown() { | |||
|
|||
func TestRegisterSpanProcessort(t *testing.T) { | |||
name := "Register span processor before span starts" | |||
tp, _ := sdktrace.NewProvider( | |||
sdktrace.WithConfig(sdktrace.Config{DefaultSampler: sdktrace.AlwaysSample()})) |
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 line is repeated a lot.
suggestion:
Set var testConfig = sdktrace.Config{DefaultSampler: sdktrace.AlwaysSample()}
and use that in WithConfig
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.
api/trace/noop_trace_manager.go
Outdated
@@ -0,0 +1,24 @@ | |||
// Copyright 2019, OpenTelemetry 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.
Should this file be named noop_trace_provider.go
?
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.
I'll take care of this in another PR. |
sdk/trace/benchmark_test.go
Outdated
@@ -144,6 +145,7 @@ func BenchmarkSpanWithAttributes_all_2x(b *testing.B) { | |||
} | |||
|
|||
func BenchmarkTraceID_DotString(b *testing.B) { | |||
getTracer(b, "Benchmark traceID to string") |
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.
It just doesn't look like the tracer is used in this benchmark. No big deal.
This is a prototype for named tracer. What is in here?