Package brave.http

Class HttpResponse

java.lang.Object
brave.Response
brave.http.HttpResponse
Direct Known Subclasses:
HttpClientResponse, HttpServerResponse

public abstract class HttpResponse
extends Response
Abstract response type used for parsing and sampling of http clients and servers.
Since:
5.10
See Also:
HttpClientResponse, HttpServerResponse
  • Method Details

    • request

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

      Implementations should return the last wire-level request that caused this response or error. HTTP properties like path and headers might be different, due to redirects or authentication. Some properties might not be visible until response processing, notably route().

      Overrides:
      request in class Response
      Since:
      5.10
    • method

      @Nullable public String method()
      Returns the HTTP method of the request that caused this response or null if unreadable.

      Note: This value may be present even when request() is null, but implementations should implement request() when possible.

      Since:
      5.10
      See Also:
      HttpRequest.method()
    • route

      @Nullable public String route()
      Returns the HTTP route of the request that caused this response or null if unreadable.

      Note: This value may be present even when request() is null, but implementations should implement request() when possible.

      Since:
      5.10
      See Also:
      HttpRequest.route()
    • statusCode

      public abstract int statusCode()
      The HTTP status code or zero if unreadable.

      Conventionally associated with the key "http.status_code"

      Since:
      5.10
    • 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, unless Tracing.Builder.clock(Clock) uses the same implementation.

      Since:
      5.10
      See Also:
      HttpRequest.startTimestamp(), Span.finish(long), Tracing.clock(TraceContext)