Skip to content

Commit

Permalink
Minor readability fixes to the Jeager example (open-telemetry#1282)
Browse files Browse the repository at this point in the history
Consistency with deferring span.End, variable names.

Co-authored-by: Tyler Yahn <[email protected]>
  • Loading branch information
rakyll and MrAlias authored Oct 28, 2020
1 parent d98ad10 commit 23e32b1
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions example/jaeger/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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) {
Expand Down

0 comments on commit 23e32b1

Please sign in to comment.