diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/VertxGrpcExporter.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/VertxGrpcExporter.java index af5206f3c152b..cb6e208632afd 100644 --- a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/VertxGrpcExporter.java +++ b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/VertxGrpcExporter.java @@ -139,6 +139,10 @@ private void failOnClientRequest(int numItems, Throwable t, CompletableResultCod @Override public CompletableResultCode export(Collection spans) { + if (isShutdown.get()) { + return CompletableResultCode.ofFailure(); + } + TraceRequestMarshaler request = TraceRequestMarshaler.create(spans); return export(request, spans.size()); diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/VertxHttpExporter.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/VertxHttpExporter.java index bc8472286dae8..23c0175621898 100644 --- a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/VertxHttpExporter.java +++ b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/VertxHttpExporter.java @@ -44,6 +44,7 @@ final class VertxHttpExporter implements SpanExporter { private static final int MAX_ATTEMPTS = 3; private final HttpExporter delegate; + private final AtomicBoolean isShutdown = new AtomicBoolean(); VertxHttpExporter(HttpExporter delegate) { this.delegate = delegate; @@ -51,6 +52,10 @@ final class VertxHttpExporter implements SpanExporter { @Override public CompletableResultCode export(Collection spans) { + if (isShutdown.get()) { + return CompletableResultCode.ofFailure(); + } + TraceRequestMarshaler exportRequest = TraceRequestMarshaler.create(spans); return delegate.export(exportRequest, spans.size()); } @@ -62,6 +67,10 @@ public CompletableResultCode flush() { @Override public CompletableResultCode shutdown() { + if (!isShutdown.compareAndSet(false, true)) { + logger.log(Level.FINE, "Calling shutdown() multiple times."); + return CompletableResultCode.ofSuccess(); + } return delegate.shutdown(); } @@ -95,7 +104,6 @@ static final class VertxHttpSender implements HttpSender { this.client = vertx.createHttpClient(httpClientOptions); } - private final AtomicBoolean isShutdown = new AtomicBoolean(); private final CompletableResultCode shutdownResult = new CompletableResultCode(); private static String determineBasePath(URI baseUri) { @@ -148,11 +156,6 @@ public void accept(HttpClientRequest request) { @Override public CompletableResultCode shutdown() { - if (!isShutdown.compareAndSet(false, true)) { - logger.log(Level.FINE, "Calling shutdown() multiple times."); - return shutdownResult; - } - client.close() .onSuccess( new Handler<>() {