InstrumentedOkHttpClient extends OkHttpClient { String metricId(String metric) { return name(OkHttpClient.class, name, metric); } InstrumentedOkHttpClient(MetricRegistry registry, OkHttpClient rawClient, String name); @Override Authenticator authenticator(); @Override Cache cache(); @Override CertificatePinner certificatePinner(); @Override ConnectionPool connectionPool(); @Override List<ConnectionSpec> connectionSpecs(); @Override int connectTimeoutMillis(); @Override CookieJar cookieJar(); @Override Dispatcher dispatcher(); @Override Dns dns(); @Override boolean followRedirects(); @Override boolean followSslRedirects(); @Override HostnameVerifier hostnameVerifier(); @Override List<Interceptor> interceptors(); @Override List<Interceptor> networkInterceptors(); @Override OkHttpClient.Builder newBuilder(); @Override Call newCall(Request request); @Override WebSocket newWebSocket(Request request, WebSocketListener listener); @Override int pingIntervalMillis(); @Override List<Protocol> protocols(); @Override Proxy proxy(); @Override Authenticator proxyAuthenticator(); @Override ProxySelector proxySelector(); @Override int readTimeoutMillis(); @Override boolean retryOnConnectionFailure(); @Override SocketFactory socketFactory(); @Override SSLSocketFactory sslSocketFactory(); @Override int writeTimeoutMillis(); @Override boolean equals(Object obj); @Override String toString();  }
@Test public void providedNameUsedInMetricId() { String prefix = "custom"; String baseId = "network-requests-submitted"; assertThat(registry.getMeters()).isEmpty(); InstrumentedOkHttpClient client = new InstrumentedOkHttpClient(registry, rawClient, prefix); String generatedId = client.metricId(baseId); assertThat(registry.getMeters().get(generatedId)).isNotNull(); }