okhttp - Instrumenting OkHttpClient -
i'm writing small wrapper library that'll allow me monitor internals of okhttpclient using dropwizard metrics: https://github.com/raskasa/metrics-okhttp.
i'm having trouble instrumenting connectionpool
- specifically, periodically calling getconnectioncount()
monitor number of open tcp connections.
when instance of okhttpclient
created, getconnectionpool()
null - i'm expecting. also, subsequent attempts access pool still return null during/after executing network requests.
i'm assuming there proper way monitor connectionpool
because part of public api, i'm not seeing @ moment.
so:
- is there way access
connectionpool
@ pointokhttpclient.getconnectionpool()
notnull
? - if isn't best approach, advice going better way?
try this:
okhttpclient client = ... client.setconnectionpool(connectionpool.getdefault());
that'll give same connection pool you'll anyway, it'll give sooner.
Comments
Post a Comment