Capture error message even if no exception object provided.
This is currently only used by the GoogleHttpClient instrumentation, but may be used by customers too.
This commit is contained in:
parent
b3f15ca133
commit
31b77cbd7b
|
@ -4,6 +4,7 @@ import com.google.api.client.http.HttpResponse
|
||||||
import com.google.api.client.http.javanet.NetHttpTransport
|
import com.google.api.client.http.javanet.NetHttpTransport
|
||||||
import datadog.trace.agent.test.base.HttpClientTest
|
import datadog.trace.agent.test.base.HttpClientTest
|
||||||
import datadog.trace.api.DDSpanTypes
|
import datadog.trace.api.DDSpanTypes
|
||||||
|
import datadog.trace.api.DDTags
|
||||||
import datadog.trace.instrumentation.api.Tags
|
import datadog.trace.instrumentation.api.Tags
|
||||||
import datadog.trace.instrumentation.googlehttpclient.GoogleHttpClientDecorator
|
import datadog.trace.instrumentation.googlehttpclient.GoogleHttpClientDecorator
|
||||||
import spock.lang.Shared
|
import spock.lang.Shared
|
||||||
|
@ -69,6 +70,7 @@ abstract class AbstractGoogleHttpClientTest extends HttpClientTest<GoogleHttpCli
|
||||||
"$Tags.HTTP_METHOD" String
|
"$Tags.HTTP_METHOD" String
|
||||||
"$Tags.HTTP_STATUS" Integer
|
"$Tags.HTTP_STATUS" Integer
|
||||||
"$Tags.ERROR" true
|
"$Tags.ERROR" true
|
||||||
|
"$DDTags.ERROR_MSG" "Server Error"
|
||||||
defaultTags()
|
defaultTags()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package datadog.opentracing;
|
package datadog.opentracing;
|
||||||
|
|
||||||
import static io.opentracing.log.Fields.ERROR_OBJECT;
|
import static io.opentracing.log.Fields.ERROR_OBJECT;
|
||||||
|
import static io.opentracing.log.Fields.MESSAGE;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonGetter;
|
import com.fasterxml.jackson.annotation.JsonGetter;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
@ -153,6 +154,9 @@ public class DDSpan implements Span, MutableSpan {
|
||||||
final Throwable error = (Throwable) map.get(ERROR_OBJECT);
|
final Throwable error = (Throwable) map.get(ERROR_OBJECT);
|
||||||
setErrorMeta(error);
|
setErrorMeta(error);
|
||||||
return true;
|
return true;
|
||||||
|
} else if (map.get(MESSAGE) instanceof String) {
|
||||||
|
setTag(DDTags.ERROR_MSG, (String) map.get(MESSAGE));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue