add dummy values for span/trace id, and for span_ctx

This commit is contained in:
Simon Cruanes 2024-02-12 13:44:02 -05:00
parent e4c41b2b62
commit 84ba8c7473
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4

View file

@ -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 }