mirror of
https://github.com/ocaml-tracing/ocaml-trace.git
synced 2026-03-07 18:37:56 -05:00
trace.simple: a basic span type as illustration
This commit is contained in:
parent
64936441ef
commit
85ef7f4587
2 changed files with 39 additions and 0 deletions
6
src/simple/dune
Normal file
6
src/simple/dune
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
|
||||||
|
(library
|
||||||
|
(name trace_simple)
|
||||||
|
(public_name trace.simple)
|
||||||
|
(synopsis "simple type for spans")
|
||||||
|
(libraries trace.core trace.util))
|
||||||
33
src/simple/simple_span.ml
Normal file
33
src/simple/simple_span.ml
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
(** A simple span.
|
||||||
|
|
||||||
|
This is a concrete representation of spans that is convenient to manipulate.
|
||||||
|
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
|
open Trace_core
|
||||||
|
|
||||||
|
type span_flavor =
|
||||||
|
[ `Sync
|
||||||
|
| `Async
|
||||||
|
]
|
||||||
|
|
||||||
|
type t = {
|
||||||
|
name: string;
|
||||||
|
__FUNCTION__: string option;
|
||||||
|
__FILE__: string;
|
||||||
|
__LINE__: int;
|
||||||
|
time_ns: int64; (** Time the span was entered. *)
|
||||||
|
mutable time_exit_ns: int64;
|
||||||
|
(** Time the span was exited. Set at exit, [Int64.max_int] otherwise *)
|
||||||
|
tid: int; (** Thread in which span was created *)
|
||||||
|
trace_id: int64; (** For async spans *)
|
||||||
|
parent: parent;
|
||||||
|
flavor: span_flavor;
|
||||||
|
params: extension_parameter list;
|
||||||
|
mutable data: (string * Trace_core.user_data) list;
|
||||||
|
(** Modified by [add_data_to_span] *)
|
||||||
|
}
|
||||||
|
(** The type of spans used by all subscribers. *)
|
||||||
|
|
||||||
|
type Trace_core.span +=
|
||||||
|
| Span_simple of t (** How to turn a {!Simple_span.t} into a {!span}. *)
|
||||||
Loading…
Add table
Reference in a new issue