From 58e9a526e8a118054aa811e6b62bcae3f227b224 Mon Sep 17 00:00:00 2001 From: Cyrille Le Clerc Date: Thu, 22 Aug 2024 22:49:03 +0200 Subject: [PATCH 1/3] Workaround NoClassDefFoundError in @PreDestroy waiting for MNG-7056 --- .../maven/OtelLifecycleParticipant.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/maven-extension/src/main/java/io/opentelemetry/maven/OtelLifecycleParticipant.java b/maven-extension/src/main/java/io/opentelemetry/maven/OtelLifecycleParticipant.java index 6b910e15f..2e959bbdd 100644 --- a/maven-extension/src/main/java/io/opentelemetry/maven/OtelLifecycleParticipant.java +++ b/maven-extension/src/main/java/io/opentelemetry/maven/OtelLifecycleParticipant.java @@ -21,6 +21,8 @@ public final class OtelLifecycleParticipant extends AbstractMavenLifecyclePartic private static final Logger logger = LoggerFactory.getLogger(OtelLifecycleParticipant.class); + private final OpenTelemetrySdkService openTelemetrySdkService; + private final OtelExecutionListener otelExecutionListener; /** @@ -30,6 +32,7 @@ public final class OtelLifecycleParticipant extends AbstractMavenLifecyclePartic @Inject OtelLifecycleParticipant( OpenTelemetrySdkService openTelemetrySdkService, SpanRegistry spanRegistry) { + this.openTelemetrySdkService = openTelemetrySdkService; this.otelExecutionListener = new OtelExecutionListener(spanRegistry, openTelemetrySdkService); } @@ -60,4 +63,13 @@ public void afterProjectsRead(MavenSession session) { + initialExecutionListener); } } + + @Override + public void afterSessionEnd(MavenSession session) { + // Waiting for https://issues.apache.org/jira/browse/MNG-7056 and + // https://github.com/open-telemetry/opentelemetry-java-contrib/issues/1391 + // to be fixed, close OpenTelemetry SDK in `afterSessionEnd()` + logger.debug("OpenTelemetry: After Maven session end, close OpenTelemetry SDK"); + openTelemetrySdkService.close(); + } } From c328b4dec3e71e1909d26d73f823fa0575c752f9 Mon Sep 17 00:00:00 2001 From: Cyrille Le Clerc Date: Mon, 9 Dec 2024 22:37:12 +0100 Subject: [PATCH 2/3] Better docs --- .../io/opentelemetry/maven/OtelLifecycleParticipant.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/maven-extension/src/main/java/io/opentelemetry/maven/OtelLifecycleParticipant.java b/maven-extension/src/main/java/io/opentelemetry/maven/OtelLifecycleParticipant.java index 2e959bbdd..ac8f06e20 100644 --- a/maven-extension/src/main/java/io/opentelemetry/maven/OtelLifecycleParticipant.java +++ b/maven-extension/src/main/java/io/opentelemetry/maven/OtelLifecycleParticipant.java @@ -59,16 +59,15 @@ public void afterProjectsRead(MavenSession session) { .setExecutionListener( new ChainedExecutionListener(this.otelExecutionListener, initialExecutionListener)); logger.debug( - "OpenTelemetry: OpenTelemetry extension registered as execution listener. InitialExecutionListener: " - + initialExecutionListener); + "OpenTelemetry: OpenTelemetry extension registered as execution listener. InitialExecutionListener: {}", + initialExecutionListener); } } @Override public void afterSessionEnd(MavenSession session) { - // Waiting for https://issues.apache.org/jira/browse/MNG-7056 and - // https://github.com/open-telemetry/opentelemetry-java-contrib/issues/1391 - // to be fixed, close OpenTelemetry SDK in `afterSessionEnd()` + // Workaround https://issues.apache.org/jira/browse/MNG-8217 + // close OpenTelemetry SDK in `afterSessionEnd()` logger.debug("OpenTelemetry: After Maven session end, close OpenTelemetry SDK"); openTelemetrySdkService.close(); } From 70de93fa3b23bf4be7dfaa38d90ef68fe7c0663c Mon Sep 17 00:00:00 2001 From: Cyrille Le Clerc Date: Mon, 9 Dec 2024 22:37:49 +0100 Subject: [PATCH 3/3] Better docs --- .../java/io/opentelemetry/maven/OtelLifecycleParticipant.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maven-extension/src/main/java/io/opentelemetry/maven/OtelLifecycleParticipant.java b/maven-extension/src/main/java/io/opentelemetry/maven/OtelLifecycleParticipant.java index ac8f06e20..d613f9607 100644 --- a/maven-extension/src/main/java/io/opentelemetry/maven/OtelLifecycleParticipant.java +++ b/maven-extension/src/main/java/io/opentelemetry/maven/OtelLifecycleParticipant.java @@ -60,7 +60,7 @@ public void afterProjectsRead(MavenSession session) { new ChainedExecutionListener(this.otelExecutionListener, initialExecutionListener)); logger.debug( "OpenTelemetry: OpenTelemetry extension registered as execution listener. InitialExecutionListener: {}", - initialExecutionListener); + initialExecutionListener); } }