Skip to content

Commit

Permalink
jambalaya-junit-opentelemetry switch to slf4j
Browse files Browse the repository at this point in the history
  • Loading branch information
donbeave committed May 31, 2024
1 parent 9a8ab39 commit 0f1b7d1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jambalaya-graphql = "0.10.0"
jambalaya-graphql-apollo = "0.11.0"
jambalaya-graphql-jooq = "0.10.0"
jambalaya-jsr310 = "0.10.0"
jambalaya-junit-opentelemetry = "0.9.0"
jambalaya-junit-opentelemetry = "0.10.0"
jambalaya-kotlin-test = "0.10.0"
jambalaya-mapstruct = "0.9.0"
jambalaya-mapstruct-processor = "0.9.0"
Expand Down
3 changes: 3 additions & 0 deletions jambalaya-junit-opentelemetry/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ dependencies {

// JUnit
implementation(jambalayaLibs.junit.jupiter.api)

// SLF4J
api(jambalayaLibs.slf4j.api)
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.api.extension.InvocationInterceptor;
import org.junit.jupiter.api.extension.ReflectiveInvocationContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;

import static io.opentelemetry.semconv.SemanticAttributes.CODE_FUNCTION;
import static io.opentelemetry.semconv.SemanticAttributes.CODE_NAMESPACE;
Expand All @@ -43,7 +44,7 @@
public class OpenTelemetryExtension implements BeforeEachCallback, AfterEachCallback, AfterAllCallback,
InvocationInterceptor {

private static final Logger logger = Logger.getLogger(OpenTelemetryExtension.class.getName());
private static final Logger logger = LoggerFactory.getLogger(OpenTelemetryExtension.class.getName());

private static Tracer tracer;

Expand Down Expand Up @@ -72,11 +73,9 @@ public void beforeEach(ExtensionContext context) {
spans.put(context.getUniqueId(), span);
scopes.put(context.getUniqueId(), span.makeCurrent());

logger.info(() ->
String.format("Run test %s > %s", context.getRequiredTestClass().getSimpleName(),
context.getDisplayName()));
logger.info(() ->
String.format("Trace ID: %s", span.getSpanContext().getTraceId()));
logger.info(String.format("Run test %s > %s", context.getRequiredTestClass().getSimpleName(),
context.getDisplayName()));
logger.info(String.format("Trace ID: %s", span.getSpanContext().getTraceId()));
}

@Override
Expand Down Expand Up @@ -146,8 +145,7 @@ private void interceptMethod(
span.setAttribute(CODE_FUNCTION, invocationContext.getExecutable().getName());
span.setAttribute(CODE_NAMESPACE, invocationContext.getTargetClass().getName());

logger.info(() ->
String.format(">> %s", spanName));
logger.info(String.format(">> %s", spanName));

try (Scope ignored = span.makeCurrent()) {
invocation.proceed();
Expand Down

0 comments on commit 0f1b7d1

Please sign in to comment.