Class RpcResponse
- java.lang.Object
-
- brave.Response
-
- brave.rpc.RpcResponse
-
- Direct Known Subclasses:
RpcClientResponse
,RpcServerResponse
public abstract class RpcResponse extends brave.Response
Abstract response type used for parsing and sampling of RPC clients and servers.- Since:
- 5.12
- See Also:
RpcClientResponse
,RpcServerResponse
-
-
Constructor Summary
Constructors Constructor Description RpcResponse()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract String
errorCode()
Returns the shortest human readable error code name.long
finishTimestamp()
The timestamp in epoch microseconds of the end of this request or zero to take this implicitly from the current clock.RpcRequest
request()
The request that initiated this RPC response ornull
if unknown.
-
-
-
Method Detail
-
request
@Nullable public RpcRequest request()
The request that initiated this RPC response ornull
if unknown.- Overrides:
request
in classbrave.Response
- Since:
- 5.12
-
errorCode
@Nullable public abstract String errorCode()
Returns the shortest human readable error code name. Ex. {code io.grpc.Status.Code.name()} may return "CANCELLED".Conventionally, this is used as the
"error" tag
and optionally tagged separately as "rpc.error_code".Notes
This is not a success code. On success, returnnull
. Do not return "OK" or similar as it will interfere with error interpretation.When only a boolean value is available, this should return empty string ("") on
true
andnull
on false.When an error code has both a numeric and text label, return the text.
- Since:
- 5.12
-
finishTimestamp
public long finishTimestamp()
The timestamp in epoch microseconds of the end of this request or zero to take this implicitly from the current clock. Defaults to zero.This is helpful in two scenarios: late parsing and avoiding redundant timestamp overhead. For example, you can asynchronously handle span completion without losing precision of the actual end.
Note: Overriding has the same problems as using
Span.finish(long)
. For example, it can result in negative duration if the clock used is allowed to correct backwards. It can also result in misalignments in the trace, unlessTracing.Builder.clock(Clock)
uses the same implementation.- Since:
- 5.12
- See Also:
RpcRequest.startTimestamp()
,Span.finish(long)
,Tracing.clock(TraceContext)
-
-