|
15 | 15 | -module(elysium_buffering_audit). |
16 | 16 | -author('jay@duomark.com'). |
17 | 17 |
|
| 18 | +%% External API for audit reporting. |
| 19 | +-export([get_audit_count/1, |
| 20 | + get_audit_count_reset/1]). |
| 21 | + |
| 22 | +%% Exported functions for audit counting behaviours. |
18 | 23 | -export([ |
19 | 24 | audit_count_init/2, |
20 | 25 | audit_count/3, |
@@ -107,6 +112,37 @@ count(Audit_Name, Audit_Key, Counter_Pos) -> |
107 | 112 | ets:update_counter(Audit_Name, Audit_Key, {Counter_Pos, 1}). |
108 | 113 |
|
109 | 114 |
|
| 115 | +-spec get_audit_count (config_type()) -> proplists:proplist(). |
| 116 | +-spec get_audit_count_reset (config_type()) -> proplists:proplist(). |
| 117 | + |
| 118 | +get_audit_count(Config) -> |
| 119 | + Count_Flds = count_fields(), |
| 120 | + Count_Ops = [{Pos, 0} || {_Label, Pos} <- Count_Flds], |
| 121 | + return_counts_proplist(Config, Count_Flds, Count_Ops). |
| 122 | + |
| 123 | +get_audit_count_reset(Config) -> |
| 124 | + Count_Flds = count_fields(), |
| 125 | + Count_Ops = [{Pos, 0, 0, 0} || {_Label, Pos} <- Count_Flds], |
| 126 | + return_counts_proplist(Config, Count_Flds, Count_Ops). |
| 127 | + |
| 128 | +return_counts_proplist(Config, Count_Flds, Count_Ops) -> |
| 129 | + {_Buffering, BS_Module} = elysium_connection:get_buffer_strategy_module(Config), |
| 130 | + Audit_Key = {BS_Module, counts}, |
| 131 | + Audit_Name = elysium_config:audit_ets_name(Config), |
| 132 | + Raw_Counts = ets:update_counter(Audit_Name, Audit_Key, Count_Ops), |
| 133 | + lists:zipwith(fun({Label, _Pos}, Count) -> {Label, Count} end, Count_Flds, Raw_Counts). |
| 134 | + |
| 135 | +count_fields() -> |
| 136 | + [{pending_dead, #elysium_audit_counts.pending_dead}, |
| 137 | + {pending_timeouts, #elysium_audit_counts.pending_timeouts}, |
| 138 | + {session_dead, #elysium_audit_counts.session_dead}, |
| 139 | + {session_decay, #elysium_audit_counts.session_decay}, |
| 140 | + {session_timeouts, #elysium_audit_counts.session_timeouts}, |
| 141 | + {session_wrong, #elysium_audit_counts.session_wrong}, |
| 142 | + {worker_errors, #elysium_audit_counts.worker_errors}, |
| 143 | + {worker_timeouts, #elysium_audit_counts.worker_timeouts}]. |
| 144 | + |
| 145 | + |
110 | 146 | %%%----------------------------------------------------------------------- |
111 | 147 | %%% Audit counts for each connection |
112 | 148 | %%%----------------------------------------------------------------------- |
|
0 commit comments