Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import static net.bytebuddy.matcher.ElementMatchers.hasParameters;
import static net.bytebuddy.matcher.ElementMatchers.isAnnotatedWith;
import static net.bytebuddy.matcher.ElementMatchers.isDeclaredBy;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.namedOneOf;
import static net.bytebuddy.matcher.ElementMatchers.none;
Expand Down Expand Up @@ -79,13 +80,13 @@ public void transform(TypeTransformer transformer) {
tracedMethods.and(not(annotatedParametersMatcher));

transformer.applyAdviceToMethod(
tracedMethodsWithoutParameters,
tracedMethodsWithoutParameters.and(isMethod()),
WithSpanInstrumentation.class.getName() + "$WithSpanAdvice");

// Only apply advice for tracing parameters as attributes if any of the parameters are annotated
// with @SpanAttribute to avoid unnecessarily copying the arguments into an array.
transformer.applyAdviceToMethod(
tracedMethodsWithParameters,
tracedMethodsWithParameters.and(isMethod()),
WithSpanInstrumentation.class.getName() + "$WithSpanAttributesAdvice");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
@SuppressWarnings("deprecation") // testing instrumentation of deprecated class
public class TracedWithSpan {

public TracedWithSpan() {}

// used to verify that constructor with @WithSpan annotation doesn't break instrumentation
@io.opentelemetry.extension.annotations.WithSpan
public TracedWithSpan(String unused) {}

@io.opentelemetry.extension.annotations.WithSpan
public String otel() {
return "hello!";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import static net.bytebuddy.matcher.ElementMatchers.declaresMethod;
import static net.bytebuddy.matcher.ElementMatchers.hasParameters;
import static net.bytebuddy.matcher.ElementMatchers.isAnnotatedWith;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.not;
import static net.bytebuddy.matcher.ElementMatchers.whereAny;
Expand Down Expand Up @@ -66,13 +67,13 @@ public void transform(TypeTransformer transformer) {
tracedMethods.and(not(annotatedParametersMatcher));

transformer.applyAdviceToMethod(
tracedMethodsWithoutParameters,
tracedMethodsWithoutParameters.and(isMethod()),
WithSpanInstrumentation.class.getName() + "$WithSpanAdvice");

// Only apply advice for tracing parameters as attributes if any of the parameters are annotated
// with @SpanAttribute to avoid unnecessarily copying the arguments into an array.
transformer.applyAdviceToMethod(
tracedMethodsWithParameters,
tracedMethodsWithParameters.and(isMethod()),
WithSpanInstrumentation.class.getName() + "$WithSpanAttributesAdvice");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@

public class TracedWithSpan {

TracedWithSpan() {}

// used to verify that constructor with @WithSpan annotation doesn't break instrumentation
@WithSpan
TracedWithSpan(String unused) {}

@WithSpan
public String otel() {
return "hello!";
Expand Down
Loading