From 944e03204a1f4f659aa4b067d990d477192919be Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Mon, 12 Sep 2022 07:36:34 -0700 Subject: [PATCH] Rename ErrorCauseExtractor.jdk() to getDefault() (#6580) * Rename ErrorCauseExtractor.jdk() to ErrorCauseExtractor.getDefault() * jApiCmp --- .../opentelemetry-instrumentation-api.txt | 2 +- ...eExtractor.java => DefaultErrorCauseExtractor.java} | 6 +++--- .../api/instrumenter/ErrorCauseExtractor.java | 6 +++--- .../api/instrumenter/InstrumenterBuilder.java | 2 +- ...orTest.java => DefaultErrorCauseExtractorTest.java} | 10 +++++----- .../instrumentation/jsf/JsfErrorCauseExtractor.java | 2 +- .../kafka/internal/KafkaInstrumenterFactory.java | 2 +- .../instrumentation/ratpack/RatpackSingletons.java | 2 +- .../servlet/ServletErrorCauseExtractor.java | 2 +- .../kafka/v2_7/SpringKafkaErrorCauseExtractor.java | 2 +- .../instrumentation/tapestry/TapestrySingletons.java | 2 +- 11 files changed, 19 insertions(+), 19 deletions(-) rename instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/{JdkErrorCauseExtractor.java => DefaultErrorCauseExtractor.java} (87%) rename instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/{JdkErrorCauseExtractorTest.java => DefaultErrorCauseExtractorTest.java} (85%) diff --git a/docs/apidiffs/current_vs_latest/opentelemetry-instrumentation-api.txt b/docs/apidiffs/current_vs_latest/opentelemetry-instrumentation-api.txt index be6bccb8f617..7253ba8f20ae 100644 --- a/docs/apidiffs/current_vs_latest/opentelemetry-instrumentation-api.txt +++ b/docs/apidiffs/current_vs_latest/opentelemetry-instrumentation-api.txt @@ -14,7 +14,7 @@ Comparing source compatibility of against +++ CLASS FILE FORMAT VERSION: 52.0 <- n.a. +++ NEW SUPERCLASS: java.lang.Object +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.lang.Throwable extract(java.lang.Throwable) - +++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.instrumentation.api.instrumenter.ErrorCauseExtractor jdk() + +++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.instrumentation.api.instrumenter.ErrorCauseExtractor getDefault() +++ NEW ANNOTATION: java.lang.FunctionalInterface +++ NEW CLASS: PUBLIC(+) io.opentelemetry.instrumentation.api.instrumenter.Instrumenter (not serializable) +++ CLASS FILE FORMAT VERSION: 52.0 <- n.a. diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/JdkErrorCauseExtractor.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/DefaultErrorCauseExtractor.java similarity index 87% rename from instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/JdkErrorCauseExtractor.java rename to instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/DefaultErrorCauseExtractor.java index a9474b7ec590..b2dd00ef91be 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/JdkErrorCauseExtractor.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/DefaultErrorCauseExtractor.java @@ -10,8 +10,8 @@ import java.util.concurrent.ExecutionException; import javax.annotation.Nullable; -final class JdkErrorCauseExtractor implements ErrorCauseExtractor { - static final ErrorCauseExtractor INSTANCE = new JdkErrorCauseExtractor(); +final class DefaultErrorCauseExtractor implements ErrorCauseExtractor { + static final ErrorCauseExtractor INSTANCE = new DefaultErrorCauseExtractor(); @Nullable private static final Class COMPLETION_EXCEPTION_CLASS = getCompletionExceptionClass(); @@ -42,5 +42,5 @@ private static Class getCompletionExceptionClass() { } } - private JdkErrorCauseExtractor() {} + private DefaultErrorCauseExtractor() {} } diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/ErrorCauseExtractor.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/ErrorCauseExtractor.java index dfd08415e60d..d744b88e5953 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/ErrorCauseExtractor.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/ErrorCauseExtractor.java @@ -17,10 +17,10 @@ public interface ErrorCauseExtractor { Throwable extract(Throwable error); /** - * Returns a {@link ErrorCauseExtractor} which unwraps common standard library wrapping + * Returns the default {@link ErrorCauseExtractor}, which unwraps common standard library wrapping * exceptions. */ - static ErrorCauseExtractor jdk() { - return JdkErrorCauseExtractor.INSTANCE; + static ErrorCauseExtractor getDefault() { + return DefaultErrorCauseExtractor.INSTANCE; } } diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/InstrumenterBuilder.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/InstrumenterBuilder.java index ee78d5aeb711..c68dc97b07d7 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/InstrumenterBuilder.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/InstrumenterBuilder.java @@ -57,7 +57,7 @@ public final class InstrumenterBuilder { SpanKindExtractor spanKindExtractor = SpanKindExtractor.alwaysInternal(); SpanStatusExtractor spanStatusExtractor = SpanStatusExtractor.getDefault(); - ErrorCauseExtractor errorCauseExtractor = ErrorCauseExtractor.jdk(); + ErrorCauseExtractor errorCauseExtractor = ErrorCauseExtractor.getDefault(); boolean enabled = true; InstrumenterBuilder( diff --git a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/JdkErrorCauseExtractorTest.java b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/DefaultErrorCauseExtractorTest.java similarity index 85% rename from instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/JdkErrorCauseExtractorTest.java rename to instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/DefaultErrorCauseExtractorTest.java index 02cbaf161612..cb17e46dc7db 100644 --- a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/JdkErrorCauseExtractorTest.java +++ b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/DefaultErrorCauseExtractorTest.java @@ -15,7 +15,7 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; -class JdkErrorCauseExtractorTest { +class DefaultErrorCauseExtractorTest { @ParameterizedTest @ValueSource( @@ -31,7 +31,7 @@ void unwraps(Class exceptionClass) throws Exception { .getConstructor(Throwable.class) .newInstance(new IllegalArgumentException("test")); - assertThat(ErrorCauseExtractor.jdk().extract(exception)) + assertThat(ErrorCauseExtractor.getDefault().extract(exception)) .isInstanceOf(IllegalArgumentException.class) .hasMessage("test"); } @@ -39,7 +39,7 @@ void unwraps(Class exceptionClass) throws Exception { @Test void multipleUnwraps() { assertThat( - ErrorCauseExtractor.jdk() + ErrorCauseExtractor.getDefault() .extract( new ExecutionException( new UndeclaredThrowableException(new IllegalArgumentException("test"))))) @@ -49,11 +49,11 @@ void multipleUnwraps() { @Test void notWrapped() { - assertThat(ErrorCauseExtractor.jdk().extract(new IllegalArgumentException("test"))) + assertThat(ErrorCauseExtractor.getDefault().extract(new IllegalArgumentException("test"))) .isInstanceOf(IllegalArgumentException.class) .hasMessage("test"); assertThat( - ErrorCauseExtractor.jdk() + ErrorCauseExtractor.getDefault() .extract(new IllegalArgumentException("test", new IllegalStateException("state")))) .isInstanceOf(IllegalArgumentException.class) .hasMessage("test"); diff --git a/instrumentation/jsf/jsf-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jsf/JsfErrorCauseExtractor.java b/instrumentation/jsf/jsf-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jsf/JsfErrorCauseExtractor.java index c6f9d1280a73..598c49f7d4d8 100644 --- a/instrumentation/jsf/jsf-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jsf/JsfErrorCauseExtractor.java +++ b/instrumentation/jsf/jsf-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jsf/JsfErrorCauseExtractor.java @@ -15,6 +15,6 @@ public Throwable extract(Throwable error) { while (error.getCause() != null && error instanceof FacesException) { error = error.getCause(); } - return ErrorCauseExtractor.jdk().extract(error); + return ErrorCauseExtractor.getDefault().extract(error); } } diff --git a/instrumentation/kafka/kafka-clients/kafka-clients-common/library/src/main/java/io/opentelemetry/instrumentation/kafka/internal/KafkaInstrumenterFactory.java b/instrumentation/kafka/kafka-clients/kafka-clients-common/library/src/main/java/io/opentelemetry/instrumentation/kafka/internal/KafkaInstrumenterFactory.java index 20ca8229cf12..e0d65985d346 100644 --- a/instrumentation/kafka/kafka-clients/kafka-clients-common/library/src/main/java/io/opentelemetry/instrumentation/kafka/internal/KafkaInstrumenterFactory.java +++ b/instrumentation/kafka/kafka-clients/kafka-clients-common/library/src/main/java/io/opentelemetry/instrumentation/kafka/internal/KafkaInstrumenterFactory.java @@ -32,7 +32,7 @@ public final class KafkaInstrumenterFactory { private final OpenTelemetry openTelemetry; private final String instrumentationName; - private ErrorCauseExtractor errorCauseExtractor = ErrorCauseExtractor.jdk(); + private ErrorCauseExtractor errorCauseExtractor = ErrorCauseExtractor.getDefault(); private List capturedHeaders = emptyList(); private boolean captureExperimentalSpanAttributes = false; private boolean propagationEnabled = true; diff --git a/instrumentation/ratpack/ratpack-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/ratpack/RatpackSingletons.java b/instrumentation/ratpack/ratpack-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/ratpack/RatpackSingletons.java index 9f3ac15a5e73..4e386bf6ef29 100644 --- a/instrumentation/ratpack/ratpack-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/ratpack/RatpackSingletons.java +++ b/instrumentation/ratpack/ratpack-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/ratpack/RatpackSingletons.java @@ -50,7 +50,7 @@ public static String updateServerSpanName( public static void onError(io.opentelemetry.context.Context context, Throwable error) { Span span = Span.fromContext(context); span.setStatus(StatusCode.ERROR); - span.recordException(ErrorCauseExtractor.jdk().extract(error)); + span.recordException(ErrorCauseExtractor.getDefault().extract(error)); } private RatpackSingletons() {} diff --git a/instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletErrorCauseExtractor.java b/instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletErrorCauseExtractor.java index 9538bbe02650..6b949c32369c 100644 --- a/instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletErrorCauseExtractor.java +++ b/instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletErrorCauseExtractor.java @@ -19,6 +19,6 @@ public Throwable extract(Throwable error) { if (accessor.isServletException(error) && error.getCause() != null) { error = error.getCause(); } - return ErrorCauseExtractor.jdk().extract(error); + return ErrorCauseExtractor.getDefault().extract(error); } } diff --git a/instrumentation/spring/spring-kafka-2.7/library/src/main/java/io/opentelemetry/instrumentation/spring/kafka/v2_7/SpringKafkaErrorCauseExtractor.java b/instrumentation/spring/spring-kafka-2.7/library/src/main/java/io/opentelemetry/instrumentation/spring/kafka/v2_7/SpringKafkaErrorCauseExtractor.java index c15ba829244c..463ce1b13b0d 100644 --- a/instrumentation/spring/spring-kafka-2.7/library/src/main/java/io/opentelemetry/instrumentation/spring/kafka/v2_7/SpringKafkaErrorCauseExtractor.java +++ b/instrumentation/spring/spring-kafka-2.7/library/src/main/java/io/opentelemetry/instrumentation/spring/kafka/v2_7/SpringKafkaErrorCauseExtractor.java @@ -16,6 +16,6 @@ public Throwable extract(Throwable error) { if (error instanceof ListenerExecutionFailedException && error.getCause() != null) { error = error.getCause(); } - return ErrorCauseExtractor.jdk().extract(error); + return ErrorCauseExtractor.getDefault().extract(error); } } diff --git a/instrumentation/tapestry-5.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tapestry/TapestrySingletons.java b/instrumentation/tapestry-5.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tapestry/TapestrySingletons.java index fd906e06bf09..e3e2e279885e 100644 --- a/instrumentation/tapestry-5.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tapestry/TapestrySingletons.java +++ b/instrumentation/tapestry-5.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tapestry/TapestrySingletons.java @@ -25,7 +25,7 @@ public class TapestrySingletons { if (error instanceof ComponentEventException) { error = error.getCause(); } - return ErrorCauseExtractor.jdk().extract(error); + return ErrorCauseExtractor.getDefault().extract(error); }) .setEnabled(ExperimentalConfig.get().controllerTelemetryEnabled()) .buildInstrumenter();