How can I react to GRPC exporter client errors #3770
Answered
by
dmathieu
ivanaguilario
asked this question in
Q&A
-
I added the OTLP GRPC exporter to my service. I'd like to be able to react if the grpc client used by the exporter throws any error, as I don't want my service to run at all if I'm not going to receive spans in my collector. One such error would be for example a timeout when I don't specify a port for the GRPC endpoint. Any ideas? This is my code to initialize the trace provider: func initOTELTracerProvider(ctx context.Context, resource *resource.Resource) (func(context.Context) error, error) {
connCtx, cancel := context.WithTimeout(ctx, time.Second)
defer cancel()
otlpExporter, err := otlptracegrpc.New(connCtx, otlptracegrpc.WithTimeout(time.Second*5))
if err != nil {
return nil, err
}
otlpProcessor := sdktrace.NewBatchSpanProcessor(otlpExporter)
tracerProvider := sdktrace.NewTracerProvider(
sdktrace.WithSampler(sdktrace.AlwaysSample()),
sdktrace.WithResource(resource),
sdktrace.WithSpanProcessor(otlpProcessor),
)
otel.SetTracerProvider(tracerProvider)
otel.SetTextMapPropagator(propagation.TraceContext{})
ctx, span := otelTracer.Start(ctx, "initOTELTracerProvider")
defer span.End()
return tracerProvider.Shutdown, nil
} |
Beta Was this translation helpful? Give feedback.
Answered by
dmathieu
Feb 24, 2023
Replies: 1 comment 1 reply
-
All errors should be sent to the ErrorHandler which you can be set as you see fit. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
ivanaguilario
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
All errors should be sent to the ErrorHandler which you can be set as you see fit.