@Test public void testResponseFamilyMetrics() throws IOException { successfulRequest(REQUEST_A); interceptor.intercept(chain); HostMetrics hostA = hostMetrics("hosta", PORT); assertThat(hostA.get2xx().getCount()).isEqualTo(1); successfulRequest(REQUEST_B); interceptor.intercept(chain); HostMetrics hostB = hostMetrics("hostb", PORT); assertThat(hostB.get2xx().getCount()).isEqualTo(1); }
@Override public Response intercept(Chain chain) throws IOException { HttpUrl url = chain.request().url(); String hostname = url.host(); int port = url.port(); Stopwatch stopwatch = Stopwatch.createStarted(); Response response; try { response = chain.proceed(chain.request()); } catch (IOException e) { if (!chain.call().isCanceled()) { hostEventsSink.recordIoException(serviceName, hostname, port); ioExceptionMeter.mark(); } throw e; } long micros = stopwatch.elapsed(TimeUnit.MICROSECONDS); hostEventsSink.record(serviceName, hostname, port, response.code(), micros); responseTimer.update(micros, TimeUnit.MICROSECONDS); return response; }
InstrumentedInterceptor implements Interceptor { @Override public Response intercept(Chain chain) throws IOException { HttpUrl url = chain.request().url(); String hostname = url.host(); int port = url.port(); Stopwatch stopwatch = Stopwatch.createStarted(); Response response; try { response = chain.proceed(chain.request()); } catch (IOException e) { if (!chain.call().isCanceled()) { hostEventsSink.recordIoException(serviceName, hostname, port); ioExceptionMeter.mark(); } throw e; } long micros = stopwatch.elapsed(TimeUnit.MICROSECONDS); hostEventsSink.record(serviceName, hostname, port, response.code(), micros); responseTimer.update(micros, TimeUnit.MICROSECONDS); return response; } }
InstrumentedInterceptor implements Interceptor { @Override public Response intercept(Chain chain) throws IOException { HttpUrl url = chain.request().url(); String hostname = url.host(); int port = url.port(); Stopwatch stopwatch = Stopwatch.createStarted(); Response response; try { response = chain.proceed(chain.request()); } catch (IOException e) { if (!chain.call().isCanceled()) { hostEventsSink.recordIoException(serviceName, hostname, port); ioExceptionMeter.mark(); } throw e; } long micros = stopwatch.elapsed(TimeUnit.MICROSECONDS); hostEventsSink.record(serviceName, hostname, port, response.code(), micros); responseTimer.update(micros, TimeUnit.MICROSECONDS); return response; } InstrumentedInterceptor(ClientMetrics clientMetrics, HostEventsSink hostEventsSink, String serviceName); }
InstrumentedInterceptor implements Interceptor { @Override public Response intercept(Chain chain) throws IOException { HttpUrl url = chain.request().url(); String hostname = url.host(); int port = url.port(); Stopwatch stopwatch = Stopwatch.createStarted(); Response response; try { response = chain.proceed(chain.request()); } catch (IOException e) { if (!chain.call().isCanceled()) { hostEventsSink.recordIoException(serviceName, hostname, port); ioExceptionMeter.mark(); } throw e; } long micros = stopwatch.elapsed(TimeUnit.MICROSECONDS); hostEventsSink.record(serviceName, hostname, port, response.code(), micros); responseTimer.update(micros, TimeUnit.MICROSECONDS); return response; } InstrumentedInterceptor(ClientMetrics clientMetrics, HostEventsSink hostEventsSink, String serviceName); @Override Response intercept(Chain chain); }
InstrumentedInterceptor implements Interceptor { @Override public Response intercept(Chain chain) throws IOException { HttpUrl url = chain.request().url(); String hostname = url.host(); int port = url.port(); Stopwatch stopwatch = Stopwatch.createStarted(); Response response; try { response = chain.proceed(chain.request()); } catch (IOException e) { if (!chain.call().isCanceled()) { hostEventsSink.recordIoException(serviceName, hostname, port); ioExceptionMeter.mark(); } throw e; } long micros = stopwatch.elapsed(TimeUnit.MICROSECONDS); hostEventsSink.record(serviceName, hostname, port, response.code(), micros); responseTimer.update(micros, TimeUnit.MICROSECONDS); return response; } InstrumentedInterceptor(ClientMetrics clientMetrics, HostEventsSink hostEventsSink, String serviceName); @Override Response intercept(Chain chain);  }