mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-02-09 13:37:12 +02:00
Minor readability fixes to the Jeager example (#1282)
Consistency with deferring span.End, variable names. Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
This commit is contained in:
parent
d98ad1042c
commit
23e32b19ec
@ -29,7 +29,7 @@ import (
|
||||
|
||||
// initTracer creates a new trace provider instance and registers it as global trace provider.
|
||||
func initTracer() func() {
|
||||
// Create and install Jaeger export pipeline
|
||||
// Create and install Jaeger export pipeline.
|
||||
flush, err := jaeger.InstallNewPipeline(
|
||||
jaeger.WithCollectorEndpoint("http://localhost:14268/api/traces"),
|
||||
jaeger.WithProcess(jaeger.Process{
|
||||
@ -44,22 +44,20 @@ func initTracer() func() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
return func() {
|
||||
flush()
|
||||
}
|
||||
return flush
|
||||
}
|
||||
|
||||
func main() {
|
||||
fn := initTracer()
|
||||
defer fn()
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
flush := initTracer()
|
||||
defer flush()
|
||||
|
||||
tr := global.Tracer("component-main")
|
||||
ctx, span := tr.Start(ctx, "foo")
|
||||
defer span.End()
|
||||
|
||||
bar(ctx)
|
||||
span.End()
|
||||
}
|
||||
|
||||
func bar(ctx context.Context) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user