Package brave.http
Class HttpResponseParser.Default
java.lang.Object
brave.http.HttpResponseParser.Default
- All Implemented Interfaces:
HttpResponseParser
- Enclosing interface:
- HttpResponseParser
public static class HttpResponseParser.Default extends Object implements HttpResponseParser
The default data policy sets the span name to the HTTP route when available, along with the
"http.status_code" and "error" tags.
Route-based span name
If routing is supported, and a GET didn't match due to 404, the span name will be "get not_found". If it didn't match due to redirect, the span name will be "get redirected". If routing is not supported, the span name is left alone.-
Nested Class Summary
Nested classes/interfaces inherited from interface brave.http.HttpResponseParser
HttpResponseParser.Default
-
Field Summary
-
Constructor Summary
Constructors Constructor Description Default()
-
Method Summary
Modifier and Type Method Description protected void
error(int httpStatus, Throwable error, SpanCustomizer span)
Override to change what data from the HTTP error are parsed into the span modeling it.void
parse(HttpResponse response, TraceContext context, SpanCustomizer span)
This tags "http.status_code" when it is not 2xx.
-
Constructor Details
-
Default
public Default()
-
-
Method Details
-
parse
This tags "http.status_code" when it is not 2xx. If the there is no exception and the status code is neither 2xx nor 3xx, it tags "error". This also overrides the span name based on theHttpResponse.method()
andHttpResponse.route()
where possible (ex "get /users/:userId").If you only want to change how exceptions are parsed, override
error(int, Throwable, SpanCustomizer)
instead.- Specified by:
parse
in interfaceHttpResponseParser
- See Also:
HttpResponseParser.Default
-
error
Override to change what data from the HTTP error are parsed into the span modeling it. By default, this tags "error" as the the status code, if the error parameter was null and the HTTP status is below 1xx or above 3xx.Note: Either the httpStatus can be zero or the error parameter null, but not both. This does not parse the error, as it is assumed that the
has done so prior
.Conventionally associated with the tag key "error"
-