From ca6187a177dc88fd59de0aeabef72e150b02344d Mon Sep 17 00:00:00 2001 From: Jean Bisutti Date: Tue, 26 Jul 2022 07:18:23 +0200 Subject: [PATCH] Prevent the runtime attachment from launching multiple times (#409) --- .../io/opentelemetry/contrib/attach/CoreRuntimeAttach.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/runtime-attach/runtime-attach-core/src/main/java/io/opentelemetry/contrib/attach/CoreRuntimeAttach.java b/runtime-attach/runtime-attach-core/src/main/java/io/opentelemetry/contrib/attach/CoreRuntimeAttach.java index 6b0162b70..effd8a76a 100644 --- a/runtime-attach/runtime-attach-core/src/main/java/io/opentelemetry/contrib/attach/CoreRuntimeAttach.java +++ b/runtime-attach/runtime-attach-core/src/main/java/io/opentelemetry/contrib/attach/CoreRuntimeAttach.java @@ -19,6 +19,8 @@ public final class CoreRuntimeAttach { private final String agentJarResourceName; + private boolean runtimeAttachmentRequested; + /** * Creates a new {@code DistroRuntimeAttach} from the resource name of the agent jar. * @@ -37,6 +39,11 @@ public void attachJavaagentToCurrentJVM() { return; } + if (runtimeAttachmentRequested) { + return; + } + runtimeAttachmentRequested = true; + AgentFileProvider agentFileProvider = new AgentFileProvider(agentJarResourceName); File javaagentFile = agentFileProvider.getAgentFile();