-
Notifications
You must be signed in to change notification settings - Fork 319
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
Fix OTel bridge behavior with multiple classloaders + improved activation #2735
Fix OTel bridge behavior with multiple classloaders + improved activation #2735
Conversation
List<String> logLines = Arrays.asList(app.getLogs().split("\n")); | ||
assertThat(logLines).isNotEmpty(); | ||
|
||
assertThat(logLines).containsExactly( |
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.
[for review] this is a very simple way to validate proper plugin execution by relying on the fact that instrumentation plugin will print to output, proper parsing of the generated event could added later with a mock server.
apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/AbstractSpan.java
Outdated
Show resolved
Hide resolved
…tel-bridge-plugin
…tel-bridge-plugin
…tel-bridge-plugin
/test |
apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/ElasticContextWrapper.java
Show resolved
Hide resolved
apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/ElasticContextWrapper.java
Outdated
Show resolved
Hide resolved
apm-agent-core/src/main/java/co/elastic/apm/agent/impl/ElasticApmTracer.java
Outdated
Show resolved
Hide resolved
apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/ElasticContextWrapper.java
Outdated
Show resolved
Hide resolved
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.
LGTM
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.
What if one OTel plugin wants to attach
a context that was created by another plugin?
I think the way co.elastic.apm.agent.opentelemetry.context.OTelContextStorage#attach
is implemented doesn't support that atm.
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.
Thanks for walking me through it @SylvainJuge 🙏
…tel-bridge-plugin
Summary
When there are multiple external plugins using OTel API, or there are multiple OTel APIs that are instrumented in distinct classloaders (CL), each copy is instrumented within an isolated CL, which makes all those calls to OTel APIs unable to properly work together in the OTel bridge as they can't rely on type equality due to having isolated CLs.
For example, as it was reported in the forum, creating a transaction with an external plugin and creating spans with another external plugin would make using both not work as expected and unable to properly create child spans when the transaction is active.
On top of that, the "span upgrade" process that is currently used when wrapping Elastic spans to make them visible to OTel is flawed:
Solution proposal
ElasticContext
) able to store wrapped objects with aMap<Class<?>,ElasticContet<?>>
with wrapped object type as the key, and wrapped object as value.Checklist