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

Add stats formatting for riak-admin and http stats output #304

Closed
wants to merge 22 commits into from
Closed
Changes from 4 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
a3586aa
added formatting to stats for the legacy stats blob produced for riak…
bowrocker Feb 13, 2014
90ff951
added check for YZ enabled; return no stats if not
bowrocker Feb 13, 2014
0007f5c
renamed yz stats to search/[index|query] instead of yokozuna/[search|…
bowrocker Feb 13, 2014
c0c835f
removed variance
bowrocker Feb 13, 2014
24a8423
remove stats formatting by pattern matching and replace with a mappin…
bowrocker Feb 19, 2014
f8123cf
added type spec to stats_map/1
bowrocker Feb 19, 2014
f7a5cb8
fixed stats_map spec
bowrocker Feb 20, 2014
10d23ff
Merge pull request #315 from basho/refactor/rz/yz-jar
rzezeski Feb 20, 2014
8710478
refactored stats for wm and riak-admin
bowrocker Feb 21, 2014
e1bf9b2
removed empty comment lines
bowrocker Feb 21, 2014
f044373
fixed spec formatting
bowrocker Feb 21, 2014
8e0b5ac
added formatting to stats for the legacy stats blob produced for riak…
bowrocker Feb 13, 2014
3b01e1c
added check for YZ enabled; return no stats if not
bowrocker Feb 13, 2014
aad62c4
renamed yz stats to search/[index|query] instead of yokozuna/[search|…
bowrocker Feb 13, 2014
b89702d
removed variance
bowrocker Feb 13, 2014
c53c138
remove stats formatting by pattern matching and replace with a mappin…
bowrocker Feb 19, 2014
2779987
added type spec to stats_map/1
bowrocker Feb 19, 2014
a62d641
fixed stats_map spec
bowrocker Feb 20, 2014
f2607cd
refactored stats for wm and riak-admin
bowrocker Feb 21, 2014
6288cc1
removed empty comment lines
bowrocker Feb 21, 2014
d331b94
fixed spec formatting
bowrocker Feb 21, 2014
fa1c284
Merge branch 'bugfix/jra/yz_stats' of https://github.com/basho/yokozu…
bowrocker Feb 21, 2014
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
73 changes: 73 additions & 0 deletions src/yz_stat.erl
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ get_stats() ->
Error -> Error
end.

%% @doc Return formatted stats
-spec get_formatted_stats() -> [term()].
get_formatted_stats() ->
case yokozuna:is_enabled(index) andalso ?YZ_ENABLED of
Copy link
Contributor

Choose a reason for hiding this comment

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

No need for the yokozuna:is_enabled(index) check. That check is to allow users to just disabled indexing or querying without disabling all of Yokozuna. We will want to be able to retrieve stats even if index is disabled.

false ->
[];
true ->
Stats = ?MODULE:get_stats(),
format_stats(Stats)
end.

%% TODO: export stats() type from riak_core_stat_q.
-spec produce_stats() -> {atom(), list()}.
produce_stats() ->
Expand Down Expand Up @@ -175,3 +186,65 @@ update(StatUpdate) ->
false -> notify(StatUpdate)
end,
ok.

%% @private
%%
%% @doc Format stats for legacy stats blob
-spec format_stats([term()]) -> [term()].
format_stats(Stats) ->
lists:flatten([format(Stat) || Stat <- Stats]).

format({{_, search, fail},[{count, Count}, {one, One}]}) ->
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a type spec for this function and mark as private.

[{search_query_fail_count, Count},
{search_query_fail_one, One}];
format({{_, search, throughput},[{count, Count}, {one, One}]}) ->
[{search_query_throughput_count, Count},
{search_query_throughput_one, One}];
format({{_, index, fail},[{count, Count}, {one, One}]}) ->
[{search_index_fail_count, Count},
{search_index_fail_one, One}];
format({{_, index, throughput},[{count, Count}, {one, One}]}) ->
[{search_index_throughput_count, Count},
{search_index_throughput_one, One}];
format({{_, search, latency}, ValueList}) ->
[format_query_latency(V) || V <- ValueList];
format({{_, index, latency}, ValueList}) ->
[format_index_latency(V) || V <- ValueList];
format({yokozuna_stat_ts, TS}) ->
[{search_stat_ts, TS}];
format(T) -> T.

format_query_latency({min, Value}) ->
Copy link
Contributor

Choose a reason for hiding this comment

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

Add type specs for all these functions and mark as private. You don't have to spec them to death. E.g. {atom, term()} is probably okay for format_query_latency.

{search_query_latency_min, Value};
format_query_latency({max, Value}) ->
{search_query_latency_max, Value};
format_query_latency({median, Value}) ->
{search_query_latency_median, Value};
format_query_latency({percentile, PList}) ->
[ format_query_latency_percentile(P) || P <- PList];
format_query_latency({_, _}) ->
[].

format_query_latency_percentile({95, Value}) ->
{search_query_latency_percentile_95, Value};
format_query_latency_percentile({99, Value}) ->
{search_query_latency_percentile_99, Value};
format_query_latency_percentile(_) -> [].

format_index_latency({min, Value}) ->
{search_index_latency_min, Value};
format_index_latency({max, Value}) ->
{search_index_latency_max, Value};
format_index_latency({median, Value}) ->
{search_index_latency_median, Value};
format_index_latency({percentile, PList}) ->
[ format_index_latency_percentile(P) || P <- PList];
format_index_latency({_, _}) ->
[].

format_index_latency_percentile({95, Value}) ->
{search_index_latency_percentile_95, Value};
format_index_latency_percentile({99, Value}) ->
{search_index_latency_percentile_99, Value};
format_index_latency_percentile(_) -> [].