mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-08 03:47:59 -04:00
add dummy values for span/trace id, and for span_ctx
This commit is contained in:
parent
e4c41b2b62
commit
84ba8c7473
1 changed files with 16 additions and 1 deletions
|
|
@ -271,6 +271,8 @@ module Trace_id : sig
|
|||
|
||||
val create : unit -> t
|
||||
|
||||
val dummy : t
|
||||
|
||||
val pp : Format.formatter -> t -> unit
|
||||
|
||||
val is_valid : t -> bool
|
||||
|
|
@ -291,6 +293,8 @@ end = struct
|
|||
|
||||
let to_bytes self = self
|
||||
|
||||
let dummy : t = Bytes.make 16 '\x00'
|
||||
|
||||
let create () : t =
|
||||
let b = Collector.rand_bytes_16 () in
|
||||
assert (Bytes.length b = 16);
|
||||
|
|
@ -324,6 +328,8 @@ module Span_id : sig
|
|||
|
||||
val create : unit -> t
|
||||
|
||||
val dummy : t
|
||||
|
||||
val pp : Format.formatter -> t -> unit
|
||||
|
||||
val is_valid : t -> bool
|
||||
|
|
@ -344,6 +350,8 @@ end = struct
|
|||
|
||||
let to_bytes self = self
|
||||
|
||||
let dummy : t = Bytes.make 8 '\x00'
|
||||
|
||||
let create () : t =
|
||||
let b = Collector.rand_bytes_8 () in
|
||||
assert (Bytes.length b = 8);
|
||||
|
|
@ -373,12 +381,16 @@ end
|
|||
|
||||
(** Span context. This bundles up a trace ID and parent ID.
|
||||
|
||||
https://opentelemetry.io/docs/specs/otel/trace/api/#spancontext *)
|
||||
https://opentelemetry.io/docs/specs/otel/trace/api/#spancontext
|
||||
@since NEXT_RELEASE *)
|
||||
module Span_ctx : sig
|
||||
type t
|
||||
|
||||
val make : trace_id:Trace_id.t -> parent_id:Span_id.t -> unit -> t
|
||||
|
||||
val dummy : t
|
||||
(** Invalid span context, to be used as a placeholder *)
|
||||
|
||||
val is_valid : t -> bool
|
||||
|
||||
val trace_id : t -> Trace_id.t
|
||||
|
|
@ -403,6 +415,9 @@ end = struct
|
|||
is_remote: bool;
|
||||
}
|
||||
|
||||
let dummy =
|
||||
{ trace_id = Trace_id.dummy; parent_id = Span_id.dummy; is_remote = false }
|
||||
|
||||
let make ~trace_id ~parent_id () : t =
|
||||
{ trace_id; parent_id; is_remote = false }
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue