From d61132b71bea3cfc2732d8e1e553e67c9fea7e00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=B8=A9=E7=82=8E?= Date: Fri, 13 Sep 2024 17:42:22 +0800 Subject: [PATCH] feat: support for ForceFlush of LoggerProvider --- uptrace/client.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/uptrace/client.go b/uptrace/client.go index 934dc492..62e25751 100644 --- a/uptrace/client.go +++ b/uptrace/client.go @@ -8,7 +8,7 @@ import ( "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" sdklog "go.opentelemetry.io/otel/sdk/log" - "go.opentelemetry.io/otel/sdk/metric" + sdkmetric "go.opentelemetry.io/otel/sdk/metric" sdktrace "go.opentelemetry.io/otel/sdk/trace" "go.opentelemetry.io/otel/trace" ) @@ -21,7 +21,7 @@ type client struct { tracer trace.Tracer tp *sdktrace.TracerProvider - mp *metric.MeterProvider + mp *sdkmetric.MeterProvider lp *sdklog.LoggerProvider } @@ -65,6 +65,11 @@ func (c *client) ForceFlush(ctx context.Context) (lastErr error) { lastErr = err } } + if c.lp != nil { + if err := c.lp.ForceFlush(ctx); err != nil { + lastErr = err + } + } return lastErr }