@@ -72,7 +72,9 @@ op_complete(Op, {ok, Units}, ElapsedUs) ->
7272 folsom_metrics :notify_existing_metric ({latencies , Op }, ElapsedUs , histogram ),
7373 folsom_metrics :notify_existing_metric ({overall_latencies , Op }, ElapsedUs , histogram ),
7474 folsom_metrics :notify_existing_metric ({overall_units , Op }, {inc , Units }, counter ),
75- folsom_metrics :notify_existing_metric ({units , Op }, {inc , Units }, counter )
75+ folsom_metrics :notify_existing_metric ({units , Op }, {inc , Units }, counter ),
76+ folsom_metrics :notify_existing_metric ({overall_ops , Op }, {inc , 1 }, counter ),
77+ folsom_metrics :notify_existing_metric ({ops , Op }, {inc , 1 }, counter )
7678 end ,
7779 ok ;
7880op_complete (Op , Result , ElapsedUs ) ->
@@ -114,7 +116,9 @@ init([]) ->
114116 folsom_metrics :new_histogram ({latencies , Op }, slide , basho_bench_config :get (report_interval )),
115117 folsom_metrics :new_histogram ({overall_latencies , Op }, uniform , 16384 ),
116118 folsom_metrics :new_counter ({overall_units , Op }),
117- folsom_metrics :new_counter ({units , Op })
119+ folsom_metrics :new_counter ({units , Op }),
120+ folsom_metrics :new_counter ({overall_ops , Op }),
121+ folsom_metrics :new_counter ({ops , Op })
118122 end || Op <- Ops ++ Measurements ],
119123
120124 StatsWriter = basho_bench_config :get (stats , csv ),
@@ -162,10 +166,13 @@ handle_cast({Op, {ok, Units}, ElapsedUs}, State = #state{last_write_time = LWT,
162166 folsom_metrics :notify_existing_metric ({overall_latencies , Op }, ElapsedUs , histogram ),
163167 folsom_metrics :notify_existing_metric ({overall_units , Op }, {inc , Units }, counter ),
164168 folsom_metrics :notify_existing_metric ({units , Op }, {inc , Units }, counter ),
169+ folsom_metrics :notify_existing_metric ({overall_ops , Op }, {inc , 1 }, counter ),
170+ folsom_metrics :notify_existing_metric ({ops , Op }, {inc , 1 }, counter ),
165171 {noreply , NewState };
166172handle_cast (_ , State ) ->
167173 {noreply , State }.
168174
175+
169176handle_info (report , State ) ->
170177 consume_report_msgs (),
171178 Now = os :timestamp (),
@@ -251,19 +258,21 @@ process_stats(Now, #state{stats_writer=Module}=State) ->
251258 Window = timer :now_diff (Now , State # state .last_write_time ) / 1000000 ,
252259
253260 % % Time to report latency data to our CSV files
254- {Oks , Errors , OkOpsRes } =
255- lists :foldl (fun (Op , {TotalOks , TotalErrors , OpsResAcc }) ->
256- {Oks , Errors } = report_latency (State , Elapsed , Window , Op ),
257- {TotalOks + Oks , TotalErrors + Errors ,
258- [{Op , Oks }|OpsResAcc ]}
259- end , {0 ,0 ,[]}, State # state .ops ),
261+ {Ops , Oks , Errors , OkOpsRes } =
262+ lists :foldl (fun (Op , {TotalOps , TotalOks , TotalErrors , OpsResAcc }) ->
263+ {Ops , Oks , Errors } = report_latency (State , Elapsed , Window , Op ),
264+ {TotalOps + Ops , TotalOks + Oks , TotalErrors + Errors ,
265+ [{Op , Oks , Ops }|OpsResAcc ]}
266+ end , {0 ,0 ,0 , []}, State # state .ops ),
260267
261268 % % Reset units
262- [folsom_metrics_counter :dec ({units , Op }, OpAmount ) || {Op , OpAmount } <- OkOpsRes ],
269+ [folsom_metrics_counter :dec ({units , Op }, OksAmount ) || {Op , OksAmount , _ } <- OkOpsRes ],
270+ % % Reset Ops
271+ [folsom_metrics_counter :dec ({ops , Op }, OpsAmount ) || {Op , _ , OpsAmount } <- OkOpsRes ],
263272
264273 % % Write summary
265274 Module :process_summary (State # state .stats_writer_data ,
266- Elapsed , Window , Oks , Errors ),
275+ Elapsed , Window , Ops , Oks , Errors ),
267276
268277 % % Dump current error counts to console
269278 case (State # state .errors_since_last_report ) of
@@ -285,7 +294,8 @@ process_global_stats(#state{stats_writer=Module}=State) ->
285294 Stats = folsom_metrics :get_histogram_statistics ({overall_latencies , Op }),
286295 Errors = error_counter (Op ),
287296 Units = folsom_metrics :get_metric_value ({overall_units , Op }),
288- Module :report_global_stats (Op , Stats , Errors , Units )
297+ Ops = folsom_metrics :get_metric_value ({overall_ops , Op }),
298+ Module :report_global_stats (Op , Stats , Errors , Units , Ops )
289299 end , State # state .ops ).
290300
291301% %
@@ -296,12 +306,13 @@ report_latency(#state{stats_writer=Module}=State, Elapsed, Window, Op) ->
296306 Stats = folsom_metrics :get_histogram_statistics ({latencies , Op }),
297307 Errors = error_counter (Op ),
298308 Units = folsom_metrics :get_metric_value ({units , Op }),
309+ Ops = folsom_metrics :get_metric_value ({ops , Op }),
299310
300311 Module :report_latency ({State # state .stats_writer ,
301312 State # state .stats_writer_data },
302313 Elapsed , Window , Op ,
303- Stats , Errors , Units ),
304- {Units , Errors }.
314+ Stats , Errors , Units , Ops ),
315+ {Ops , Units , Errors }.
305316
306317report_total_errors (# state {stats_writer = Module }= State ) ->
307318 case ets :tab2list (basho_bench_total_errors ) of
@@ -349,14 +360,14 @@ get_worker_ops() ->
349360 Workers = basho_bench_config :get (workers , []),
350361 case Workers of
351362 % % No workers reverts to original case is fine as long as we stick with 2-tuples
352- [] ->
363+ [] ->
353364 lists :map (
354365 fun ({OpTag , _Count }) -> {OpTag , OpTag };
355366 ({Label , OpTag , _Count }) -> {Label , OpTag };
356367 ({Label , OpTag , _Count , _OptionsList }) -> {Label , OpTag }
357368 end , basho_bench_config :get (operations , []));
358369 % % Use workers to determine active worker types for current config
359- _ ->
370+ _ ->
360371 get_worker_ops (Workers , basho_bench_config :get (worker_types ), [])
361372 end .
362373
@@ -374,7 +385,7 @@ get_worker_ops([{WorkerType, _Count} | RestWorkers], WorkerTypes, Acc) ->
374385 end ,
375386
376387 Ops = lists :map (
377- fun ({OpTag , _Count2 }) ->
388+ fun ({OpTag , _Count2 }) ->
378389 { worker_op_name (WorkerType , OpTag ), worker_op_name (WorkerType , OpTag )};
379390 ({Label , OpTag , _Count2 }) ->
380391 { worker_op_name (WorkerType , Label ), worker_op_name (WorkerType , OpTag )}
@@ -383,7 +394,7 @@ get_worker_ops([{WorkerType, _Count} | RestWorkers], WorkerTypes, Acc) ->
383394
384395
385396worker_op_name (Worker ,Op ) ->
386- case Worker of
397+ case Worker of
387398 single_worker ->
388399 Op ;
389400 _ ->
0 commit comments