[infer] Log accumulated backend counters to scuba

Reviewed By: jvillard

Differential Revision: D16422748

fbshipit-source-id: bc1a5a93f
master
Mitya Lyubarskiy 5 years ago committed by Facebook Github Bot
parent cb4a16b460
commit 7c2f1a955f

@ -7,12 +7,18 @@
open! IStd
module F = Format
type t =
{ mutable summary_file_try_load: int
; mutable summary_read_from_disk: int
; mutable summary_cache_hits: int
; mutable summary_cache_misses: int
; mutable summary_has_model_queries: int }
include struct
(* ignore dead modules added by @@deriving fields *)
[@@@warning "-60"]
type t =
{ mutable summary_file_try_load: int
; mutable summary_read_from_disk: int
; mutable summary_cache_hits: int
; mutable summary_cache_misses: int
; mutable summary_has_model_queries: int }
[@@deriving fields]
end
let global_stats =
{ summary_file_try_load= 0
@ -100,3 +106,15 @@ let pp f stats =
summary_file_try_load summary_read_from_disk summary_cache_hits
(pp_hit_percent summary_cache_hits summary_cache_misses)
summary_cache_misses summary_has_model_queries
let log_to_scuba stats =
let create_counter field =
LogEntry.mk_count ~label:("backend_stats." ^ Field.name field) ~value:(Field.get field stats)
in
let entries =
Fields.to_list ~summary_file_try_load:create_counter ~summary_read_from_disk:create_counter
~summary_cache_hits:create_counter ~summary_cache_misses:create_counter
~summary_has_model_queries:create_counter
in
ScubaLogging.log_many entries

@ -35,3 +35,6 @@ val pp : Format.formatter -> t -> unit
val merge : t -> t -> t
(** return a new value that adds up the stats in both arguments *)
val log_to_scuba : t -> unit
(** Log aggregated backend stats to Scuba. Use after the stats have been fully calculated *)

@ -154,4 +154,5 @@ let main ~changed_files =
let stats = analyze source_files in
L.progress "@\nAnalysis finished in %as@." Pp.elapsed_time () ;
L.debug Analysis Quiet "collected stats:@\n%a@." BackendStats.pp stats ;
BackendStats.log_to_scuba stats ;
output_json_makefile_stats source_files

@ -17,6 +17,11 @@ open! IStd
run of Infer.
*)
val log_many : LogEntry.t list -> unit
(** Log several events in one go. Useful when you do custom aggregations
and have a place to log all aggregated results at once.
*)
val log_count : label:string -> value:int -> unit
(** Log anything that can be counted. Events will be prefixed with "count." *)

Loading…
Cancel
Save