Created
October 22, 2021 19:50
-
-
Save lmolkova/70f4f6118d93100f54c739469d30e817 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static final Method SET_REACTOR_CONTEXT_METHOD = getStoreContextMethod(); | |
static Method getStoreContextMethod() { | |
try { | |
Class<?> contextPropagationOperatorClass = Class.forName("io.opentelemetry.javaagent.shaded.instrumentation.reactor.ContextPropagationOperator"); | |
Class<?> oteContextShaded = Class.forName("io.opentelemetry.javaagent.shaded.io.opentelemetry.context.Context"); | |
if (contextPropagationOperatorClass != null && oteContextShaded != null) { | |
Method storeMethod = contextPropagationOperatorClass.getDeclaredMethod("storeOpenTelemetryContext", reactor.util.context.Context.class, oteContextShaded); | |
if (storeMethod.getReturnType() == reactor.util.context.Context.class) { | |
return storeMethod; | |
} | |
} catch (Throwable t) { | |
// | |
} | |
return null; | |
} | |
if (SET_REACTOR_CONTEXT_METHOD != null) { | |
try { | |
this.context = (reactor.util.context.Context) SET_REACTOR_CONTEXT_METHOD.invoke(null, reactorContext, traceContext); | |
} catch (IllegalAccessException | InvocationTargetException e) { | |
// THROWS! because traceContext I use is io.otel.context.Context and this method wants shaded context | |
LOGGER.info("ContextPropagationOperator.storeOpenTelemetryContext threw"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment