mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-07 18:37:56 -05:00
rename hmap keys with more consistent scheme
This commit is contained in:
parent
e9485c97da
commit
a43587f2a6
7 changed files with 11 additions and 9 deletions
|
|
@ -144,4 +144,4 @@ let set_status = span_set_status
|
||||||
|
|
||||||
let set_kind = span_set_kind
|
let set_kind = span_set_kind
|
||||||
|
|
||||||
let k_context : t Context.key = Context.new_key ()
|
let k_ambient : t Context.key = Context.new_key ()
|
||||||
|
|
|
||||||
|
|
@ -124,4 +124,6 @@ val default_kind : Span_kind.t ref
|
||||||
set to "internal", following directions from the [.proto] file. It can be
|
set to "internal", following directions from the [.proto] file. It can be
|
||||||
convenient to set "client" or "server" uniformly in here. *)
|
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 *)
|
||||||
|
|
|
||||||
|
|
@ -88,4 +88,4 @@ let of_w3c_trace_context_exn bs =
|
||||||
| Ok t -> t
|
| Ok t -> t
|
||||||
| Error msg -> invalid_arg @@ spf "invalid w3c trace context: %s" msg
|
| 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 ()
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ val of_w3c_trace_context : bytes -> (t, string) result
|
||||||
val of_w3c_trace_context_exn : bytes -> t
|
val of_w3c_trace_context_exn : bytes -> t
|
||||||
(** @raise Invalid_argument if parsing failed *)
|
(** @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
|
(** Hmap key to carry around a {!Span_ctx.t}, e.g. to remember what the current
|
||||||
parent span is.
|
parent span is.
|
||||||
@since 0.8 *)
|
@since 0.8 *)
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
(** Find current span from ambient-context *)
|
(** Find current span from ambient-context *)
|
||||||
let[@inline] get () : Span.t option =
|
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
|
(** [with_ambient span f] runs [f()] with the current ambient span being set to
|
||||||
[span] *)
|
[span] *)
|
||||||
let[@inline] with_ambient (span : Span.t) (f : unit -> 'a) : 'a =
|
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 ())
|
f ())
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ let k_trace_id = Trace_id.k_trace_id
|
||||||
module Span_id = Span_id
|
module Span_id = Span_id
|
||||||
module Span_ctx = Span_ctx
|
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} *)
|
(** {2 Attributes and conventions} *)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,9 +36,9 @@ open struct
|
||||||
(* sanity check: otrace meta-map must be the same as hmap *)
|
(* sanity check: otrace meta-map must be the same as hmap *)
|
||||||
let () = ignore (fun (k : _ Hmap.key) : _ Ambient_context.Context.key -> k)
|
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 =
|
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:_
|
let enter_span (self : state) ~__FUNCTION__ ~__FILE__ ~__LINE__ ~level:_
|
||||||
~params:_ ~(data : (_ * Otrace.user_data) list) ~parent name : Otrace.span
|
~params:_ ~(data : (_ * Otrace.user_data) list) ~parent name : Otrace.span
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue