[erlang-questions] Reporting gen_server timings

Sean Cribbs sean@REDACTED
Fri May 30 18:01:22 CEST 2014

It looks like folsom (which it looks like folsomite wraps, correct me if
I'm wrong), will do this for you already:

You'll still have to wrap those calls with instrumentation. However, you
could also write your own wrapper function just once, maybe something like

pool_instrument(Pool, Fun, TotalMetric, CheckoutMetric, InternalMetric) ->
    folsom:histogram_timed_update(TotalMetric, fun pool_instrument/4,
                                  [Pool, Fun, CheckoutMetric,

pool_instrument(Pool, Fun, CheckoutMetric, InternalMetric) ->
    Worker = folsom:histogram_timed_update(CheckoutMetric,
                                           poolboy, checkout, [Pool, true,
        folsom:histogram_timed_update(InternalMetric, Fun, [Worker])
        ok = poolboy:checkin(Pool, Worker)

On Fri, May 30, 2014 at 10:02 AM, Roger Lipscombe <roger@REDACTED>

> We're using poolboy and pgsql. I'd like to report (to graphite; we're
> using folsomite) the time taken for the gen_server and database calls.
> When you use poolboy, you provide it with a worker (usually a
> gen_server), and call it like this:
>     poolboy:transaction(?POOL, fun(W) -> gen_server:call(W, {equery,
> Stmt}) end).
> I'd like to instrument this -- without having to add too much wrapper
> code -- such that I get measurements of:
> - How long the overall transaction took.
> - How much of that was spent waiting for poolboy to get an available
> worker.
> - How much of that was spent waiting on the database.
> I could decorate the code with timer:tc calls everywhere, but that
> gets ugly really quickly. Is there a better way?
> Thanks,
> Roger.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

Sean Cribbs <sean@REDACTED>
Software Engineer
Basho Technologies, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140530/2bbbcf6a/attachment.htm>

More information about the erlang-questions mailing list