Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump webmachine dep. Properly detect histogram type on readpath. #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion rebar.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{deps, [
{folsom, ".*", {git, "git://github.com/boundary/folsom", master}},
{webmachine, ".*", {git, "git://github.com/basho/webmachine", {tag, "1.9.2"}}},
{webmachine, ".*", {git, "git://github.com/basho/webmachine", {tag, "1.10.8"}}},
{ibrowse, ".*", {git, "git://github.com/cmullaparthi/ibrowse.git", {tag, "v4.0.1"}}}
]}.
{erl_opts, [debug_info]}.
Expand Down
13 changes: 10 additions & 3 deletions src/folsom_webmachine_metrics_resource.erl
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,11 @@ resource_exists(Id, ReqData, Context) ->
get_request(undefined, undefined, undefined) ->
folsom_metrics:get_metrics();
get_request(Id, undefined, undefined) ->
case folsom_metrics:get_metric_info(Id) of
[{_, [{type, histogram}]}] ->
MetricInfo = folsom_metrics:get_metric_info(Id),
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MetricInfo can look something like this (this is what triggered the issue for me):

[{connect_latency,[{type,histogram},
                   {tags,{set,0,16,16,8,80,48,
                              {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],
                               []},
                              {{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],
                                []}}}}]}]

case is_histogram(MetricInfo) of
true ->
[{value, folsom_metrics:get_histogram_statistics(Id)}];
_ ->
false ->
[{value, folsom_metrics:get_metric_value(Id)}]
end;
get_request(Id, undefined, CoId) ->
Expand Down Expand Up @@ -161,3 +162,9 @@ metric_exists(Id) when is_binary(Id) ->
end;
metric_exists(Id) when is_atom(Id) ->
{folsom_metrics:metric_exists(Id), Id}.

% @doc Return true if this metric info is for a histogram.
is_histogram([{_, MetricProps}]) ->
proplists:get_value(type, MetricProps) =:= histogram;
is_histogram(_) ->
false.