Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion apps/ff_server/src/ff_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,11 @@ wrap_handler(Handler, WrapperOpts) ->

setup_metrics() ->
ok = woody_ranch_prometheus_collector:setup(),
ok = woody_hackney_prometheus_collector:setup().
ok = woody_hackney_prometheus_collector:setup(),
_ = prometheus_histogram:declare([
{name, woody_wrapper_processing_duration_ms},
{help, "Duration of processing handle_function in millisecond"},
{buckets, [50, 150, 300, 500, 750, 1000]},
{labels, [handler, function]}
]),
ok.
19 changes: 13 additions & 6 deletions apps/ff_server/src/ff_woody_wrapper.erl
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,19 @@ handle_function(Func, Args, WoodyContext0, #{handler := Handler} = Opts) ->
WoodyContext = ensure_woody_deadline_set(WoodyContext0, Opts),
{HandlerMod, HandlerOptions} = get_handler_opts(Handler),
ok = op_context:save(op_context:key(fistful), create_context(WoodyContext, Opts)),
try
HandlerMod:handle_function(
Func,
Args,
HandlerOptions
)
F = fun() -> HandlerMod:handle_function(Func, Args, HandlerOptions) end,
try timer:tc(F) of
{DurationMicro, Result} ->
DurationMs = DurationMicro div 1000,
HandlerBin = erlang:atom_to_binary(HandlerMod),
FuncBin = erlang:atom_to_binary(Func),
Labels = [HandlerBin, FuncBin],
ok = prometheus_histogram:observe(
woody_wrapper_processing_duration_ms,
Labels,
DurationMs
),
Result
after
op_context:cleanup(fistful)
end.
Expand Down
9 changes: 8 additions & 1 deletion apps/hellgate/src/hellgate.erl
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,11 @@ stop(_State) ->

setup_metrics() ->
ok = woody_ranch_prometheus_collector:setup(),
ok = woody_hackney_prometheus_collector:setup().
ok = woody_hackney_prometheus_collector:setup(),
_ = prometheus_histogram:declare([
{name, woody_wrapper_processing_duration_ms},
{help, "Duration of processing handle_function in millisecond"},
{buckets, [50, 150, 300, 500, 750, 1000]},
{labels, [handler, function]}
]),
ok.
20 changes: 13 additions & 7 deletions apps/hg_proto/src/hg_woody_service_wrapper.erl
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,19 @@
handle_function(Func, Args, WoodyContext0, #{handler := Handler} = Opts) ->
WoodyContext = ensure_woody_deadline_set(WoodyContext0, Opts),
ok = op_context:save(op_context:key(hellgate), create_context(WoodyContext, Opts)),
try
Result = Handler:handle_function(
Func,
Args,
Opts
),
{ok, Result}
F = fun() -> Handler:handle_function(Func, Args, Opts) end,
try timer:tc(F) of
{DurationMicro, Result} ->
DurationMs = DurationMicro div 1000,
HandlerBin = erlang:atom_to_binary(Handler),
FuncBin = erlang:atom_to_binary(Func),
Labels = [HandlerBin, FuncBin],
ok = prometheus_histogram:observe(
woody_wrapper_processing_duration_ms,
Labels,
DurationMs
),
{ok, Result}
catch
throw:Reason ->
raise(Reason)
Expand Down
Loading