mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-08 03:47:59 -04:00
migrate a few more things to lib/ from core/
This commit is contained in:
parent
5804cd299b
commit
9453506d7b
9 changed files with 25 additions and 11 deletions
|
|
@ -28,9 +28,10 @@ let[@inline] trace_id self = Trace_id.of_bytes self.trace_id
|
|||
|
||||
let[@inline] is_not_dummy self = Span_id.is_valid (id self)
|
||||
|
||||
let make ?(kind = !Globals.default_span_kind) ?trace_state ?(attrs = [])
|
||||
?(events = []) ?status ~trace_id ~id ?parent ?(links = []) ~start_time
|
||||
~end_time name : t =
|
||||
let default_kind = ref Proto.Trace.Span_kind_unspecified
|
||||
|
||||
let make ?(kind = !default_kind) ?trace_state ?(attrs = []) ?(events = [])
|
||||
?status ~trace_id ~id ?parent ?(links = []) ~start_time ~end_time name : t =
|
||||
let trace_id = Trace_id.to_bytes trace_id in
|
||||
let parent_span_id = Option.map Span_id.to_bytes parent in
|
||||
let attributes = List.map Key_value.conv attrs in
|
||||
|
|
@ -99,7 +100,14 @@ let record_exception (self : t) (exn : exn) (bt : Printexc.raw_backtrace) : unit
|
|||
add_event self ev
|
||||
)
|
||||
|
||||
let[@inline] add_attrs (self : t) (attrs : unit -> Key_value.t list) : unit =
|
||||
let add_attrs (self : t) (attrs : Key_value.t list) : unit =
|
||||
if is_not_dummy self then (
|
||||
let attrs = List.rev_map Key_value.conv attrs in
|
||||
let attrs = List.rev_append attrs self.attributes in
|
||||
span_set_attributes self attrs
|
||||
)
|
||||
|
||||
let add_attrs' (self : t) (attrs : unit -> Key_value.t list) : unit =
|
||||
if is_not_dummy self then (
|
||||
let attrs = List.rev_map Key_value.conv (attrs ()) in
|
||||
let attrs = List.rev_append attrs self.attributes in
|
||||
|
|
|
|||
|
|
@ -112,4 +112,11 @@ val set_kind : t -> Span_kind.t -> unit
|
|||
(** Set the span's kind.
|
||||
@since 0.11 *)
|
||||
|
||||
val default_kind : Span_kind.t ref
|
||||
(** Default span kind in {!make} and {!create_new}.
|
||||
|
||||
This will be used in all spans that do not specify [~kind] explicitly; it is
|
||||
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
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ let setup ?(min_interval_s = default_interval_s) (exp : Exporter.t) =
|
|||
Exporter.on_tick exp on_tick
|
||||
|
||||
let setup_on_main_exporter ?min_interval_s () =
|
||||
match Exporter.Main_exporter.get () with
|
||||
match Main_exporter.get () with
|
||||
| None -> ()
|
||||
| Some exp -> setup ?min_interval_s exp
|
||||
|
||||
|
|
@ -43,12 +43,7 @@ let merge_global_attributes_ into : _ list =
|
|||
let not_redundant kv = List.for_all (fun kv' -> kv.key <> kv'.key) into in
|
||||
List.rev_append (List.filter not_redundant !global_attributes) into
|
||||
|
||||
(** Default span kind in {!Span.create}. This will be used in all spans that do
|
||||
not specify [~kind] explicitly; it is set to "internal", following
|
||||
directions from the [.proto] file. It can be convenient to set "client" or
|
||||
"server" uniformly in here.
|
||||
@since 0.4 *)
|
||||
let default_span_kind = ref Proto.Trace.Span_kind_internal
|
||||
let default_span_kind = Span.default_kind
|
||||
|
||||
open struct
|
||||
let runtime_attributes =
|
||||
|
|
@ -7,6 +7,10 @@ module Alist = Alist
|
|||
(** Atomic list, for internal usage
|
||||
@since 0.7 *)
|
||||
|
||||
module Interval_limiter = Interval_limiter
|
||||
(** Utility to limit the frequency of some event
|
||||
@since NEXT_RELEASE *)
|
||||
|
||||
(** {2 Wire format} *)
|
||||
|
||||
module Proto = Opentelemetry_proto
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue