Skip to content
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

Merged
merged 16 commits into from
Oct 22, 2019
Merged

Conversation

rghetia
Copy link
Contributor

@rghetia rghetia commented Oct 21, 2019

This is a prototype for named tracer. What is in here?

  • Global Provider Register (instead of Tracer Registry). This may not be required.
  • SDK provides NewProvider method to create instance of Provider. Multiple provider instance can be created. This can help to parallelized testing.
    • It accepts optional parameter to associate exporters and configuration (sampler and other parameters) during instance creation.
    • exporters and configuration can also be applied at a later time.
  • Some Tests are updated to created its own provider. Remove reference to global tracer.
    • few tests still uses Global Tracer.

Copy link
Contributor

@jmacd jmacd left a 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.

@@ -144,6 +145,7 @@ func BenchmarkSpanWithAttributes_all_2x(b *testing.B) {
}

func BenchmarkTraceID_DotString(b *testing.B) {
getTracer(b, "Benchmark traceID to string")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

@@ -157,6 +159,7 @@ func BenchmarkTraceID_DotString(b *testing.B) {
}

func BenchmarkSpanID_DotString(b *testing.B) {
getTracer(b, "Benchmark spanID to string")
Copy link
Contributor

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
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@jmacd
Copy link
Contributor

jmacd commented Oct 21, 2019

My concern about naming is that

   tracer := trace.GlobalProvider().GetTracer(name) 

is fairly long. Renaming GetTracer() to Get() may help. In #216 I've proposed that globals move out of the core packages, so then I could imagine a package named global that would give us calls like:

  tracer := global.GetTracer(name)

the Init() method proposed in OTEP 0005 would take both a metric and a trace provider, but the caller doesn't need to write "provider" when accessing the globals.

}

func main() {
initTracer()
tr := trace.GlobalProvider().GetTracer("stackdriver/example/server")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be /client?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. changed.

// 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"
Copy link
Contributor

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.

Copy link
Contributor Author

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete this comment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed.

}

// UnregisterSpanProcessor removes from the list of SpanProcessors the SpanProcessor that was
// registered with the given name.
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@@ -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()}))
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@@ -0,0 +1,24 @@
// Copyright 2019, OpenTelemetry Authors
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@rghetia
Copy link
Contributor Author

rghetia commented Oct 22, 2019

My concern about naming is that

   tracer := trace.GlobalProvider().GetTracer(name) 

is fairly long. Renaming GetTracer() to Get() may help. In #216 I've proposed that globals move out of the core packages, so then I could imagine a package named global that would give us calls like:

  tracer := global.GetTracer(name)

the Init() method proposed in OTEP 0005 would take both a metric and a trace provider, but the caller doesn't need to write "provider" when accessing the globals.

I'll take care of this in another PR.

@@ -144,6 +145,7 @@ func BenchmarkSpanWithAttributes_all_2x(b *testing.B) {
}

func BenchmarkTraceID_DotString(b *testing.B) {
getTracer(b, "Benchmark traceID to string")
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants