Skip to content

Commit

Permalink
Excavator: Migrate to the logsafe SafeLogger API (#752)
Browse files Browse the repository at this point in the history
  • Loading branch information
svc-excavator-bot authored Aug 2, 2021
1 parent 5efa9c8 commit 2312400
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 16 deletions.
2 changes: 1 addition & 1 deletion tracing-servlet/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies {
// servlet-api should be the only exposed dependency
api "jakarta.servlet:jakarta.servlet-api"

implementation "org.slf4j:slf4j-api"
implementation 'com.palantir.safe-logging:logger'

testImplementation "io.dropwizard:dropwizard-testing"
testImplementation "junit:junit"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

import com.palantir.logsafe.SafeArg;
import com.palantir.logsafe.UnsafeArg;
import com.palantir.logsafe.logger.SafeLogger;
import com.palantir.logsafe.logger.SafeLoggerFactory;
import com.palantir.tracing.Trace;
import com.palantir.tracing.Tracer;
import java.io.IOException;
Expand All @@ -29,8 +31,6 @@
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Guarantees clean {@link Tracer} thread state for incoming requests. This {@link Filter} logs at
Expand All @@ -41,7 +41,7 @@
* by this filter has leaked state.
*/
public final class LeakedTraceFilter implements Filter {
private static final Logger log = LoggerFactory.getLogger(LeakedTraceFilter.class);
private static final SafeLogger log = SafeLoggerFactory.get(LeakedTraceFilter.class);

@Override
public void init(FilterConfig _value) {
Expand Down
1 change: 1 addition & 0 deletions tracing-undertow/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ dependencies {
implementation project(':tracing-api')
implementation 'com.google.guava:guava'
implementation 'com.palantir.safe-logging:preconditions'
implementation 'com.palantir.safe-logging:logger'

// Required for tests using the slf4j MDC which is not implemented in slf4j-simple
testImplementation 'ch.qos.logback:logback-classic'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import com.google.common.base.Strings;
import com.palantir.logsafe.SafeArg;
import com.palantir.logsafe.exceptions.SafeIllegalStateException;
import com.palantir.logsafe.logger.SafeLogger;
import com.palantir.logsafe.logger.SafeLoggerFactory;
import com.palantir.tracing.DetachedSpan;
import com.palantir.tracing.InternalTracers;
import com.palantir.tracing.Observability;
Expand All @@ -33,16 +35,14 @@
import io.undertow.util.HeaderMap;
import io.undertow.util.HttpString;
import java.util.Optional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Internal utility functionality shared between {@link TracedOperationHandler} and {@link TracedRequestHandler}.
* Intentionally package private.
*/
final class UndertowTracing {

private static final Logger log = LoggerFactory.getLogger(UndertowTracing.class);
private static final SafeLogger log = SafeLoggerFactory.get(UndertowTracing.class);

// Tracing header definitions
private static final HttpString TRACE_ID = HttpString.tryFromString(TraceHttpHeaders.TRACE_ID);
Expand Down
1 change: 1 addition & 0 deletions tracing/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ dependencies {
compile "com.palantir.safe-logging:safe-logging"
compile "org.slf4j:slf4j-api"

implementation 'com.palantir.safe-logging:logger'
implementation 'com.fasterxml.jackson.core:jackson-annotations'
implementation 'com.fasterxml.jackson.core:jackson-core'
implementation 'com.google.code.findbugs:jsr305'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
import com.palantir.logsafe.SafeArg;
import com.palantir.logsafe.logger.SafeLogger;
import com.palantir.logsafe.logger.SafeLoggerFactory;
import com.palantir.tracing.api.Span;
import com.palantir.tracing.api.SpanObserver;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.atomic.AtomicInteger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/** A {@link SpanObserver} whose observations are executed on a supplied {@link ExecutorService}. */
public abstract class AsyncSpanObserver implements SpanObserver {

private static final Logger log = LoggerFactory.getLogger(AsyncSpanObserver.class);
private static final SafeLogger log = SafeLoggerFactory.get(AsyncSpanObserver.class);
private static final int DEFAULT_MAX_INFLIGHTS = 10_000;

private final ListeningExecutorService executorService;
Expand Down
6 changes: 3 additions & 3 deletions tracing/src/main/java/com/palantir/tracing/Tracer.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import com.palantir.logsafe.exceptions.SafeIllegalArgumentException;
import com.palantir.logsafe.exceptions.SafeIllegalStateException;
import com.palantir.logsafe.exceptions.SafeRuntimeException;
import com.palantir.logsafe.logger.SafeLogger;
import com.palantir.logsafe.logger.SafeLoggerFactory;
import com.palantir.tracing.api.OpenSpan;
import com.palantir.tracing.api.Span;
import com.palantir.tracing.api.SpanObserver;
Expand All @@ -41,8 +43,6 @@
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
import java.util.function.Consumer;
import javax.annotation.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;

/**
Expand All @@ -53,7 +53,7 @@
*/
public final class Tracer {

private static final Logger log = LoggerFactory.getLogger(Tracer.class);
private static final SafeLogger log = SafeLoggerFactory.get(Tracer.class);

private Tracer() {}

Expand Down
9 changes: 6 additions & 3 deletions versions.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ com.fasterxml.jackson.core:jackson-core:2.12.3 (18 constraints: f5617cda)
com.fasterxml.jackson.core:jackson-databind:2.12.3 (26 constraints: 8cf4d2b4)
com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.12.3 (4 constraints: 1e3f528b)
com.google.code.findbugs:jsr305:3.0.2 (16 constraints: 50e8dc30)
com.google.errorprone:error_prone_annotations:2.5.1 (3 constraints: 1c2b3fe9)
com.google.errorprone:error_prone_annotations:2.5.1 (6 constraints: ab58734d)
com.google.guava:failureaccess:1.0.1 (1 constraints: 140ae1b4)
com.google.guava:guava:28.2-jre (6 constraints: 5d5b5723)
com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava (1 constraints: bd17c918)
com.google.j2objc:j2objc-annotations:1.3 (1 constraints: b809eda0)
com.palantir.safe-logging:logger:1.18.0 (1 constraints: 3c05413b)
com.palantir.safe-logging:logger-slf4j:1.18.0 (1 constraints: 350e9350)
com.palantir.safe-logging:logger-spi:1.18.0 (2 constraints: 791e0cb1)
com.palantir.safe-logging:preconditions:1.18.0 (3 constraints: 19364d74)
com.palantir.safe-logging:safe-logging:1.18.0 (3 constraints: cf2ab885)
com.palantir.safe-logging:safe-logging:1.18.0 (5 constraints: b0485624)
com.squareup.okhttp3:okhttp:3.9.0 (1 constraints: 0e051536)
com.squareup.okio:okio:1.13.0 (1 constraints: 7f0cb509)
io.undertow:undertow-core:2.0.17.Final (1 constraints: 54072861)
Expand All @@ -34,7 +37,7 @@ org.jboss.xnio:xnio-api:3.3.8.Final (2 constraints: 6f1a4d45)
org.jboss.xnio:xnio-nio:3.3.8.Final (1 constraints: c40da530)
org.openjdk.jmh:jmh-core:1.32 (2 constraints: ed155dd8)
org.openjdk.jmh:jmh-generator-annprocess:1.32 (1 constraints: da04f730)
org.slf4j:slf4j-api:1.7.31 (25 constraints: a06b8313)
org.slf4j:slf4j-api:1.7.31 (26 constraints: e67b4d74)

[Test dependencies]
ch.qos.logback:logback-access:1.2.3 (1 constraints: b41148e2)
Expand Down

0 comments on commit 2312400

Please sign in to comment.