Skip to content

Commit ca6187a

Browse files
authored
Prevent the runtime attachment from launching multiple times (#409)
1 parent 51b0086 commit ca6187a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

runtime-attach/runtime-attach-core/src/main/java/io/opentelemetry/contrib/attach/CoreRuntimeAttach.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ public final class CoreRuntimeAttach {
1919

2020
private final String agentJarResourceName;
2121

22+
private boolean runtimeAttachmentRequested;
23+
2224
/**
2325
* Creates a new {@code DistroRuntimeAttach} from the resource name of the agent jar.
2426
*
@@ -37,6 +39,11 @@ public void attachJavaagentToCurrentJVM() {
3739
return;
3840
}
3941

42+
if (runtimeAttachmentRequested) {
43+
return;
44+
}
45+
runtimeAttachmentRequested = true;
46+
4047
AgentFileProvider agentFileProvider = new AgentFileProvider(agentJarResourceName);
4148

4249
File javaagentFile = agentFileProvider.getAgentFile();

0 commit comments

Comments
 (0)