From 2695c308866bed0c9f55a27b1d90db036c3fcabf Mon Sep 17 00:00:00 2001 From: neosu Date: Thu, 23 Sep 2021 10:42:45 +0800 Subject: [PATCH] we can use otel.ErrorHandlerFunc instead of custom struct when we update OpenTelemetry to 1.0.0 (#1081) --- core/trace/opentelemetry/agent.go | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/core/trace/opentelemetry/agent.go b/core/trace/opentelemetry/agent.go index fdb70b77..add06089 100644 --- a/core/trace/opentelemetry/agent.go +++ b/core/trace/opentelemetry/agent.go @@ -52,17 +52,10 @@ func StartAgent(c Config) { otel.SetTracerProvider(tp) otel.SetTextMapPropagator(propagation.NewCompositeTextMapPropagator(propagation.TraceContext{}, propagation.Baggage{})) - otel.SetErrorHandler(otelErrHandler{}) + otel.SetErrorHandler(otel.ErrorHandlerFunc(func(e error) { + logx.Errorf("[otel] error: %v", err) + })) enabled.Set(true) }) } - -// errHandler handing otel errors. -type otelErrHandler struct{} - -var _ otel.ErrorHandler = otelErrHandler{} - -func (o otelErrHandler) Handle(err error) { - logx.Errorf("[otel] error: %v", err) -}