|
|
@ -39,17 +39,21 @@ let set_common_fields sample =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let sample_from_event ({label; created_at_ts; data} : LogEntry.t) =
|
|
|
|
let sample_from_event ({label; created_at_ts; data} : LogEntry.t) =
|
|
|
|
let event_name, value =
|
|
|
|
let create_sample_with_label label =
|
|
|
|
match data with
|
|
|
|
Scuba.new_sample ~time:(Some created_at_ts)
|
|
|
|
| LogEntry.Count {value} ->
|
|
|
|
|> set_common_fields |> set_command_line_normales |> set_command_line_tagsets
|
|
|
|
(Printf.sprintf "count.%s" label, value)
|
|
|
|
|> Scuba.add_normal ~name:"event" ~value:label
|
|
|
|
| LogEntry.Time {duration_ms} ->
|
|
|
|
|
|
|
|
(Printf.sprintf "time.%s" label, duration_ms)
|
|
|
|
|
|
|
|
in
|
|
|
|
in
|
|
|
|
Scuba.new_sample ~time:(Some created_at_ts)
|
|
|
|
match data with
|
|
|
|
|> set_common_fields |> set_command_line_normales |> set_command_line_tagsets
|
|
|
|
| Count {value} ->
|
|
|
|
|> Scuba.add_normal ~name:"event" ~value:event_name
|
|
|
|
create_sample_with_label (Printf.sprintf "count.%s" label)
|
|
|
|
|> Scuba.add_int ~name:"value" ~value
|
|
|
|
|> Scuba.add_int ~name:"value" ~value
|
|
|
|
|
|
|
|
| Time {duration_ms} ->
|
|
|
|
|
|
|
|
create_sample_with_label (Printf.sprintf "time.%s" label)
|
|
|
|
|
|
|
|
|> Scuba.add_int ~name:"value" ~value:duration_ms
|
|
|
|
|
|
|
|
| String {message} ->
|
|
|
|
|
|
|
|
create_sample_with_label (Printf.sprintf "msg.%s" label)
|
|
|
|
|
|
|
|
|> Scuba.add_normal ~name:"message" ~value:message
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(** Consider buffering or batching if proves to be a problem *)
|
|
|
|
(** Consider buffering or batching if proves to be a problem *)
|
|
|
@ -66,6 +70,8 @@ let log_one entry = log_many [entry]
|
|
|
|
|
|
|
|
|
|
|
|
let log_count ~label ~value = log_one (LogEntry.mk_count ~label ~value)
|
|
|
|
let log_count ~label ~value = log_one (LogEntry.mk_count ~label ~value)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let log_message ~label ~message = log_one (LogEntry.mk_string ~label ~message)
|
|
|
|
|
|
|
|
|
|
|
|
let execute_with_time_logging label f =
|
|
|
|
let execute_with_time_logging label f =
|
|
|
|
let ret_val, duration_ms = Utils.timeit ~f in
|
|
|
|
let ret_val, duration_ms = Utils.timeit ~f in
|
|
|
|
let entry = LogEntry.mk_time ~label ~duration_ms in
|
|
|
|
let entry = LogEntry.mk_time ~label ~duration_ms in
|
|
|
|