Search in sources :

Example 6 with HttpRequestContext

use of io.opencensus.contrib.http.HttpRequestContext in project instrumentation-java by census-instrumentation.

the class JaxrsContainerFilterTest method testResponseFilter.

@Test
public void testResponseFilter() throws Exception {
    Span span = new FakeSpan(SpanContext.INVALID, null);
    TagContext tagContext = mock(TagContext.class);
    HttpRequestContext context = JaxrsClientFilterTest.createHttpRequestContext(span, tagContext);
    UriInfo uriInfo = mock(UriInfo.class);
    when(uriInfo.getMatchedURIs()).thenReturn(Collections.singletonList("/resource/{route}"));
    ContainerRequestContext requestContext = mock(ContainerRequestContext.class);
    when(requestContext.getProperty("opencensus.context")).thenReturn(context);
    when(requestContext.getUriInfo()).thenReturn(uriInfo);
    ContainerResponseContext responseContext = mock(ContainerResponseContext.class);
    filter.filter(requestContext, responseContext);
    verify(requestContext).getProperty("opencensus.context");
    verify(responseContext, times(1)).getStatus();
}
Also used : FakeSpan(io.opencensus.contrib.http.jaxrs.JaxrsClientFilterTest.FakeSpan) ContainerRequestContext(javax.ws.rs.container.ContainerRequestContext) TagContext(io.opencensus.tags.TagContext) ContainerResponseContext(javax.ws.rs.container.ContainerResponseContext) HttpRequestContext(io.opencensus.contrib.http.HttpRequestContext) FakeSpan(io.opencensus.contrib.http.jaxrs.JaxrsClientFilterTest.FakeSpan) Span(io.opencensus.trace.Span) UriInfo(javax.ws.rs.core.UriInfo) Test(org.junit.Test)

Example 7 with HttpRequestContext

use of io.opencensus.contrib.http.HttpRequestContext in project instrumentation-java by census-instrumentation.

the class JaxrsClientFilter method filter.

@Override
public void filter(ClientRequestContext requestContext) {
    HttpRequestContext context = handler.handleStart(null, requestContext, requestContext);
    requestContext.setProperty(OPENCENSUS_CONTEXT, context);
}
Also used : HttpRequestContext(io.opencensus.contrib.http.HttpRequestContext)

Example 8 with HttpRequestContext

use of io.opencensus.contrib.http.HttpRequestContext in project instrumentation-java by census-instrumentation.

the class JaxrsClientFilter method filter.

@Override
public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) {
    HttpRequestContext context = (HttpRequestContext) requestContext.getProperty(OPENCENSUS_CONTEXT);
    handler.handleEnd(context, requestContext, responseContext, null);
}
Also used : HttpRequestContext(io.opencensus.contrib.http.HttpRequestContext)

Aggregations

HttpRequestContext (io.opencensus.contrib.http.HttpRequestContext)8 Scope (io.opencensus.common.Scope)3 TagContext (io.opencensus.tags.TagContext)2 Span (io.opencensus.trace.Span)2 Test (org.junit.Test)2 FakeSpan (io.opencensus.contrib.http.jaxrs.JaxrsClientFilterTest.FakeSpan)1 IOException (java.io.IOException)1 AsyncContext (javax.servlet.AsyncContext)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 ClientRequestContext (javax.ws.rs.client.ClientRequestContext)1 ClientResponseContext (javax.ws.rs.client.ClientResponseContext)1 ContainerRequestContext (javax.ws.rs.container.ContainerRequestContext)1 ContainerResponseContext (javax.ws.rs.container.ContainerResponseContext)1 UriInfo (javax.ws.rs.core.UriInfo)1 ClientHttpResponse (org.springframework.http.client.ClientHttpResponse)1