Missed merge from dd-trace-java
MODIFY
dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/instrumentation/api/AgentSpan.java
dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/instrumentation/api/AgentSpan.java
@@ -13,6 +13,8 @@ public interface AgentSpan {
AgentSpan setError(boolean error);
+ AgentSpan setErrorMessage(String errorMessage);
+
AgentSpan addThrowable(Throwable throwable);
AgentSpan getLocalRootSpan();

MODIFY
dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/instrumentation/api/AgentTracer.java
dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/instrumentation/api/AgentTracer.java
@@ -167,6 +167,11 @@ public class AgentTracer {
return this;
}
+ @Override
+ public AgentSpan setErrorMessage(final String errorMessage) {
+ return this;
+ }
+
@Override
public AgentSpan addThrowable(final Throwable throwable) {
return this;

MODIFY
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/AgentTracerImpl.java
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/AgentTracerImpl.java
@@ -170,6 +170,14 @@ public final class AgentTracerImpl implements TracerAPI {
return this;
}
+ @Override
+ public AgentSpan setErrorMessage(final String errorMessage) {
+ if (span instanceof DDSpan) {
+ ((DDSpan) span).setErrorMessage(errorMessage);
+ }
+ return this;
+ }
+
@Override
public AgentSpan addThrowable(final Throwable throwable) {
if (span instanceof DDSpan) {

MODIFY
dd-java-agent/instrumentation/google-http-client/src/main/java/datadog/trace/instrumentation/googlehttpclient/GoogleHttpClientInstrumentation.java
dd-java-agent/instrumentation/google-http-client/src/main/java/datadog/trace/instrumentation/googlehttpclient/GoogleHttpClientInstrumentation.java
@@ -121,6 +121,7 @@ public class GoogleHttpClientInstrumentation extends Instrumenter.Default {
// for a failed request. Thus, check the response code
if (response != null && !response.isSuccessStatusCode()) {
span.setError(true);
+ span.setErrorMessage(response.getStatusMessage());
}
DECORATE.beforeFinish(span);

MODIFY
dd-java-agent/instrumentation/google-http-client/src/test/groovy/AbstractGoogleHttpClientTest.groovy
dd-java-agent/instrumentation/google-http-client/src/test/groovy/AbstractGoogleHttpClientTest.groovy
@@ -68,6 +68,7 @@ abstract class AbstractGoogleHttpClientTest extends HttpClientTest<GoogleHttpCli
"$Tags.HTTP_URL" "${uri.resolve(uri.path)}"
"$Tags.HTTP_METHOD" method
"$Tags.HTTP_STATUS" 500
+ "$DDTags.ERROR_MSG" "Server Error"
}
}
}

MODIFY
dd-trace-ot/src/main/java/datadog/opentracing/DDSpan.java
dd-trace-ot/src/main/java/datadog/opentracing/DDSpan.java
@@ -120,6 +120,10 @@ public class DDSpan implements Span {
return context().getTrace().getRootSpan();
}
+ public void setErrorMessage(final String errorMessage) {
+ setTag(DDTags.ERROR_MSG, errorMessage);
+ }
+
public void setErrorMeta(final Throwable error) {
setError(true);

Missed merge from dd-trace-java (#47)