jzelinskie / cobrautil

A collection of utility functions when using Cobra.
https://github.com/jzelinskie/cobrautil
Apache License 2.0
5 stars 10 forks source link

Inject OTEL provider into command context #53

Closed alecmerdler closed 8 months ago

alecmerdler commented 8 months ago

The OpenTelemetry library flushes traces asynchronously, so pending traces can be lost when the application terminates. This adds the OTEL provider to the command context so that clients can call provider.Shutdown() and ensure that all traces are flushed before exiting the program.

Addresses #52

alecmerdler commented 8 months ago

Closing as we can get the provider using otel.GetTracerProvider() and type-cast it to a trace.TracerProvider to call Shutdown().