@PreMatching @Singleton @Priority(value=1) public class BardLoggingFilter extends Object implements javax.ws.rs.container.ContainerRequestFilter, javax.ws.rs.container.ContainerResponseFilter, javax.ws.rs.client.ClientRequestFilter, javax.ws.rs.client.ClientResponseFilter, javax.ws.rs.ext.WriterInterceptor
Request: GET, length=-1
http://localhost:9998/test/data?metrics=pageViews&dateTime=2014-06-11%2F2014-06-12
> user-agent=Jersey/2.9 (HttpUrlConnection 1.7.0_55)
> host=localhost:9998
> accept=text/html, image/gif, image/jpeg, *; q=.2,
> connection=keep-alive
< Content-Type=application/json
Response: 200, OK, 1020.253 ms
length=2
Modifier and Type | Field and Description |
---|---|
static String |
CLIENT_TOTAL_TIMER |
static double |
MILLISECONDS_PER_NANOSECOND |
static String |
TOTAL_TIMER |
static String |
X_REQUEST_ID_HEADER |
Constructor and Description |
---|
BardLoggingFilter() |
Modifier and Type | Method and Description |
---|---|
void |
aroundWriteTo(javax.ws.rs.ext.WriterInterceptorContext writerInterceptorContext)
This allows us to compute the length of the output stream when stream is closed.
|
void |
filter(javax.ws.rs.client.ClientRequestContext request)
Intercept Client request and add start timestamp.
|
void |
filter(javax.ws.rs.client.ClientRequestContext request,
javax.ws.rs.client.ClientResponseContext response) |
void |
filter(javax.ws.rs.container.ContainerRequestContext request)
Intercept the Container request to add length of request and a start timestamp.
|
void |
filter(javax.ws.rs.container.ContainerRequestContext request,
javax.ws.rs.container.ContainerResponseContext response)
Intercept the Container request/response and log.
|
protected String |
renderUri(URI uri)
Render the URI as a string.
|
public static final double MILLISECONDS_PER_NANOSECOND
public static final String TOTAL_TIMER
public static final String CLIENT_TOTAL_TIMER
public static final String X_REQUEST_ID_HEADER
public void filter(javax.ws.rs.container.ContainerRequestContext request) throws IOException
filter
in interface javax.ws.rs.container.ContainerRequestFilter
request
- Request to interceptIOException
- if there's a problem processing the requestpublic void filter(javax.ws.rs.container.ContainerRequestContext request, javax.ws.rs.container.ContainerResponseContext response) throws IOException
If output is streamed, also hook the output stream.
filter
in interface javax.ws.rs.container.ContainerResponseFilter
request
- Request to interceptresponse
- Response to interceptIOException
- if there's a problem processing the request or responsepublic void filter(javax.ws.rs.client.ClientRequestContext request) throws IOException
filter
in interface javax.ws.rs.client.ClientRequestFilter
request
- Request to interceptIOException
- if there's a problem processing the requestpublic void filter(javax.ws.rs.client.ClientRequestContext request, javax.ws.rs.client.ClientResponseContext response) throws IOException
filter
in interface javax.ws.rs.client.ClientResponseFilter
IOException
protected String renderUri(URI uri)
uri
- The URI to renderpublic void aroundWriteTo(javax.ws.rs.ext.WriterInterceptorContext writerInterceptorContext) throws IOException
aroundWriteTo
in interface javax.ws.rs.ext.WriterInterceptor
writerInterceptorContext
- Interceptor to use for intercepting the entity being writtenIOException
- if there's a problem processing the requestCopyright © 2016–2018 Yahoo! Inc.. All rights reserved.