-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent the runtime attachment from launching multiple times #409
Prevent the runtime attachment from launching multiple times #409
Conversation
d335179
to
b31b1fa
Compare
if (runtimeAttachmentRequested) { | ||
return; | ||
} | ||
runtimeAttachmentRequested = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just wondering, what kind of situations are we trying to prevent here? A simple duplicated line of code? Or runtime attach being called from completely different places in the application? Would it make sense to print out a warning with a stack trace to help pinpoint the unnecessary invocations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR aims to prevent the runtime attachment from being invoked several times from the main method. If a runtime attachment is invoked while another runtime attachment is in progress and not finished, I am not sure about the result with JVM attachment mechanism. The instrumentation might not be correctly installed.
Would it make sense to print out a warning with a stack trace to help pinpoint the unnecessary invocations?
Nothing is displayed to be consistent with the current display policy. First, this type of message was reported with a debug log. After, the warning log messages were replaced with System.err.println
and the debug messages removed. Perhaps it may be worth rediscussing this display policy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a runtime attachment is invoked while another runtime attachment is in progress and not finished
Again, is that a valid scenario? Don't we already have a check that verifies that only the main
thread can call this method?
Otherwise, if a concurrent scenario is possible, then this code needs to be thread safe (use AtomicBoolean
instead).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we already have a check that verifies that only the main thread can call this method?
Otherwise, if a concurrent scenario is possible, then this code needs to be thread safe (use AtomicBoolean instead).
The scenario is about two runtime attachments requested from the main thread since the new check is after the main thread check.
Again, is that a valid scenario?
I have not today enough knowledge about the Attach Listener
JVM thread implementation. I would prefer to stop the things ealier because it is not the kind of issue I would like to debug. We can close this PR on OTel if you prefer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to stop the things ealier because it is not the kind of issue I would like to debug.
👍
We can close this PR on OTel if you prefer.
No, I approve of this PR, I think this kind of check definitely makes sense. I was wondering whether this was motivated by a real use case, and if so, what kind of issue it was.
Prevent the runtime attachment from launching multiple times