@Test
public void testTracingSyncError() {

  final RequestContext requestContext = mock(RequestContext.class);
  final Request request = Request.forUri("/bar", "GET");
  final MockSpan span = new MockSpan();
  when(requestContext.request()).thenReturn(request);
  when(tracer.spanBuilder("foo-service//bar")).thenReturn(spanBuilder);
  when(spanBuilder.startSpan()).thenReturn(span);
  try {
    awaitResponse(Middlewares.tracer(tracer, "foo-service")
        .apply(rc -> {
          throw new RuntimeException();
        })
        .invoke(requestContext));
    fail();
  } catch (Exception ignore) {
  }
  assertThat(span.ended, is(true));
  assertThat(span.status, is(io.opencensus.trace.Status.UNKNOWN));
}