Package brave.http
Class HttpAdapter<Req,Resp>
- java.lang.Object
-
- brave.http.HttpAdapter<Req,Resp>
-
- Direct Known Subclasses:
HttpClientAdapter,HttpServerAdapter
public abstract class HttpAdapter<Req,Resp> extends Object
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract Stringmethod(Req request)The HTTP method, or verb, such as "GET" or "POST" or null if unreadable.StringmethodFromResponse(Resp resp)Likemethod(Object)except used in response parsing.Stringpath(Req request)The absolute http path, without any query parameters or null if unreadable.abstract StringrequestHeader(Req request, String name)Returns one value corresponding to the specified header, or null.Stringroute(Resp response)Returns an expression such as "/items/:itemId" representing an application endpoint, conventionally associated with the tag key "http.route".abstract IntegerstatusCode(Resp response)The HTTP status code or null if unreadable.intstatusCodeAsInt(Resp response)LikestatusCode(Object)except returns a primitive where zero implies absent.abstract Stringurl(Req request)The entire URL, including the scheme, host and query parameters if available or null if unreadable.
-
-
-
Method Detail
-
method
@Nullable public abstract String method(Req request)
The HTTP method, or verb, such as "GET" or "POST" or null if unreadable.Conventionally associated with the key "http.method"
-
path
@Nullable public String path(Req request)
The absolute http path, without any query parameters or null if unreadable. Ex. "/objects/abcd-ff"Conventionally associated with the key "http.path"
- See Also:
route(Object)
-
url
@Nullable public abstract String url(Req request)
The entire URL, including the scheme, host and query parameters if available or null if unreadable.Conventionally associated with the key "http.url"
-
requestHeader
@Nullable public abstract String requestHeader(Req request, String name)
Returns one value corresponding to the specified header, or null.
-
methodFromResponse
@Nullable public String methodFromResponse(Resp resp)
Likemethod(Object)except used in response parsing.Notably, this is used to create a route-based span name.
-
route
@Nullable public String route(Resp response)
Returns an expression such as "/items/:itemId" representing an application endpoint, conventionally associated with the tag key "http.route". If no route matched, "" (empty string) is returned. Null indicates this instrumentation doesn't understand http routes.Eventhough the route is associated with the request, not the response, this is present on the response object. The reasons is that many server implementations process the request before they can identify the route route.
-
statusCode
@Nullable public abstract Integer statusCode(Resp response)
The HTTP status code or null if unreadable.Conventionally associated with the key "http.status_code"
- See Also:
statusCodeAsInt(Object)
-
statusCodeAsInt
public int statusCodeAsInt(Resp response)
LikestatusCode(Object)except returns a primitive where zero implies absent.Using this method usually avoids allocation, so is encouraged when parsing data.
-
-