Skip to content

Commit

Permalink
refactor: sonarcloud issues
Browse files Browse the repository at this point in the history
  • Loading branch information
EddeCCC committed Oct 11, 2024
1 parent 5bb7b89 commit 9262fd7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* (C) 2024 */
package rocks.inspectit.gepard.agent.instrumentation.hook.action.exception;

/** Exception errors, while trying to find the SdkSpan class */
public class SdkSpanClassNotFoundException extends RuntimeException {

public SdkSpanClassNotFoundException(String className, Throwable cause) {
super("Could not find the class '" + className + "'", cause);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import io.opentelemetry.sdk.trace.data.SpanData;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import rocks.inspectit.gepard.agent.instrumentation.hook.action.exception.SdkSpanClassNotFoundException;

/**
* Special util class, to access the package private {@link io.opentelemetry.sdk.trace.SdkSpan}
Expand All @@ -16,11 +17,14 @@ public class SpanUtil {
/** The class of {@link io.opentelemetry.sdk.trace.SdkSpan} */
private static final Class<?> SDKSPAN_CLASS;

private SpanUtil() {}

static {
String className = "io.opentelemetry.sdk.trace.SdkSpan";
try {
SDKSPAN_CLASS = Class.forName("io.opentelemetry.sdk.trace.SdkSpan");
SDKSPAN_CLASS = Class.forName(className);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
throw new SdkSpanClassNotFoundException(className, e);
}
}

Expand Down

0 comments on commit 9262fd7

Please sign in to comment.