Skip to content

WIP: Named tracer prototype#227

Merged
rghetia merged 16 commits intoopen-telemetry:masterfrom
rghetia:named_tracer
Oct 22, 2019
Merged

WIP: Named tracer prototype#227
rghetia merged 16 commits intoopen-telemetry:masterfrom
rghetia:named_tracer

Conversation

@rghetia
Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread sdk/trace/benchmark_test.go Outdated
}

func BenchmarkTraceID_DotString(b *testing.B) {
getTracer(b, "Benchmark traceID to string")
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

Comment thread sdk/trace/benchmark_test.go Outdated
}

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

Choose a reason for hiding this comment

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

(same)

Comment thread api/trace/api.go
// 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes. changed.

Comment thread 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"
Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

removed.

Comment thread sdk/trace/batch_span_processor_test.go Outdated
t.Errorf("%s: Error creating new instance of BatchSpanProcessor, error: %v\n", option.name, err)
}
sdktrace.RegisterSpanProcessor(ssp)
//sdktrace.RegisterSpanProcessor(ssp)
Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

removed.

Comment thread sdk/trace/provider.go Outdated
}

// UnregisterSpanProcessor removes from the list of SpanProcessors the SpanProcessor that was
// registered with the given name.
Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done.

Comment thread sdk/trace/span_processor_test.go Outdated
func TestRegisterSpanProcessort(t *testing.T) {
name := "Register span processor before span starts"
tp, _ := sdktrace.NewProvider(
sdktrace.WithConfig(sdktrace.Config{DefaultSampler: sdktrace.AlwaysSample()}))
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

Comment thread sdk/trace/benchmark_test.go Outdated
}

func BenchmarkTraceID_DotString(b *testing.B) {
getTracer(b, "Benchmark traceID to string")
Copy link
Copy Markdown
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