Skip to content

Commit

Permalink
Replaces slf4j loggers with JUL
Browse files Browse the repository at this point in the history
  • Loading branch information
anuragagarwal561994 committed Mar 28, 2022
1 parent 4d6f4c0 commit 35a427c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.implementsInterface;
import static io.opentelemetry.javaagent.instrumentation.apachehttpasyncclient.ApacheHttpAsyncClientSingletons.instrumenter;
import static io.opentelemetry.javaagent.instrumentation.api.Java8BytecodeBridge.currentContext;
import static java.util.logging.Level.FINE;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
Expand All @@ -19,6 +20,7 @@
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
import java.io.IOException;
import java.util.logging.Logger;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
Expand All @@ -32,8 +34,6 @@
import org.apache.hc.core5.http.nio.RequestChannel;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.hc.core5.http.protocol.HttpCoreContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ApacheHttpAsyncClientInstrumentation implements TypeInstrumentation {

Expand Down Expand Up @@ -158,7 +158,7 @@ public void sendRequest(HttpRequest request, EntityDetails entityDetails, HttpCo

public static class WrappedFutureCallback<T> implements FutureCallback<T> {

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

private final Context parentContext;
private final HttpContext httpContext;
Expand All @@ -179,7 +179,7 @@ public WrappedFutureCallback(
public void completed(T result) {
if (context == null) {
// this is unexpected
logger.debug("context was never set");
logger.log(FINE, "context was never set");
completeDelegate(result);
return;
}
Expand All @@ -200,7 +200,7 @@ public void completed(T result) {
public void failed(Exception ex) {
if (context == null) {
// this is unexpected
logger.debug("context was never set");
logger.log(FINE, "context was never set");
failDelegate(ex);
return;
}
Expand All @@ -222,7 +222,7 @@ public void failed(Exception ex) {
public void cancelled() {
if (context == null) {
// this is unexpected
logger.debug("context was never set");
logger.log(FINE, "context was never set");
cancelDelegate();
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,25 @@

package io.opentelemetry.javaagent.instrumentation.apachehttpasyncclient;

import static java.util.logging.Level.FINE;

import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.logging.Logger;
import javax.annotation.Nullable;
import org.apache.hc.core5.http.EntityDetails;
import org.apache.hc.core5.http.Header;
import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.ProtocolVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public final class ApacheHttpClientRequest {

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

@Nullable private final URI uri;

Expand Down Expand Up @@ -87,7 +88,7 @@ public String getFlavor(HttpResponse response) {
if (major == 2 && minor == 0) {
return SemanticAttributes.HttpFlavorValues.HTTP_2_0;
}
logger.debug("unexpected http protocol version: " + protocolVersion);
logger.log(FINE, "unexpected http protocol version: " + protocolVersion);
return null;
}

Expand All @@ -109,7 +110,7 @@ public Integer getPeerPort() {
case "https":
return 443;
default:
logger.debug("no default port mapping for scheme: {}", uri.getScheme());
logger.log(FINE, "no default port mapping for scheme: {}", uri.getScheme());
return null;
}
}
Expand All @@ -120,7 +121,7 @@ private static URI getUri(HttpRequest httpRequest) {
// this can be relative or absolute
return httpRequest.getUri();
} catch (URISyntaxException e) {
logger.debug(e.getMessage(), e);
logger.log(FINE, e.getMessage(), e);
return null;
}
}
Expand Down

0 comments on commit 35a427c

Please sign in to comment.