-
Notifications
You must be signed in to change notification settings - Fork 76
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
Changes from 4 commits
a3586aa
90ff951
0007f5c
c0c835f
24a8423
f8123cf
f7a5cb8
10d23ff
8710478
e1bf9b2
f044373
8e0b5ac
3b01e1c
aad62c4
b89702d
c53c138
2779987
a62d641
f2607cd
6288cc1
d331b94
fa1c284
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
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() -> | ||
|
@@ -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}]}) -> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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}) -> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
{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(_) -> []. | ||
|
There was a problem hiding this comment.
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.