From 04c3ccaac52a722038b0ee9857701a72a6c56b18 Mon Sep 17 00:00:00 2001 From: Mitya Lyubarskiy Date: Tue, 21 May 2019 04:01:51 -0700 Subject: [PATCH] [infer][logging] support passing arbitrary scuba columns to infer Summary: `infer_events` table is a key-value storage that also have list of fields common for entire infer run. Infer should be agnostic of many of such fields (e.g. diff number). Hence we will pass such extra fields through CI. Note that only "normals" (strings in scuba terminology) are currently supported. Reason being: most of things that are technically ints (like IDs) should actually be normals (because average etc does not make sense for them; and group by, in contrast, does). Reviewed By: jvillard Differential Revision: D15376636 fbshipit-source-id: 729eaabfc --- infer/man/man1/infer-full.txt | 4 ++++ infer/src/base/Config.ml | 7 +++++++ infer/src/base/Config.mli | 2 ++ infer/src/scuba/ScubaEventLogging.ml | 7 ++++++- 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/infer/man/man1/infer-full.txt b/infer/man/man1/infer-full.txt index 8cb7eebb1..8ba336501 100644 --- a/infer/man/man1/infer-full.txt +++ b/infer/man/man1/infer-full.txt @@ -1579,6 +1579,10 @@ INTERNAL OPTIONS Activates: (direct) logging to scuba (Conversely: --no-scuba-logging) + --scuba-normal +key=value + add an extra string (normal) field to be set for each sample of + scuba, format = + --seconds-per-iteration float Set the number of seconds per iteration (see --iterations) diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index ea2a5eb00..7737692b8 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -2017,6 +2017,11 @@ and select = and scuba_logging = CLOpt.mk_bool ~long:"scuba-logging" "(direct) logging to scuba " +and scuba_normals = + CLOpt.mk_string_map ~long:"scuba-normal" + "add an extra string (normal) field to be set for each sample of scuba, format =" + + and siof_safe_methods = CLOpt.mk_string_list ~long:"siof-safe-methods" ~in_help:InferCommand.[(Analyze, manual_siof)] @@ -2997,6 +3002,8 @@ and select = !select and scuba_logging = !scuba_logging +and scuba_normals = !scuba_normals + and show_buckets = !print_buckets and siof = !siof diff --git a/infer/src/base/Config.mli b/infer/src/base/Config.mli index 046129796..04c1ff6d8 100644 --- a/infer/src/base/Config.mli +++ b/infer/src/base/Config.mli @@ -600,6 +600,8 @@ val results_dir : string val scuba_logging : bool +val scuba_normals : string String.Map.t + val seconds_per_iteration : float option val select : int option diff --git a/infer/src/scuba/ScubaEventLogging.ml b/infer/src/scuba/ScubaEventLogging.ml index d751f28e1..cb4a91d1a 100644 --- a/infer/src/scuba/ScubaEventLogging.ml +++ b/infer/src/scuba/ScubaEventLogging.ml @@ -17,6 +17,11 @@ let maybe_add_normal ~name ~value sample = match value with None -> sample | Some value -> Scuba.add_normal ~name ~value sample +let set_command_line_normales sample = + let add_normal ~key ~data = Scuba.add_normal ~name:key ~value:data in + Map.fold Config.scuba_normals ~init:sample ~f:add_normal + + let set_common_fields sample = let open Scuba in sample @@ -29,7 +34,7 @@ let set_common_fields sample = let create_sample ~event_name ~value = - Scuba.new_sample ~time:None |> set_common_fields + Scuba.new_sample ~time:None |> set_common_fields |> set_command_line_normales |> Scuba.add_normal ~name:"event" ~value:event_name |> Scuba.add_int ~name:"value" ~value