mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-08 03:47:59 -04:00
opentelemetry: add a hmap in Scope.t
This commit is contained in:
parent
e33a792f46
commit
90208d1733
1 changed files with 13 additions and 3 deletions
|
|
@ -894,10 +894,11 @@ end
|
||||||
module Scope : sig
|
module Scope : sig
|
||||||
type item_list
|
type item_list
|
||||||
|
|
||||||
type t = {
|
type t = private {
|
||||||
trace_id: Trace_id.t;
|
trace_id: Trace_id.t;
|
||||||
span_id: Span_id.t;
|
span_id: Span_id.t;
|
||||||
mutable items: item_list;
|
mutable items: item_list;
|
||||||
|
mutable hmap: Hmap.t; (** additional data, @since NEXT_RELEASE *)
|
||||||
}
|
}
|
||||||
|
|
||||||
val attrs : t -> key_value list
|
val attrs : t -> key_value list
|
||||||
|
|
@ -975,6 +976,10 @@ module Scope : sig
|
||||||
|
|
||||||
@see <https://github.com/ELLIOTTCABLE/ocaml-ambient-context>
|
@see <https://github.com/ELLIOTTCABLE/ocaml-ambient-context>
|
||||||
ambient-context docs *)
|
ambient-context docs *)
|
||||||
|
|
||||||
|
val hmap_set : 'a Hmap.key -> 'a -> t -> unit
|
||||||
|
(** Modify the hmap.
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
end = struct
|
end = struct
|
||||||
type item_list =
|
type item_list =
|
||||||
| Nil
|
| Nil
|
||||||
|
|
@ -988,6 +993,7 @@ end = struct
|
||||||
trace_id: Trace_id.t;
|
trace_id: Trace_id.t;
|
||||||
span_id: Span_id.t;
|
span_id: Span_id.t;
|
||||||
mutable items: item_list;
|
mutable items: item_list;
|
||||||
|
mutable hmap: Hmap.t;
|
||||||
}
|
}
|
||||||
|
|
||||||
let attrs scope =
|
let attrs scope =
|
||||||
|
|
@ -1049,7 +1055,8 @@ end = struct
|
||||||
in
|
in
|
||||||
List.fold_left (fun acc link -> Span_link (link, acc)) items links
|
List.fold_left (fun acc link -> Span_link (link, acc)) items links
|
||||||
in
|
in
|
||||||
{ trace_id; span_id; items }
|
let hmap = Hmap.empty in
|
||||||
|
{ trace_id; span_id; items; hmap }
|
||||||
|
|
||||||
let[@inline] to_span_link ?trace_state ?attrs ?dropped_attributes_count
|
let[@inline] to_span_link ?trace_state ?attrs ?dropped_attributes_count
|
||||||
(self : t) : Span_link.t =
|
(self : t) : Span_link.t =
|
||||||
|
|
@ -1107,6 +1114,8 @@ end = struct
|
||||||
|
|
||||||
let[@inline] with_ambient_scope (sc : t) (f : unit -> 'a) : 'a =
|
let[@inline] with_ambient_scope (sc : t) (f : unit -> 'a) : 'a =
|
||||||
Ambient_context.with_key_bound_to ambient_scope_key sc f
|
Ambient_context.with_key_bound_to ambient_scope_key sc f
|
||||||
|
|
||||||
|
let[@inline] hmap_set k v self = self.hmap <- Hmap.add k v self.hmap
|
||||||
end
|
end
|
||||||
|
|
||||||
(** {2 Traces} *)
|
(** {2 Traces} *)
|
||||||
|
|
@ -1233,10 +1242,11 @@ module Trace = struct
|
||||||
let rs = make_resource_spans ?service_name ?attrs spans in
|
let rs = make_resource_spans ?service_name ?attrs spans in
|
||||||
Collector.send_trace [ rs ] ~ret:(fun () -> ())
|
Collector.send_trace [ rs ] ~ret:(fun () -> ())
|
||||||
|
|
||||||
type scope = Scope.t = {
|
type scope = Scope.t = private {
|
||||||
trace_id: Trace_id.t;
|
trace_id: Trace_id.t;
|
||||||
span_id: Span_id.t;
|
span_id: Span_id.t;
|
||||||
mutable items: Scope.item_list;
|
mutable items: Scope.item_list;
|
||||||
|
mutable hmap: Hmap.t;
|
||||||
}
|
}
|
||||||
[@@deprecated "use Scope.t"]
|
[@@deprecated "use Scope.t"]
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue