Skip to content

Commit

Permalink
Return the tracerProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Lindfalk committed Oct 14, 2022
1 parent 96edb6c commit 7e6fde5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Note that both of these can't be enabled at the same time, first we check if the
## Install

```
go get github.com/dentech-floss/[email protected].0
go get github.com/dentech-floss/[email protected].1
```

## Usage
Expand All @@ -29,7 +29,7 @@ func main() {

metadata := metadata.NewMetadata()

shutdownTracing := telemetry.SetupTracing(
tracerProvider, shutdownTracing := telemetry.SetupTracing(
ctx,
&telemetry.TracingConfig{
ServiceName: revision.ServiceName,
Expand All @@ -42,6 +42,10 @@ func main() {
},
)
defer shutdownTracing()

// And if you want to do manual instrumentation in your service then create a tracer
// and inject it where needed, otherwise you don't need the tracerProvider variable
// tracer := tracerProvider.Tracer(revision.ServiceName)
}
```

Expand Down
7 changes: 2 additions & 5 deletions pkg/telemetry/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@ func (c *TracingConfig) setDefaults() {
}
}

func SetupTracing(
ctx context.Context,
config *TracingConfig,
) func() {
func SetupTracing(ctx context.Context, config *TracingConfig) (*sdktrace.TracerProvider, func()) {
config.setDefaults()

// Create a resource describing this application
Expand Down Expand Up @@ -101,7 +98,7 @@ func SetupTracing(
propagation.Baggage{},
))

return func() {
return tracerProvider, func() {
tracerProvider.ForceFlush(ctx)
tracerProvider.Shutdown(ctx)
}
Expand Down

0 comments on commit 7e6fde5

Please sign in to comment.