Slackbot
07/21/2022, 10:54 AMPranay
Enrico
07/21/2022, 11:08 AMfunc initOtel() (func(), error) {
exp, err := otlptrace.New(
context.Background(),
otlptracegrpc.NewClient(
otlptracegrpc.WithInsecure(),
otlptracegrpc.WithEndpoint("localhost:4317"),
),
)
if err != nil {
return nil, err
}
r, err := resource.New(
context.Background(),
resource.WithAttributes(
attribute.String("service.name", "mtgprint-backend"),
attribute.String("library.language", "go"),
),
)
if err != nil {
return nil, err
}
tp := trace.NewTracerProvider(
trace.WithSampler(trace.AlwaysSample()),
trace.WithBatcher(exp),
trace.WithResource(r),
)
otel.SetTracerProvider(tp)
return func() {
if err := tp.Shutdown(context.Background()); err != nil {
panic(err)
}
}, nil
}
Enrico
07/21/2022, 11:08 AM