raskasa / metrics-okhttp

An OkHttp HTTP client wrapper providing Metrics instrumentation of connection pools, request durations and rates, and other useful information.
Apache License 2.0
23 stars 9 forks source link

Empty report #43

Closed loicsf closed 7 years ago

loicsf commented 7 years ago

Hi,

Maybe I am missing something, but using the master (0.3.0-SNAPSHOT) I keep getting empty reports.

I tried this simple test:

@Test
public void instrumentAndNameDefaultClient2() {
        final MetricRegistry registry2 = new MetricRegistry();
        final OkHttpClient client = InstrumentedOkHttpClients.create(registry2, "custom");

        // The connection, read, and write timeouts are the only configurations applied by default.
        assertThat(client.connectTimeoutMillis()).isEqualTo(10_000);
        assertThat(client.readTimeoutMillis()).isEqualTo(10_000);
        assertThat(client.writeTimeoutMillis()).isEqualTo(10_000);

        // Test with echo Postman
        final HttpUrl url = new HttpUrl.Builder().scheme("https").host("echo.getpostman.com")
                .addPathSegment("get").addQueryParameter("test", "123").build();
        final Request request =
                new Request.Builder().url(url).get().addHeader("cache-control", "no-cache").build();

        Response response = null;
        try {
            response = client.newCall(request).execute();
            assertThat(response.code()).isEqualTo(200);
            System.out.println(response.body().string());
        } catch (IOException | NullPointerException ex) {
            System.out.println("Exception: " + ex);
        } finally {
            if (response != null) {
                response.close();
            }
        }

        final ConsoleReporter reporter =
                ConsoleReporter.forRegistry(registry2).convertRatesTo(TimeUnit.SECONDS)
                        .convertDurationsTo(TimeUnit.MILLISECONDS).build();
        reporter.report();
    }

And it returns the following. Note, none of the counters are incremented, even though a successful call has been made using the client:

{"args":{"test":"123"},"headers":{"host":"postman-echo.com","accept-encoding":"gzip","cache-control":"no-cache","user-agent":"okhttp/3.6.0","x-forwarded-port":"443","x-forwarded-proto":"https"},"url":"https://postman-echo.com/get?test=123"}
5/3/17 1:08:44 PM ==============================================================

-- Gauges ----------------------------------------------------------------------
okhttp3.OkHttpClient.custom.connection-pool-idle-count
             value = 2
okhttp3.OkHttpClient.custom.connection-pool-total-count
             value = 2

-- Counters --------------------------------------------------------------------
okhttp3.OkHttpClient.custom.network-requests-running
             count = 0

-- Meters ----------------------------------------------------------------------
okhttp3.OkHttpClient.custom.network-requests-completed
             count = 0
         mean rate = 0.00 events/second
     1-minute rate = 0.00 events/second
     5-minute rate = 0.00 events/second
    15-minute rate = 0.00 events/second
okhttp3.OkHttpClient.custom.network-requests-submitted
             count = 0
         mean rate = 0.00 events/second
     1-minute rate = 0.00 events/second
     5-minute rate = 0.00 events/second
    15-minute rate = 0.00 events/second

-- Timers ----------------------------------------------------------------------
okhttp3.OkHttpClient.custom.network-requests-duration
             count = 0
         mean rate = 0.00 calls/second
     1-minute rate = 0.00 calls/second
     5-minute rate = 0.00 calls/second
    15-minute rate = 0.00 calls/second
               min = 0.00 milliseconds
               max = 0.00 milliseconds
              mean = 0.00 milliseconds
            stddev = 0.00 milliseconds
            median = 0.00 milliseconds
              75% <= 0.00 milliseconds
              95% <= 0.00 milliseconds
              98% <= 0.00 milliseconds
              99% <= 0.00 milliseconds
            99.9% <= 0.00 milliseconds

Process finished with exit code 0

I tried to debug it, but for some reasons it does not seem to reach the InstrumentedExecutorService. Any idea why it is not reported ?

raskasa commented 7 years ago

@loicsf Apologies for the extreme delay.

I'm not surprised that you had some issues. I was in the middle of upgrading everything when I took a break. I haven't been active with this project for some time. I'm getting back into web development and plan to get back active once again over the long weekend.

Hopefully I'll be able to help resolve your issue soon (even if you have moved on already).

raskasa commented 7 years ago

@loicsf should be resolved now

loicsf commented 7 years ago

No worries. I was busy on my side too. I will try to retest it next week and let you know how it goes.
Thanks a lot for looking into it.

On Jun 29, 2017, at 13:23, Ras Kasa Williams notifications@github.com wrote:

Apologies for the extreme delay.

I'm not surprised that you had some issues. I was in the middle of upgrading everything when I took a break. I haven't been active with this project for some time. I'm getting back into web development and plan to get back active once again over the long weekend.

Hopefully I'll be able to help resolve your issue soon (even if you have moved on already).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

loicsf commented 7 years ago

Actually just did a unit-test, and it works just fine now. Thanks a lot!

On Sat, Jul 1, 2017 at 2:15 PM, Loic SF loic.sf@gmail.com wrote:

No worries. I was busy on my side too. I will try to retest it next week and let you know how it goes. Thanks a lot for looking into it.

On Jun 29, 2017, at 13:23, Ras Kasa Williams notifications@github.com wrote:

Apologies for the extreme delay.

I'm not surprised that you had some issues. I was in the middle of upgrading everything when I took a break. I haven't been active with this project for some time. I'm getting back into web development and plan to get back active once again over the long weekend.

Hopefully I'll be able to help resolve your issue soon (even if you have moved on already).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/raskasa/metrics-okhttp/issues/43#issuecomment-312093434, or mute the thread https://github.com/notifications/unsubscribe-auth/AB4o27FoGT0h6Q2RT13oJ3_wUVoLCyjFks5sJAfegaJpZM4NP52k .