catch and log throwables to support kotlin exception handling

This commit is contained in:
Marco Ferrer 2018-10-30 23:00:29 -04:00
parent 428a0bf66e
commit 1bd97a0f90
2 changed files with 12 additions and 12 deletions

View File

@ -47,7 +47,7 @@ public class TracingClientInterceptor implements ClientInterceptor {
try {
// call other interceptors
result = next.newCall(method, callOptions);
} catch (final RuntimeException | Error e) {
} catch (final Throwable e) {
Tags.ERROR.set(span, true);
span.log(Collections.singletonMap(ERROR_OBJECT, e));
span.finish();
@ -77,7 +77,7 @@ public class TracingClientInterceptor implements ClientInterceptor {
try (final Scope ignored = tracer.scopeManager().activate(span, false)) {
super.start(new TracingClientCallListener<>(tracer, span, responseListener), headers);
} catch (final RuntimeException | Error e) {
} catch (final Throwable e) {
Tags.ERROR.set(span, true);
span.log(Collections.singletonMap(ERROR_OBJECT, e));
span.finish();
@ -89,7 +89,7 @@ public class TracingClientInterceptor implements ClientInterceptor {
public void sendMessage(final ReqT message) {
try (final Scope ignored = tracer.scopeManager().activate(span, false)) {
super.sendMessage(message);
} catch (final RuntimeException | Error e) {
} catch (final Throwable e) {
Tags.ERROR.set(span, true);
span.log(Collections.singletonMap(ERROR_OBJECT, e));
span.finish();
@ -122,7 +122,7 @@ public class TracingClientInterceptor implements ClientInterceptor {
.startActive(true);
try {
delegate().onMessage(message);
} catch (final RuntimeException | Error e) {
} catch (final Throwable e) {
final Span span = scope.span();
Tags.ERROR.set(span, true);
this.span.log(Collections.singletonMap(ERROR_OBJECT, e));
@ -148,7 +148,7 @@ public class TracingClientInterceptor implements ClientInterceptor {
// Finishes span.
try (final Scope ignored = tracer.scopeManager().activate(span, true)) {
delegate().onClose(status, trailers);
} catch (final RuntimeException | Error e) {
} catch (final Throwable e) {
Tags.ERROR.set(span, true);
span.log(Collections.singletonMap(ERROR_OBJECT, e));
span.finish();
@ -160,7 +160,7 @@ public class TracingClientInterceptor implements ClientInterceptor {
public void onReady() {
try (final Scope ignored = tracer.scopeManager().activate(span, false)) {
delegate().onReady();
} catch (final RuntimeException | Error e) {
} catch (final Throwable e) {
Tags.ERROR.set(span, true);
span.log(Collections.singletonMap(ERROR_OBJECT, e));
span.finish();

View File

@ -66,7 +66,7 @@ public class TracingServerInterceptor implements ServerInterceptor {
try {
// call other interceptors
result = next.startCall(call, headers);
} catch (final RuntimeException | Error e) {
} catch (final Throwable e) {
Tags.ERROR.set(span, true);
span.log(Collections.singletonMap(ERROR_OBJECT, e));
span.finish();
@ -109,7 +109,7 @@ public class TracingServerInterceptor implements ServerInterceptor {
}
try {
delegate().onMessage(message);
} catch (final RuntimeException | Error e) {
} catch (final Throwable e) {
final Span span = scope.span();
Tags.ERROR.set(span, true);
this.span.log(Collections.singletonMap(ERROR_OBJECT, e));
@ -133,7 +133,7 @@ public class TracingServerInterceptor implements ServerInterceptor {
if (scope instanceof TraceScope) {
((TraceScope) scope).setAsyncPropagation(false);
}
} catch (final RuntimeException | Error e) {
} catch (final Throwable e) {
Tags.ERROR.set(span, true);
span.log(Collections.singletonMap(ERROR_OBJECT, e));
span.finish();
@ -153,7 +153,7 @@ public class TracingServerInterceptor implements ServerInterceptor {
if (scope instanceof TraceScope) {
((TraceScope) scope).setAsyncPropagation(false);
}
} catch (final RuntimeException | Error e) {
} catch (final Throwable e) {
Tags.ERROR.set(span, true);
span.log(Collections.singletonMap(ERROR_OBJECT, e));
span.finish();
@ -172,7 +172,7 @@ public class TracingServerInterceptor implements ServerInterceptor {
if (scope instanceof TraceScope) {
((TraceScope) scope).setAsyncPropagation(false);
}
} catch (final RuntimeException | Error e) {
} catch (final Throwable e) {
Tags.ERROR.set(span, true);
span.log(Collections.singletonMap(ERROR_OBJECT, e));
span.finish();
@ -190,7 +190,7 @@ public class TracingServerInterceptor implements ServerInterceptor {
if (scope instanceof TraceScope) {
((TraceScope) scope).setAsyncPropagation(false);
}
} catch (final RuntimeException | Error e) {
} catch (final Throwable e) {
Tags.ERROR.set(span, true);
span.log(Collections.singletonMap(ERROR_OBJECT, e));
span.finish();