From 8d22982ccd851b2c795dac640d8d32c15f3f1bce Mon Sep 17 00:00:00 2001 From: Tyler Neely Date: Mon, 4 Jan 2016 05:18:43 -0800 Subject: [PATCH] Bump webmachine dep. Properly detect histogram type on readpath. --- rebar.config | 2 +- src/folsom_webmachine_metrics_resource.erl | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/rebar.config b/rebar.config index b8eb349..c46b908 100644 --- a/rebar.config +++ b/rebar.config @@ -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]}. diff --git a/src/folsom_webmachine_metrics_resource.erl b/src/folsom_webmachine_metrics_resource.erl index 7f21352..cebb6f9 100644 --- a/src/folsom_webmachine_metrics_resource.erl +++ b/src/folsom_webmachine_metrics_resource.erl @@ -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), + 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) -> @@ -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.