Skip to content
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

Make counters optional. #49

Merged
merged 1 commit into from
Jul 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions lib/olly_trace/olly_trace.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Format = Olly_format_backend

let trace fmt trace_filename exec_args =
let trace fmt trace_filename emit_counter exec_args =
let open Format.Event in
let tracer = Format.create fmt ~filename:trace_filename in
let runtime_phase kind ring_id ts phase =
Expand All @@ -13,13 +13,15 @@ let trace fmt trace_filename exec_args =
}
in
let runtime_counter ring_id ts counter value =
Format.emit tracer
{
name = Runtime_events.runtime_counter_name counter;
ts = Runtime_events.Timestamp.to_int64 ts;
ring_id;
kind = Counter value;
}
if emit_counter then
Format.emit tracer
{
name = Runtime_events.runtime_counter_name counter;
ts = Runtime_events.Timestamp.to_int64 ts;
ring_id;
kind = Counter value;
}
else ()
in
let runtime_begin = runtime_phase SpanBegin
and runtime_end = runtime_phase SpanEnd
Expand Down Expand Up @@ -47,6 +49,10 @@ let trace_cmd format_list =
let doc = "Target trace file name." in
Arg.(required & pos 0 (some string) None & info [] ~docv:"TRACEFILE" ~doc)
in
let emit_counter =
let doc = "Emit runtime counter events." in
Arg.(value & flag & info [ "c"; "emit-counters" ] ~doc)
in
let format_option =
let doc =
"Format of the target trace, options are: "
Expand Down Expand Up @@ -74,4 +80,4 @@ let trace_cmd format_list =
in
let doc = "Save the runtime trace to file." in
let info = Cmd.info "trace" ~doc ~sdocs ~man in
Cmd.v info Term.(const trace $ format_option $ trace_filename $ exec_args 1)
Cmd.v info Term.(const trace $ format_option $ trace_filename $ emit_counter $ exec_args 1)
Loading