OpenTracingFilter implements Filter { @Override public Response filter(Caller<?> caller, Request request) { Tracer tracer = getTracer(); if (tracer == null || tracer instanceof NoopTracer) { return caller.call(request); } if (caller instanceof Provider) { return processProviderTrace(tracer, caller, request); } else { return processRefererTrace(tracer, caller, request); } }  @Override Response filter(Caller<?> caller, Request request);  }
@Test public void testRefererFilter() { Response res = OTFilter.filter(refer, request); assertEquals(response, res); checkMockTracer(); }
@Test public void testProviderFilter() { Response res = OTFilter.filter(provider, request); assertEquals(response, res); checkMockTracer(); }
@Test public void testException() { response.setException(new RuntimeException("in test")); Response res = OTFilter.filter(refer, request); assertEquals(response, res); if (tracer instanceof MockTracer) { MockSpan span = ((MockTracer) tracer).finishedSpans().get(0); assertEquals(span.logEntries().size(), 1); assertTrue("request fail.in test".equals(span.logEntries().get(0).fields().get("event"))); } }