Skip to content
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

Merged
merged 2 commits into from
Apr 2, 2021

Conversation

laurit
Copy link
Contributor

@laurit laurit commented Apr 2, 2021

No description provided.

Copy link

@ghost ghost left a 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.

@mateuszrzeszutek
Copy link
Member

mateuszrzeszutek commented Apr 2, 2021

We could probably make the java6 test more readable by moving it to a separate test module with maxJavaVersionForTests set to 6.

Unfortunately I don't think this'd work: tests Java process runs with our javaagent, which does not support Java <8.

Comment on lines +386 to +410
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()
Copy link
Member

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 👍

@trask trask merged commit 87950d1 into open-telemetry:main Apr 2, 2021
@laurit laurit deleted the withspan-java6 branch August 24, 2021 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants