-
Notifications
You must be signed in to change notification settings - Fork 867
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 using WithSpan annotation in java6 class #2699
Conversation
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. We could probably make the java6 test more readable by moving it to a separate test module with maxJavaVersionForTests set to 6.
...n/opentelemetry-annotations-1.0/javaagent/src/test/groovy/WithSpanInstrumentationTest.groovy
Outdated
Show resolved
Hide resolved
...ation/opentelemetry-annotations-1.0/javaagent/opentelemetry-annotations-1.0-javaagent.gradle
Outdated
Show resolved
Hide resolved
Unfortunately I don't think this'd work: tests Java process runs with our javaagent, which does not support Java <8. |
setup: | ||
/* | ||
class GeneratedJava6TestClass implements Runnable { | ||
@WithSpan | ||
public void run() { | ||
TraceUtils.runUnderTrace("intercept", {}) | ||
} | ||
} | ||
*/ | ||
Class<?> generatedClass = new ByteBuddy(ClassFileVersion.JAVA_V6) | ||
.subclass(Object) | ||
.name("GeneratedJava6TestClass") | ||
.implement(Runnable) | ||
.defineMethod("run", void.class, Modifier.PUBLIC).intercept(MethodDelegation.to(new Object() { | ||
@RuntimeType | ||
void intercept(@This Object o) { | ||
TraceUtils.runUnderTrace("intercept", {}) | ||
} | ||
})) | ||
.visit(new MemberAttributeExtension.ForMethod() | ||
.annotateMethod(AnnotationDescription.Builder.ofType(WithSpan).build()) | ||
.on(ElementMatchers.named("run"))) | ||
.make() | ||
.load(getClass().getClassLoader()) | ||
.getLoaded() |
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.
nice, I would have found a (random old) library that was compiled to Java 6 and tested instrumentation of that library, but this is better 👍
No description provided.