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 7 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
59 changes: 50 additions & 9 deletions src/yz_stat.erl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
%% -type microseconds() :: integer().
-define(SERVER, ?MODULE).
-define(NOTIFY(A, B, Type, Arg),
folsom_metrics:notify_existing_metric({?YZ_APP_NAME, A, B}, Arg, Type)).
folsom_metrics:notify_existing_metric({search, A, B}, Arg, Type)).
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm pretty sure all other systems using stats use the application name as first part of namespace. Part of me likes having the root of the namespace be search as that's what yokozuna is for but a bigger part of me wants to stay consistent with other areas of Riak which all namespace based on application.

Change it back to ?YZ_APP_NAME. The renaming will happen in the stats_map.


%% -------------------------------------------------------------------
%% API
Expand All @@ -51,8 +51,14 @@ register_stats() ->
ok.

%% @doc Return current aggregation of all stats.
-spec get_stats() -> proplists:proplist() | {error, term()}.
-spec get_stats() -> proplists:proplist() | [].
Copy link
Contributor

Choose a reason for hiding this comment

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

proplists:proplist() should cover the empty list.

get_stats() ->
get_stats(?YZ_ENABLED).

%% @doc Return current aggregation of all stats.
-spec get_stats(false | true) -> proplists:proplist() | [].
get_stats(false) -> [];
get_stats(true) ->
case riak_core_stat_cache:get_stats(?YZ_APP_NAME) of
{ok, Stats, _TS} -> Stats;
Error -> Error
Expand Down Expand Up @@ -85,6 +91,41 @@ search_fail() ->
search_end(ElapsedTime) ->
update({search_end, ElapsedTime}).

%% @doc Optionally produce stats map based on ?YZ_ENABLED
%%
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove empty comment line.

-spec stats_map() -> [] | proplists:proplist().
stats_map() ->
stats_map(?YZ_ENABLED).

%% @doc Map to format stats for legacy "blob" if YZ_ENABLED,
%% else []
%%
Copy link
Contributor

Choose a reason for hiding this comment

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

Empty comment line.

-spec stats_map(true | false) -> [] | proplists:proplist().
stats_map(false) -> [];
stats_map(true) ->
[
%% Query stats
{search_query_throughput_count, {{search, 'query', throughput}, count}, spiral},
{search_query_throughput_one, {{search, 'query', throughput}, one}, spiral},
{search_query_latency_min, {{search, 'query', latency}, min}, histogram},
{search_query_latency_max, {{search, 'query', latency}, max}, histogram},
{search_query_latency_median, {{search, 'query', latency}, median}, histogram},
{search_query_latency_95, {{search, 'query', latency}, 95}, histogram_percentile},
{search_query_latency_99, {{search, 'query', latency}, 99}, histogram_percentile},
{search_query_latency_999, {{search, 'query', latency}, 999}, histogram_percentile},

%% Index stats
{search_index_throughput_count, {{search, index, throughput}, count}, spiral},
{search_index_throughtput_one, {{search, index, throughput}, one}, spiral},
{search_index_fail_count, {{search, index, fail}, count}, spiral},
{search_index_fail_one, {{search, index, fail}, one}, spiral},
{search_index_latency_min, {{search, index, latency}, min}, histogram},
{search_index_latency_max, {{search, index, latency}, max}, histogram},
{search_index_latency_median, {{search, index, latency}, median}, histogram},
{search_index_latency_95, {{search, index, latency}, 95}, histogram_percentile},
{search_index_latency_99, {{search, index, latency}, 99}, histogram_percentile},
{search_index_latency_999, {{search, index, latency}, 999}, histogram_percentile}].

%% -------------------------------------------------------------------
%% Callbacks
%% -------------------------------------------------------------------
Expand Down Expand Up @@ -126,10 +167,10 @@ notify({index_end, Time}) ->
notify(index_fail) ->
?NOTIFY(index, fail, spiral, 1);
notify({search_end, Time}) ->
?NOTIFY(search, latency, histogram, Time),
?NOTIFY(search, throughput, spiral, 1);
?NOTIFY('query', latency, histogram, Time),
?NOTIFY('query', throughput, spiral, 1);
notify(search_fail) ->
?NOTIFY(search, fail, spiral, 1).
?NOTIFY('query', fail, spiral, 1).

%% @private
get_sample_type(Name) ->
Expand All @@ -154,15 +195,15 @@ stats() ->
{[index, fail], spiral},
{[index, latency], histogram},
{[index, throughput], spiral},
{[search, fail], spiral},
{[search, latency], histogram},
{[search, throughput], spiral}
{['query', fail], spiral},
{['query', latency], histogram},
{['query', throughput], spiral}
].

%% @private
-spec stat_name(riak_core_stat_q:path()) -> riak_core_stat_q:stat_name().
stat_name(Name) ->
list_to_tuple([?YZ_APP_NAME|Name]).
list_to_tuple([search|Name]).
Copy link
Contributor

Choose a reason for hiding this comment

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

Revert back to ?YZ_APP_NAME.


%% @private
%%
Expand Down