mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-08 03:47:59 -04:00
add Span.dummy
This commit is contained in:
parent
30baf3491c
commit
18226a63a4
2 changed files with 12 additions and 2 deletions
|
|
@ -44,6 +44,12 @@ let make ?(kind = !default_kind) ?trace_state ?(attrs = []) ?(events = [])
|
|||
in
|
||||
span
|
||||
|
||||
let dummy : t =
|
||||
Proto.Trace.make_span
|
||||
~trace_id:Trace_id.(dummy |> to_bytes)
|
||||
~span_id:Span_id.(dummy |> to_bytes)
|
||||
()
|
||||
|
||||
let create_new ?kind ?(id = Span_id.create ()) ?trace_state ?attrs ?events
|
||||
?status ~trace_id ?parent ?links ~start_time ~end_time name : t =
|
||||
make ?kind ~id ~trace_id ?trace_state ?attrs ?events ?status ?parent ?links
|
||||
|
|
@ -84,7 +90,8 @@ let[@inline] to_span_ctx (self : t) : Span_ctx.t =
|
|||
let[@inline] add_event self ev : unit =
|
||||
if is_not_dummy self then span_set_events self (ev :: self.events)
|
||||
|
||||
let add_event' self ev : unit = if is_not_dummy self then add_event self (ev ())
|
||||
let add_event' self ev : unit =
|
||||
if is_not_dummy self then span_set_events self (ev () :: self.events)
|
||||
|
||||
let record_exception (self : t) (exn : exn) (bt : Printexc.raw_backtrace) : unit
|
||||
=
|
||||
|
|
@ -117,7 +124,7 @@ let add_attrs' (self : t) (attrs : unit -> Key_value.t list) : unit =
|
|||
)
|
||||
|
||||
let add_links (self : t) (links : Span_link.t list) : unit =
|
||||
if links <> [] then (
|
||||
if is_not_dummy self && links <> [] then (
|
||||
let links = List.rev_append links self.links in
|
||||
span_set_links self links
|
||||
)
|
||||
|
|
|
|||
|
|
@ -51,6 +51,9 @@ val trace_id : t -> Trace_id.t
|
|||
|
||||
val is_not_dummy : t -> bool
|
||||
|
||||
val dummy : t
|
||||
(** Dummy span, will not record anything *)
|
||||
|
||||
val create_new :
|
||||
?kind:kind ->
|
||||
?id:Span_id.t ->
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue