Skip to content

Commit

Permalink
remove support for deprecated @WithSpan annotation from spring starter (
Browse files Browse the repository at this point in the history
  • Loading branch information
zeitlinger committed Feb 13, 2024
1 parent 4d70bb3 commit d73304b
Show file tree
Hide file tree
Showing 9 changed files with 423 additions and 639 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,4 @@ public class InstrumentationAnnotationsAutoConfiguration {
InstrumentationWithSpanAspect otelInstrumentationWithSpanAspect(OpenTelemetry openTelemetry) {
return new InstrumentationWithSpanAspect(openTelemetry, parameterNameDiscoverer);
}

@Bean
@SuppressWarnings("deprecation") // instrumenting deprecated class for backwards compatibility
@ConditionalOnClass(io.opentelemetry.extension.annotations.WithSpan.class)
SdkExtensionWithSpanAspect otelSdkExtensionWithSpanAspect(OpenTelemetry openTelemetry) {
return new SdkExtensionWithSpanAspect(openTelemetry, parameterNameDiscoverer);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,25 +69,4 @@ public JoinPointRequest create(JoinPoint joinPoint) {
return new JoinPointRequest(joinPoint, method, spanName, spanKind);
}
}

static final class SdkExtensionAnnotationFactory implements Factory {

@Override
@SuppressWarnings("deprecation") // instrumenting deprecated class for backwards compatibility
public JoinPointRequest create(JoinPoint joinPoint) {
MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
Method method = methodSignature.getMethod();

// in rare cases, when interface method does not have annotations but the implementation does,
// and the AspectJ factory is configured to proxy interfaces, this class will receive the
// abstract interface method (without annotations) instead of the implementation method (with
// annotations); these defaults prevent NPEs in this scenario
io.opentelemetry.extension.annotations.WithSpan annotation =
method.getDeclaredAnnotation(io.opentelemetry.extension.annotations.WithSpan.class);
String spanName = annotation != null ? annotation.value() : "";
SpanKind spanKind = annotation != null ? annotation.kind() : SpanKind.INTERNAL;

return new JoinPointRequest(joinPoint, method, spanName, spanKind);
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
import org.springframework.core.ParameterNameDiscoverer;

/**
* Uses Spring-AOP to wrap methods marked by {@link WithSpan} (or the deprecated {@link
* io.opentelemetry.extension.annotations.WithSpan}) in a {@link Span}.
* Uses Spring-AOP to wrap methods marked by {@link WithSpan} in a {@link Span}.
*
* <p>Ensure methods annotated with {@link WithSpan} are implemented on beans managed by the Spring
* container.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,4 @@ public String spanAttributeName(Parameter parameter) {
return annotation == null ? null : annotation.value();
}
}

static final class SdkExtensionAnnotationAttributeNameSupplier
implements SpanAttributeNameSupplier {

@Nullable
@Override
@SuppressWarnings("deprecation") // instrumenting deprecated class for backwards compatibility
public String spanAttributeName(Parameter parameter) {
io.opentelemetry.extension.annotations.SpanAttribute annotation =
parameter.getDeclaredAnnotation(
io.opentelemetry.extension.annotations.SpanAttribute.class);
return annotation == null ? null : annotation.value();
}
}
}
Loading

0 comments on commit d73304b

Please sign in to comment.