Skip to content

Commit

Permalink
Address review comment
Browse files Browse the repository at this point in the history
Signed-off-by: Gagan Juneja <[email protected]>
  • Loading branch information
Gagan Juneja committed Oct 3, 2023
1 parent d8b8198 commit a4d4ad0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ public void addAttribute(String key, Boolean value) {

@Override
public void setError(Exception exception) {
delegateSpan.setStatus(StatusCode.ERROR, exception != null ? exception.getMessage() : "no description");
if (exception != null) {
delegateSpan.setStatus(StatusCode.ERROR, exception.getMessage());
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ public class TraceableTransportChannel implements TransportChannel {
private final Span span;
private final Tracer tracer;

private final TcpChannel tcpChannel;

/**
* Constructor.
* @param delegate delegate
Expand All @@ -41,7 +39,6 @@ public TraceableTransportChannel(TransportChannel delegate, Span span, Tracer tr
this.delegate = delegate;
this.span = span;
this.tracer = tracer;
this.tcpChannel = tcpChannel;
}

/**
Expand Down Expand Up @@ -88,6 +85,9 @@ public String getChannelType() {
public void sendResponse(TransportResponse response) throws IOException {
try (SpanScope scope = tracer.withSpanInScope(span)) {
delegate.sendResponse(response);
} catch (final IOException ex) {
span.setError(ex);
throw ex;
} finally {
span.endSpan();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ public Long getEndTime() {
}

public void setError(Exception exception) {
putMetadata("ERROR", exception != null ? exception.getMessage() : null);
if (exception != null) {
putMetadata("ERROR", exception.getMessage());
}
}

private static class IdGenerator {
Expand Down

0 comments on commit a4d4ad0

Please sign in to comment.