mirror of
https://github.com/ocaml-tracing/ocaml-trace.git
synced 2026-03-07 18:37:56 -05:00
add {thread,process}_sort_index extension + TEF support
https://github.com/google/perfetto/pull/3273/changes#diff-ecec88c33adb7591ee6aa88e29b62ad52ef443611cba5e0f0ecac9b5725afdba allows user to sort threads/processes.
This commit is contained in:
parent
627164afd0
commit
e4d4e23530
4 changed files with 34 additions and 0 deletions
|
|
@ -8,6 +8,10 @@ open Types
|
|||
type extension_event +=
|
||||
| Extension_set_thread_name of string
|
||||
| Extension_set_process_name of string
|
||||
| Extension_set_thread_sort_index of int
|
||||
(** https://github.com/google/perfetto/pull/3273/changes#diff-ecec88c33adb7591ee6aa88e29b62ad52ef443611cba5e0f0ecac9b5725afdba
|
||||
*)
|
||||
| Extension_set_process_sort_index of int
|
||||
|
||||
(** Specialized parameters *)
|
||||
type extension_parameter +=
|
||||
|
|
|
|||
|
|
@ -142,12 +142,27 @@ open struct
|
|||
Writer.emit_name_process ~pid:self.pid ~name buf;
|
||||
self.exporter.on_json buf
|
||||
|
||||
let on_thread_sort_index_ (self : st) ~tid i : unit =
|
||||
let@ buf = Trace_util.Rpool.with_ self.buf_pool in
|
||||
Writer.emit_thread_sort_index ~pid:self.pid ~tid i buf;
|
||||
self.exporter.on_json buf
|
||||
|
||||
let on_process_sort_index_ (self : st) i : unit =
|
||||
let@ buf = Trace_util.Rpool.with_ self.buf_pool in
|
||||
Writer.emit_process_sort_index ~pid:self.pid i buf;
|
||||
self.exporter.on_json buf
|
||||
|
||||
let extension (self : st) ~level:_ ev =
|
||||
match ev with
|
||||
| Core_ext.Extension_set_thread_name name ->
|
||||
let tid = Trace_util.Mock_.get_tid () in
|
||||
on_name_thread_ self ~tid name
|
||||
| Core_ext.Extension_set_process_name name -> on_name_process_ self name
|
||||
| Core_ext.Extension_set_process_sort_index idx ->
|
||||
on_process_sort_index_ self idx
|
||||
| Core_ext.Extension_set_thread_sort_index idx ->
|
||||
let tid = Trace_util.Mock_.get_tid () in
|
||||
on_thread_sort_index_ self ~tid idx
|
||||
| _ -> ()
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -75,6 +75,19 @@ let emit_name_thread ~pid ~tid ~name buf : unit =
|
|||
(emit_args_o_ pp_user_data_)
|
||||
[ "name", `String name ]
|
||||
|
||||
let emit_process_sort_index ~pid i buf : unit =
|
||||
Printf.bprintf buf
|
||||
{json|{"pid":%d,"name":"process_sort_index","ph":"M"%a}|json} pid
|
||||
(emit_args_o_ pp_user_data_)
|
||||
[ "sort_index", `Int i ]
|
||||
|
||||
let emit_thread_sort_index ~pid ~tid i buf : unit =
|
||||
Printf.bprintf buf
|
||||
{json|{"pid":%d,"tid": %d,"name":"thread_sort_index","ph":"M"%a}|json} pid
|
||||
tid
|
||||
(emit_args_o_ pp_user_data_)
|
||||
[ "sort_index", `Int i ]
|
||||
|
||||
let emit_name_process ~pid ~name buf : unit =
|
||||
Printf.bprintf buf {json|{"pid":%d,"name":"process_name","ph":"M"%a}|json} pid
|
||||
(emit_args_o_ pp_user_data_)
|
||||
|
|
|
|||
|
|
@ -46,6 +46,8 @@ val emit_instant_event :
|
|||
|
||||
val emit_name_thread : pid:int -> tid:int -> name:string -> Buffer.t -> unit
|
||||
val emit_name_process : pid:int -> name:string -> Buffer.t -> unit
|
||||
val emit_process_sort_index : pid:int -> int -> Buffer.t -> unit
|
||||
val emit_thread_sort_index : pid:int -> tid:int -> int -> Buffer.t -> unit
|
||||
|
||||
val emit_counter :
|
||||
pid:int -> tid:int -> name:string -> ts:float -> Buffer.t -> float -> unit
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue