Package brave

Class Response

java.lang.Object
brave.Response

public abstract class Response
extends Object
Abstract response type used for parsing.

No extensions outside Brave

While this is an abstract type, it should not be subclassed outside the Brave repository. In other words, subtypes are sealed within this source tree.
Since:
5.10
See Also:
Request
  • Constructor Details

  • Method Details

    • spanKind

      public abstract Span.Kind spanKind()
      The remote Span.Kind describing the direction and type of the response.
    • request

      @Nullable public Request request()
      The request that initiated this response or null if unknown.

      Implementations should return the last wire-level request that caused this response or error.

    • error

      @Nullable public abstract Throwable error()
      The error raised during response processing or null if there was none.

      Lack of throwable, null, does not mean success. For example, in HTTP, there could be a 409 status code with no corresponding Java exception.

      Handling errors

      Handlers invoke Span.error(Throwable) prior to passing control to user-defined response parsers. This allows any SpanHandler to see the raw error via MutableSpan.error(), in case of export to a non-Zipkin backend such as metrics.

      User-defined parsers can take any error here into consideration when deriving a "error" tag. For example, if they prefer defaults, they do nothing. If they have a better error tag value than what would be derived from the Throwable, they can overwrite it.

    • unwrap

      public abstract Object unwrap()
      Returns the underlying response object or null if there is none. Here are some response objects: org.apache.http.HttpResponse, org.apache.dubbo.rpc.Result, org.apache.kafka.clients.producer.RecordMetadata.

      Note: Some implementations are composed of multiple types, such as a response and matched route of the server. Moreover, an implementation may change the type returned due to refactoring. Unless you control the implementation, cast carefully (ex using instanceof) instead of presuming a specific type will always be returned.

      Since:
      5.10
    • toString

      public String toString()
      Overrides:
      toString in class Object