Use `io.opentracing.log.Fields.*` instead of hardcoded strings
This commit is contained in:
parent
d4d770fe42
commit
ce7866d018
|
@ -1,5 +1,6 @@
|
|||
package datadog.trace.instrumentation.akkahttp;
|
||||
|
||||
import static io.opentracing.log.Fields.ERROR_OBJECT;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.*;
|
||||
|
||||
import akka.http.javadsl.model.HttpHeader;
|
||||
|
@ -127,7 +128,7 @@ public final class AkkaHttpServerInstrumentation extends Instrumenter.Default {
|
|||
|
||||
public static void finishSpan(Span span, Throwable t) {
|
||||
Tags.ERROR.set(span, true);
|
||||
span.log(Collections.singletonMap("error.object", t));
|
||||
span.log(Collections.singletonMap(ERROR_OBJECT, t));
|
||||
Tags.HTTP_STATUS.set(span, 500);
|
||||
|
||||
if (GlobalTracer.get().scopeManager().active() instanceof TraceScope) {
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
*/
|
||||
package datadog.trace.instrumentation.aws.v0;
|
||||
|
||||
import static io.opentracing.log.Fields.*;
|
||||
|
||||
import com.amazonaws.AmazonWebServiceResponse;
|
||||
import com.amazonaws.Request;
|
||||
import com.amazonaws.Response;
|
||||
|
@ -95,15 +97,15 @@ class SpanDecorator {
|
|||
|
||||
private static Map<String, Object> errorLogs(final Throwable throwable) {
|
||||
final Map<String, Object> errorLogs = new HashMap<>(4);
|
||||
errorLogs.put("event", Tags.ERROR.getKey());
|
||||
errorLogs.put("error.kind", throwable.getClass().getName());
|
||||
errorLogs.put("error.object", throwable);
|
||||
errorLogs.put(EVENT, Tags.ERROR.getKey());
|
||||
errorLogs.put(ERROR_KIND, throwable.getClass().getName());
|
||||
errorLogs.put(ERROR_OBJECT, throwable);
|
||||
|
||||
errorLogs.put("message", throwable.getMessage());
|
||||
errorLogs.put(MESSAGE, throwable.getMessage());
|
||||
|
||||
final StringWriter sw = new StringWriter();
|
||||
throwable.printStackTrace(new PrintWriter(sw));
|
||||
errorLogs.put("stack", sw.toString());
|
||||
errorLogs.put(STACK, sw.toString());
|
||||
|
||||
return errorLogs;
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
*/
|
||||
package datadog.trace.instrumentation.aws.v106;
|
||||
|
||||
import static io.opentracing.log.Fields.*;
|
||||
|
||||
import com.amazonaws.AmazonWebServiceResponse;
|
||||
import com.amazonaws.Request;
|
||||
import com.amazonaws.Response;
|
||||
|
@ -95,15 +97,15 @@ class SpanDecorator {
|
|||
|
||||
private static Map<String, Object> errorLogs(final Throwable throwable) {
|
||||
final Map<String, Object> errorLogs = new HashMap<>(4);
|
||||
errorLogs.put("event", Tags.ERROR.getKey());
|
||||
errorLogs.put("error.kind", throwable.getClass().getName());
|
||||
errorLogs.put("error.object", throwable);
|
||||
errorLogs.put(EVENT, Tags.ERROR.getKey());
|
||||
errorLogs.put(ERROR_KIND, throwable.getClass().getName());
|
||||
errorLogs.put(ERROR_OBJECT, throwable);
|
||||
|
||||
errorLogs.put("message", throwable.getMessage());
|
||||
errorLogs.put(MESSAGE, throwable.getMessage());
|
||||
|
||||
final StringWriter sw = new StringWriter();
|
||||
throwable.printStackTrace(new PrintWriter(sw));
|
||||
errorLogs.put("stack", sw.toString());
|
||||
errorLogs.put(STACK, sw.toString());
|
||||
|
||||
return errorLogs;
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
*/
|
||||
package datadog.trace.instrumentation.datastax.cassandra;
|
||||
|
||||
import static io.opentracing.log.Fields.*;
|
||||
|
||||
import com.datastax.driver.core.BoundStatement;
|
||||
import com.datastax.driver.core.CloseFuture;
|
||||
import com.datastax.driver.core.Cluster;
|
||||
|
@ -295,15 +297,15 @@ class TracingSession implements Session {
|
|||
|
||||
private static Map<String, Object> errorLogs(final Throwable throwable) {
|
||||
final Map<String, Object> errorLogs = new HashMap<>(4);
|
||||
errorLogs.put("event", Tags.ERROR.getKey());
|
||||
errorLogs.put("error.kind", throwable.getClass().getName());
|
||||
errorLogs.put("error.object", throwable);
|
||||
errorLogs.put(EVENT, Tags.ERROR.getKey());
|
||||
errorLogs.put(ERROR_KIND, throwable.getClass().getName());
|
||||
errorLogs.put(ERROR_OBJECT, throwable);
|
||||
|
||||
errorLogs.put("message", throwable.getMessage());
|
||||
errorLogs.put(MESSAGE, throwable.getMessage());
|
||||
|
||||
final StringWriter sw = new StringWriter();
|
||||
throwable.printStackTrace(new PrintWriter(sw));
|
||||
errorLogs.put("stack", sw.toString());
|
||||
errorLogs.put(STACK, sw.toString());
|
||||
|
||||
return errorLogs;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package datadog.trace.instrumentation.jedis;
|
||||
|
||||
import static datadog.trace.agent.tooling.ClassLoaderMatcher.classLoaderHasClasses;
|
||||
import static io.opentracing.log.Fields.ERROR_OBJECT;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
|
@ -82,7 +83,7 @@ public final class JedisInstrumentation extends Instrumenter.Default {
|
|||
if (throwable != null) {
|
||||
final Span span = scope.span();
|
||||
Tags.ERROR.set(span, true);
|
||||
span.log(Collections.singletonMap("error.object", throwable));
|
||||
span.log(Collections.singletonMap(ERROR_OBJECT, throwable));
|
||||
}
|
||||
scope.close();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package datadog.trace.instrumentation.lettuce;
|
||||
|
||||
import static io.opentracing.log.Fields.ERROR_OBJECT;
|
||||
|
||||
import datadog.trace.api.DDTags;
|
||||
import io.lettuce.core.ConnectionFuture;
|
||||
import io.lettuce.core.RedisURI;
|
||||
|
@ -44,7 +46,7 @@ public class ConnectionFutureAdvice {
|
|||
if (throwable != null) {
|
||||
final Span span = scope.span();
|
||||
Tags.ERROR.set(span, true);
|
||||
span.log(Collections.singletonMap("error.object", throwable));
|
||||
span.log(Collections.singletonMap(ERROR_OBJECT, throwable));
|
||||
scope.close();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package datadog.trace.instrumentation.lettuce;
|
||||
|
||||
import static io.opentracing.log.Fields.ERROR_OBJECT;
|
||||
|
||||
import io.opentracing.Span;
|
||||
import io.opentracing.tag.Tags;
|
||||
import java.util.Collections;
|
||||
|
@ -31,7 +33,7 @@ public class LettuceAsyncBiFunction<T extends Object, U extends Throwable, R ext
|
|||
this.span.setTag("db.command.cancelled", true);
|
||||
} else {
|
||||
Tags.ERROR.set(this.span, true);
|
||||
this.span.log(Collections.singletonMap("error.object", throwable));
|
||||
this.span.log(Collections.singletonMap(ERROR_OBJECT, throwable));
|
||||
}
|
||||
}
|
||||
this.span.finish();
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package datadog.trace.instrumentation.lettuce;
|
||||
|
||||
import static io.opentracing.log.Fields.ERROR_OBJECT;
|
||||
|
||||
import datadog.trace.api.DDTags;
|
||||
import io.lettuce.core.protocol.AsyncCommand;
|
||||
import io.lettuce.core.protocol.RedisCommand;
|
||||
|
@ -44,7 +46,7 @@ public class LettuceAsyncCommandsAdvice {
|
|||
final Span span = scope.span();
|
||||
if (throwable != null) {
|
||||
Tags.ERROR.set(span, true);
|
||||
span.log(Collections.singletonMap("error.object", throwable));
|
||||
span.log(Collections.singletonMap(ERROR_OBJECT, throwable));
|
||||
span.finish();
|
||||
scope.close();
|
||||
return;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package datadog.trace.instrumentation.lettuce.rx;
|
||||
|
||||
import static io.opentracing.log.Fields.ERROR_OBJECT;
|
||||
|
||||
import datadog.trace.api.DDTags;
|
||||
import datadog.trace.instrumentation.lettuce.LettuceInstrumentationUtil;
|
||||
import io.opentracing.Scope;
|
||||
|
@ -36,7 +38,7 @@ public class LettuceFluxTerminationRunnable implements Consumer<Signal>, Runnabl
|
|||
}
|
||||
if (throwable != null) {
|
||||
Tags.ERROR.set(this.span, true);
|
||||
this.span.log(Collections.singletonMap("error.object", throwable));
|
||||
this.span.log(Collections.singletonMap(ERROR_OBJECT, throwable));
|
||||
}
|
||||
this.span.finish();
|
||||
} else {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package datadog.trace.instrumentation.lettuce.rx;
|
||||
|
||||
import static io.opentracing.log.Fields.ERROR_OBJECT;
|
||||
|
||||
import datadog.trace.api.DDTags;
|
||||
import datadog.trace.instrumentation.lettuce.LettuceInstrumentationUtil;
|
||||
import io.opentracing.Scope;
|
||||
|
@ -29,7 +31,7 @@ public class LettuceMonoDualConsumer<R, T, U extends Throwable>
|
|||
if (this.span != null) {
|
||||
if (throwable != null) {
|
||||
Tags.ERROR.set(this.span, true);
|
||||
this.span.log(Collections.singletonMap("error.object", throwable));
|
||||
this.span.log(Collections.singletonMap(ERROR_OBJECT, throwable));
|
||||
}
|
||||
this.span.finish();
|
||||
} else {
|
||||
|
|
|
@ -1,18 +1,16 @@
|
|||
package datadog.trace.instrumentation.okhttp3;
|
||||
|
||||
import static io.opentracing.log.Fields.ERROR_OBJECT;
|
||||
|
||||
import io.opentracing.Span;
|
||||
import io.opentracing.tag.Tags;
|
||||
import java.net.Inet4Address;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import okhttp3.Connection;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
||||
import static io.opentracing.log.Fields.ERROR_OBJECT;
|
||||
|
||||
/**
|
||||
* Span decorator to add tags, logs and operation name.
|
||||
*
|
||||
|
|
|
@ -2,6 +2,7 @@ package datadog.trace.instrumentation.play;
|
|||
|
||||
import static datadog.trace.agent.tooling.ClassLoaderMatcher.classLoaderHasClassWithMethod;
|
||||
import static datadog.trace.agent.tooling.ClassLoaderMatcher.classLoaderHasClasses;
|
||||
import static io.opentracing.log.Fields.ERROR_OBJECT;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.*;
|
||||
|
||||
import akka.japi.JavaPartialFunction;
|
||||
|
@ -193,7 +194,7 @@ public final class PlayInstrumentation extends Instrumenter.Default {
|
|||
|
||||
public static void onError(final Span span, final Throwable t) {
|
||||
Tags.ERROR.set(span, Boolean.TRUE);
|
||||
span.log(Collections.singletonMap("error.object", t));
|
||||
span.log(Collections.singletonMap(ERROR_OBJECT, t));
|
||||
Tags.HTTP_STATUS.set(span, 500);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue