[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:
https://github.com/boundary/folsom/blob/master/src/folsom_metrics.erl#L210
You'll still have to wrap those calls with instrumentation. However, you
could also write your own wrapper function just once, maybe something like
this:
pool_instrument(Pool, Fun, TotalMetric, CheckoutMetric, InternalMetric) ->
folsom:histogram_timed_update(TotalMetric, fun pool_instrument/4,
[Pool, Fun, CheckoutMetric,
InternalMetric]).
pool_instrument(Pool, Fun, CheckoutMetric, InternalMetric) ->
Worker = folsom:histogram_timed_update(CheckoutMetric,
poolboy, checkout, [Pool, true,
Timeout]),
try
folsom:histogram_timed_update(InternalMetric, Fun, [Worker])
after
ok = poolboy:checkin(Pool, Worker)
end.
On Fri, May 30, 2014 at 10:02 AM, Roger Lipscombe <roger@REDACTED>
wrote:
> 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.
http://basho.com/
-------------- 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