Skip to content

Commit

Permalink
fix: Disable tracing if OTEL_EXPORTER_OTLP_ENDPOINT is not set (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
zerok committed Sep 13, 2023
1 parent 5e36725 commit 9baf368
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions otel/otel.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ import (
)

func Setup(ctx context.Context) func(context.Context) error {
endpoint := os.Getenv("OTEL_EXPORTER_OTLP_ENDPOINT")
if endpoint == "" {
log.Print("OTEL_EXPORTER_OTLP_ENDPOINT not set. Disabling tracing.")
return func(ctx context.Context) error {
return nil
}
}
client := otlptracehttp.NewClient()
exporter, err := otlptrace.New(ctx, client)
if err != nil {
Expand Down

0 comments on commit 9baf368

Please sign in to comment.