-
Notifications
You must be signed in to change notification settings - Fork 873
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
Allow scanning instrumented reactor publishers and only allow registe… #5755
Conversation
@Test | ||
void fluxParentsAccessible() { | ||
UnicastProcessor<String> source = UnicastProcessor.create(); | ||
Flux<String> mono = ContextPropagationOperator.runWithContext(source, Context.root()); |
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.
Nit
Flux<String> mono = ContextPropagationOperator.runWithContext(source, Context.root()); | |
Flux<String> flux = ContextPropagationOperator.runWithContext(source, Context.root()); |
@@ -98,17 +101,22 @@ public static Context getOpenTelemetryContext( | |||
* reactive stream. This should generally be called in a static initializer block in your | |||
* application. | |||
*/ | |||
public void registerOnEachOperator() { | |||
public synchronized void registerOnEachOperator() { |
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.
When trying to use AtomicBoolean
I got this bizzare exception in KotlinCoroutinesInstrumentationTest. Synchronizing for these should be fine anyways, but is it an agent bug?
[otel.javaagent 2022-04-06 07:40:51:716 +0000] [otel-javaagent-transform-safe-logger] DEBUG io.opentelemetry.javaagent.tooling.AgentInstaller$TransformLoggingListener - Failed to handle io.opentelemetry.instrumentation.reactor.ContextPropagationOperator for transformation on classloader jdk.internal.loader.ClassLoaders$AppClassLoader@7ad041f3
java.lang.IllegalStateException: Cannot assign private static final java.util.concurrent.atomic.AtomicBoolean io.opentelemetry.instrumentation.reactor.ContextPropagationOperator.enabled to boolean
at net.bytebuddy.asm.Advice$OffsetMapping$ForField.resolve(Advice.java:2317)
at net.bytebuddy.asm.Advice$Dispatcher$Inlining$Resolved$ForMethodEnter.doApply(Advice.java:8684)
at net.bytebuddy.asm.Advice$Dispatcher$Inlining$Resolved$ForMethodEnter$WithDiscardedEnterType.doApply(Advice.java:8786)
at net.bytebuddy.asm.Advice$Dispatcher$Inlining$Resolved$ForMethodEnter.apply(Advice.java:8642)
at net.bytebuddy.asm.Advice$Dispatcher$Inlining$Resolved$AdviceMethodInliner.visitMethod(Advice.java:8332)
at org.objectweb.asm.ClassReader.readMethod(ClassReader.java:1353)
at org.objectweb.asm.ClassReader.accept(ClassReader.java:744)
at org.objectweb.asm.ClassReader.accept(ClassReader.java:424)
at net.bytebuddy.asm.Advice$Dispatcher$Inlining$Resolved$AdviceMethodInliner.apply(Advice.java:8325)
at net.bytebuddy.asm.Advice$AdviceVisitor.onAfterExceptionTable(Advice.java:10579)
at net.bytebuddy.utility.visitor.ExceptionTableSensitiveMethodVisitor.considerEndOfExceptionTable(ExceptionTableSensitiveMethodVisitor.java:49)
at net.bytebuddy.utility.visitor.ExceptionTableSensitiveMethodVisitor.visitLabel(ExceptionTableSensitiveMethodVisitor.java:81)
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.
ah, probably coming from
Line 109 in cd725ec
@Advice.FieldValue(value = "enabled", readOnly = false) boolean enabled) { |
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.
since it's a public class, better to avoid synchronizing on this
?
open-telemetry#5755) * Allow scanning instrumented reactor publishers and only allow registering once. * Avoid atomicboolean * Clean * Bug
…ring once.
While working on some other test code, I noticed that we add a context propagating publisher to the chain that does not allow scanning it's parent, unlike all the standard reactor publishers. While not strictly necessary based on the publisher spec, it's good to not lose this functionality.
Also noticed it seems possible to register hooks twice so added a guard.