rename hmap keys with more consistent scheme

This commit is contained in:
Simon Cruanes 2026-02-15 18:45:08 +00:00
parent e9485c97da
commit a43587f2a6
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4
7 changed files with 11 additions and 9 deletions

View file

@ -144,4 +144,4 @@ let set_status = span_set_status
let set_kind = span_set_kind
let k_context : t Context.key = Context.new_key ()
let k_ambient : t Context.key = Context.new_key ()

View file

@ -124,4 +124,6 @@ val default_kind : Span_kind.t ref
set to "internal", following directions from the [.proto] file. It can be
convenient to set "client" or "server" uniformly in here. *)
val k_context : t Context.key
val k_ambient : t Context.key
(** Context key to carry around a {!Span.t} in ambient context.
@since NEXT_RELEASE *)

View file

@ -88,4 +88,4 @@ let of_w3c_trace_context_exn bs =
| Ok t -> t
| Error msg -> invalid_arg @@ spf "invalid w3c trace context: %s" msg
let k_span_ctx : t Hmap.key = Hmap.Key.create ()
let k_ambient : t Hmap.key = Hmap.Key.create ()

View file

@ -36,7 +36,7 @@ val of_w3c_trace_context : bytes -> (t, string) result
val of_w3c_trace_context_exn : bytes -> t
(** @raise Invalid_argument if parsing failed *)
val k_span_ctx : t Hmap.key
val k_ambient : t Hmap.key
(** Hmap key to carry around a {!Span_ctx.t}, e.g. to remember what the current
parent span is.
@since 0.8 *)

View file

@ -1,9 +1,9 @@
(** Find current span from ambient-context *)
let[@inline] get () : Span.t option =
Opentelemetry_ambient_context.get Span.k_context
Opentelemetry_ambient_context.get Span.k_ambient
(** [with_ambient span f] runs [f()] with the current ambient span being set to
[span] *)
let[@inline] with_ambient (span : Span.t) (f : unit -> 'a) : 'a =
Opentelemetry_ambient_context.with_key_bound_to Span.k_context span (fun _ ->
Opentelemetry_ambient_context.with_key_bound_to Span.k_ambient span (fun _ ->
f ())

View file

@ -40,7 +40,7 @@ let k_trace_id = Trace_id.k_trace_id
module Span_id = Span_id
module Span_ctx = Span_ctx
let k_span_ctx = Span_ctx.k_span_ctx
let k_ambient = Span_ctx.k_ambient
(** {2 Attributes and conventions} *)

View file

@ -36,9 +36,9 @@ open struct
(* sanity check: otrace meta-map must be the same as hmap *)
let () = ignore (fun (k : _ Hmap.key) : _ Ambient_context.Context.key -> k)
(** Key to access the current span context. *)
(** Key to access the current span context. Uses the shared key from core. *)
let k_span_ctx : OTEL.Span_ctx.t Ambient_context.Context.key =
Ambient_context.Context.new_key ()
OTEL.Span_ctx.k_ambient
let enter_span (self : state) ~__FUNCTION__ ~__FILE__ ~__LINE__ ~level:_
~params:_ ~(data : (_ * Otrace.user_data) list) ~parent name : Otrace.span