Use `io.opentracing.log.Fields.*` instead of hardcoded strings
MODIFY
dd-java-agent/instrumentation/akka-http-10.0/src/main/java/datadog/trace/instrumentation/akkahttp/AkkaHttpServerInstrumentation.java
dd-java-agent/instrumentation/akka-http-10.0/src/main/java/datadog/trace/instrumentation/akkahttp/AkkaHttpServerInstrumentation.java
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) {

MODIFY
dd-java-agent/instrumentation/aws-java-sdk-1.11.0/src/main/java/datadog/trace/instrumentation/aws/v0/SpanDecorator.java
dd-java-agent/instrumentation/aws-java-sdk-1.11.0/src/main/java/datadog/trace/instrumentation/aws/v0/SpanDecorator.java
*/
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;
}

MODIFY
dd-java-agent/instrumentation/aws-java-sdk-1.11.106/src/main/java/datadog/trace/instrumentation/aws/v106/SpanDecorator.java
dd-java-agent/instrumentation/aws-java-sdk-1.11.106/src/main/java/datadog/trace/instrumentation/aws/v106/SpanDecorator.java
*/
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;
}

MODIFY
dd-java-agent/instrumentation/datastax-cassandra-3.2/src/main/java/datadog/trace/instrumentation/datastax/cassandra/TracingSession.java
dd-java-agent/instrumentation/datastax-cassandra-3.2/src/main/java/datadog/trace/instrumentation/datastax/cassandra/TracingSession.java
*/
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;
}

MODIFY
dd-java-agent/instrumentation/jedis-1.4/src/main/java/datadog/trace/instrumentation/jedis/JedisInstrumentation.java
dd-java-agent/instrumentation/jedis-1.4/src/main/java/datadog/trace/instrumentation/jedis/JedisInstrumentation.java
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();
}

MODIFY
dd-java-agent/instrumentation/lettuce-5/src/main/java8/datadog/trace/instrumentation/lettuce/ConnectionFutureAdvice.java
dd-java-agent/instrumentation/lettuce-5/src/main/java8/datadog/trace/instrumentation/lettuce/ConnectionFutureAdvice.java
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;
}

MODIFY
dd-java-agent/instrumentation/lettuce-5/src/main/java8/datadog/trace/instrumentation/lettuce/LettuceAsyncBiFunction.java
dd-java-agent/instrumentation/lettuce-5/src/main/java8/datadog/trace/instrumentation/lettuce/LettuceAsyncBiFunction.java
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();

MODIFY
dd-java-agent/instrumentation/lettuce-5/src/main/java8/datadog/trace/instrumentation/lettuce/LettuceAsyncCommandsAdvice.java
dd-java-agent/instrumentation/lettuce-5/src/main/java8/datadog/trace/instrumentation/lettuce/LettuceAsyncCommandsAdvice.java
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;

MODIFY
dd-java-agent/instrumentation/lettuce-5/src/main/java8/datadog/trace/instrumentation/lettuce/rx/LettuceFluxTerminationRunnable.java
dd-java-agent/instrumentation/lettuce-5/src/main/java8/datadog/trace/instrumentation/lettuce/rx/LettuceFluxTerminationRunnable.java
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 {

MODIFY
dd-java-agent/instrumentation/lettuce-5/src/main/java8/datadog/trace/instrumentation/lettuce/rx/LettuceMonoDualConsumer.java
dd-java-agent/instrumentation/lettuce-5/src/main/java8/datadog/trace/instrumentation/lettuce/rx/LettuceMonoDualConsumer.java
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 {

MODIFY
dd-java-agent/instrumentation/okhttp-3/src/main/java/datadog/trace/instrumentation/okhttp3/OkHttpClientSpanDecorator.java
dd-java-agent/instrumentation/okhttp-3/src/main/java/datadog/trace/instrumentation/okhttp3/OkHttpClientSpanDecorator.java
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.
*

MODIFY
dd-java-agent/instrumentation/play-2.4/src/main/java/datadog/trace/instrumentation/play/PlayInstrumentation.java
dd-java-agent/instrumentation/play-2.4/src/main/java/datadog/trace/instrumentation/play/PlayInstrumentation.java
@@ -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);
}
}

Use `io.opentracing.log.Fields.*` instead of hardcoded strings