From 42e08a4a04db0f05176132a50f42c70e2c48faf2 Mon Sep 17 00:00:00 2001 From: Andrew Kent Date: Wed, 22 Nov 2017 13:23:44 -0800 Subject: [PATCH] Add error reporting documentation. --- dd-trace/docs/opentracing-api.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/dd-trace/docs/opentracing-api.md b/dd-trace/docs/opentracing-api.md index 4518652f50..4ed799cb35 100644 --- a/dd-trace/docs/opentracing-api.md +++ b/dd-trace/docs/opentracing-api.md @@ -114,6 +114,23 @@ Baggage is very similar to tags, but has important distinctions. Baggage is: valuableSpan.setBaggageItem("username", "modernmajorgeneral"); ``` +### Errors + +Errors are manually captured in a span by setting the error flag and logging the error attributes. + +```java + try { + // your code + } catch (Exception e) { + // capture error + ActiveSpan span = GlobalTracer.get().activeSpan(); + Tags.ERROR.set(span, Boolean.TRUE); + span.log(Collections.singletonMap("error.object", e)); + + // recovery code + } +``` + ## OpenTracing Asynchronous API An `ActiveSpan` can generate a `Continuation` as a way of propagating traces from across a thread boundary.