Writer.Expertmodule type Destination = Writer_intf.Destinationval create :
?num_temp_strs:int ->
destination:(module Destination) ->
unit ->
tval create_no_header :
?num_temp_strs:int ->
destination:(module Destination) ->
unit ->
tCreates writer without writing a FXT file header to the destination.
val set_destination : t -> destination:(module Destination) -> unitSwitches destination for future data. Use with care; does not reset any state.
val write_bytes : t -> bytes:Core.Bytes.t -> unitWrites raw byte stream to the current destination.
val write_iobuf :
t ->
buf:(Core.read, Iobuf.seek, Iobuf.global) Iobuf.t ->
unitWrites raw byte stream to the current destination.
val set_string_slot : t -> slot:int -> string @ local -> String_id.tInterns a string directly to the specified slot (whereas set_temp_string_slot may shift the index since certain indices are reserved for internal use). Will raise when setting slot 1 to any string other than "process".
Useful for preserving the string ID usage of parsed traces in a way that can lead to exact byte equality after a round trip through parsing and writing.
val force_switch_buffers : t -> unitImmediately ask the destination for a new buffer even if the current one isn't full. This is intended for use by the probe infrastructure when a destination for the global writer is initialized.
val flush : t -> unitFinish all pending writes to underlying buffer.
This is currently only intended for use by tests.
val set_name : header:header -> name:String_id.t -> headermodule Event_type : sig ... endFor use with precompute_header_and_size
val write_event :
t ->
event_type:Event_type.t ->
extra_words:int ->
arg_types:Arg_types.t ->
thread:Thread_id.t ->
category:String_id.t ->
name:String_id.t ->
ticks:int ->
unitval precompute_header :
event_type:Event_type.t ->
extra_words:int ->
arg_types:Arg_types.t ->
thread:Thread_id.t ->
category:String_id.t ->
name:String_id.t ->
headerPre-compose an event header word, for use with write_from_header_with_tsc
val get_dyn_slot : slot:int -> String_id.tProvides a way to get the String_id.t of the slots that are reserved for higher level libraries.
val set_dyn_slot : t -> slot:int -> string @ local -> String_id.tInterns a string into one of 17 temporary slots reserved for ppx_tracing. These slots are exclusively used to store the category, name, and names of arguments when they cannot be interned globally. Unlike set_temp_string_slot, strings interned to these slots are valid *only* immediately after interning, as the slot will be reused in subsequent probes.
Write an event using a pre-composed header, and using less safety checking than the normal event writing functions, intended for low-overhead probe instrumentation. Also uses the rdtsc counter for the ticks field, meaning this Writer must have been created with a calibrated ticks_per_second field to have correct timing.
The pre-composition itself saves about 3ns per event. The omission of unnecessary checks saves additional time. Overall in benchmarks this is about 2x faster than using the usual write_* functions, saving about 6ns per event.
The only caller-visible check omission should be that it doesn't check the corectness of arguments, which can result in invalid trace files if the arguments written don't match the header. Users of this function must use Write_arg_unchecked because it doesn't set the necessary state for checking.
val write_from_header_and_get_tsc : t -> header:header -> Time_stamp_counter.tSame as write_from_header_with_tsc but returns ticks. See Tracing.Writer.write_duration_instant.
val write_tsc : t -> Time_stamp_counter.t -> unitUnchecked writing of the result of write_from_header_and_get_tsc after the arguments.
val write_string_stream : t -> string @ local -> unitUnchecked write of a string stream.
val write_async_id : t -> int -> unitUnchecked write of a correlation id to complete an async event.
val set_string_map_allocate_on_intern : t -> enable:bool -> unitEnables or disables mapping String_id.t to string when interning strings.
Use with caution: Enabling this will allocate upon interning strings and cost an additional Hashtbl.add call.
val string_of_string_id : t -> String_id.t -> string optionReturns a string represented by the corresponding String_id.t
module Write_arg_unchecked :
Writer_intf.Arg_writers with type t := t and type string_id := String_id.tUnchecked versions of the Write_arg functions that can result in invalid traces.