Skip to content

Commit

Permalink
Rename ErrorCauseExtractor.jdk() to getDefault() (open-telemetry#6580)
Browse files Browse the repository at this point in the history
* Rename ErrorCauseExtractor.jdk() to ErrorCauseExtractor.getDefault()

* jApiCmp
  • Loading branch information
trask authored and LironKS committed Oct 23, 2022
1 parent 8ecfdfb commit 944e032
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -42,5 +42,5 @@ private static Class<?> getCompletionExceptionClass() {
}
}

private JdkErrorCauseExtractor() {}
private DefaultErrorCauseExtractor() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public final class InstrumenterBuilder<REQUEST, RESPONSE> {
SpanKindExtractor<? super REQUEST> spanKindExtractor = SpanKindExtractor.alwaysInternal();
SpanStatusExtractor<? super REQUEST, ? super RESPONSE> spanStatusExtractor =
SpanStatusExtractor.getDefault();
ErrorCauseExtractor errorCauseExtractor = ErrorCauseExtractor.jdk();
ErrorCauseExtractor errorCauseExtractor = ErrorCauseExtractor.getDefault();
boolean enabled = true;

InstrumenterBuilder(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

class JdkErrorCauseExtractorTest {
class DefaultErrorCauseExtractorTest {

@ParameterizedTest
@ValueSource(
Expand All @@ -31,15 +31,15 @@ void unwraps(Class<? extends Exception> 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");
}

@Test
void multipleUnwraps() {
assertThat(
ErrorCauseExtractor.jdk()
ErrorCauseExtractor.getDefault()
.extract(
new ExecutionException(
new UndeclaredThrowableException(new IllegalArgumentException("test")))))
Expand All @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> capturedHeaders = emptyList();
private boolean captureExperimentalSpanAttributes = false;
private boolean propagationEnabled = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 944e032

Please sign in to comment.