mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-09 04:17:56 -04:00
feat: update and fix opentelemetry.trace
This commit is contained in:
parent
9680d61a36
commit
60a0b843e6
3 changed files with 11 additions and 6 deletions
|
|
@ -3,4 +3,4 @@
|
||||||
(public_name opentelemetry.trace)
|
(public_name opentelemetry.trace)
|
||||||
(synopsis "Use opentelemetry as a collector for trace")
|
(synopsis "Use opentelemetry as a collector for trace")
|
||||||
(optional)
|
(optional)
|
||||||
(libraries ambient-context ambient-context.tls trace.core opentelemetry))
|
(libraries opentelemetry.ambient-context trace.core opentelemetry))
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
module Otel = Opentelemetry
|
module Otel = Opentelemetry
|
||||||
module Otrace = Trace_core (* ocaml-trace *)
|
module Otrace = Trace_core (* ocaml-trace *)
|
||||||
module TLS = Ambient_context_tls.TLS
|
module TLS = Thread_local_storage
|
||||||
|
|
||||||
open struct
|
open struct
|
||||||
let spf = Printf.sprintf
|
let spf = Printf.sprintf
|
||||||
|
|
@ -75,9 +75,14 @@ module Internal = struct
|
||||||
|
|
||||||
let create () : t = { tbl = Active_span_tbl.create 32 }
|
let create () : t = { tbl = Active_span_tbl.create 32 }
|
||||||
|
|
||||||
let tls : t TLS.t = TLS.create ()
|
let k_tls : t TLS.t = TLS.create ()
|
||||||
|
|
||||||
let[@inline] get () : t = TLS.get_or_create tls ~create
|
let[@inline] get () : t =
|
||||||
|
try TLS.get_exn k_tls
|
||||||
|
with TLS.Not_set ->
|
||||||
|
let self = create () in
|
||||||
|
TLS.set k_tls self;
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
let otrace_of_otel (id : Otel.Span_id.t) : int64 =
|
let otrace_of_otel (id : Otel.Span_id.t) : int64 =
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
module Otel := Opentelemetry
|
module Otel := Opentelemetry
|
||||||
module Otrace := Trace_core
|
module Otrace := Trace_core
|
||||||
module TLS := Ambient_context_tls.TLS
|
module TLS := Thread_local_storage
|
||||||
|
|
||||||
(** [opentelemetry.trace] implements a {!Trace_core.Collector} for
|
(** [opentelemetry.trace] implements a {!Trace_core.Collector} for
|
||||||
{{:https://v3.ocaml.org/p/trace} ocaml-trace}.
|
{{:https://v3.ocaml.org/p/trace} ocaml-trace}.
|
||||||
|
|
@ -176,7 +176,7 @@ module Internal : sig
|
||||||
|
|
||||||
val create : unit -> t
|
val create : unit -> t
|
||||||
|
|
||||||
val tls : t TLS.t
|
val k_tls : t TLS.t
|
||||||
|
|
||||||
val get : unit -> t
|
val get : unit -> t
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue