Skip to content

Commit

Permalink
Add MustInitTracerProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
joreetz-otto committed Dec 19, 2023
1 parent d35c8b4 commit 9b5b94b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pkg/gcp/trace.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package gcp

import (
texporter "github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/trace"
"go.opentelemetry.io/otel"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
)

func MustInitTracerProvider(project string, opts ...sdktrace.TracerProviderOption) *sdktrace.TracerProvider {
exporter, err := texporter.New(texporter.WithProjectID(project))
if err != nil {
panic(err)
}
tp := sdktrace.NewTracerProvider(append(opts, sdktrace.WithBatcher(exporter))...)
otel.SetTracerProvider(tp)
return tp
}

0 comments on commit 9b5b94b

Please sign in to comment.