Skip to content

Commit

Permalink
End grpc server span in onComplete instead of close
Browse files Browse the repository at this point in the history
  • Loading branch information
laurit committed Apr 18, 2024
1 parent 1da8f5e commit 0b9ca3d
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ final class TracingServerCall<REQUEST, RESPONSE>
extends ForwardingServerCall.SimpleForwardingServerCall<REQUEST, RESPONSE> {
private final Context context;
private final GrpcRequest request;
private Status status;

// Used by MESSAGE_ID_UPDATER
@SuppressWarnings("UnusedVariable")
Expand Down Expand Up @@ -101,13 +102,13 @@ public void sendMessage(RESPONSE message) {

@Override
public void close(Status status, Metadata trailers) {
this.status = status;
try {
delegate().close(status, trailers);
} catch (Throwable e) {
instrumenter.end(context, request, status, e);
throw e;
}
instrumenter.end(context, request, status, status.getCause());
}

final class TracingServerCallListener
Expand Down Expand Up @@ -165,6 +166,10 @@ public void onComplete() {
instrumenter.end(context, request, Status.UNKNOWN, e);
throw e;
}
if (status == null) {
status = Status.UNKNOWN;
}
instrumenter.end(context, request, status, status.getCause());
}

@Override
Expand Down

0 comments on commit 0b9ca3d

Please sign in to comment.