Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.

Commit 5884626

Browse files
felixbarnyyurishkuro
authored andcommitted
Fix try/catch/finally example (#270)
It actually compiles now and also includes how to log an exception
1 parent c187d9d commit 5884626

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,11 @@ This makes the span available in catch and finally blocks.
5555
io.opentracing.Tracer tracer = ...;
5656
...
5757
Span span = tracer.buildSpan("someWork").start();
58-
try (Scope scope = tracer.scopeManager().activate(span, false))
58+
try (Scope scope = tracer.scopeManager().activate(span, false)) {
5959
// Do things.
6060
} catch(Exception ex) {
61-
Tags.ERROR.set(scope.span(), true);
61+
Tags.ERROR.set(span, true);
62+
span.log(Map.of(Fields.EVENT, "error", Fields.ERROR_OBJECT, ex, Fields.MESSAGE, ex.getMessage()));
6263
} finally {
6364
span.finish();
6465
}

0 commit comments

Comments
 (0)