mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-08 03:47:59 -04:00
add Scope.make
This commit is contained in:
parent
b3747cfc8e
commit
41f1f43470
4 changed files with 8 additions and 26 deletions
|
|
@ -33,13 +33,7 @@ module Self_trace = struct
|
|||
else (
|
||||
(* do nothing *)
|
||||
let scope =
|
||||
{
|
||||
Scope.trace_id = dummy_trace_id_;
|
||||
span_id = dummy_span_id;
|
||||
attrs = [];
|
||||
events = [];
|
||||
links = [];
|
||||
}
|
||||
Scope.make ~trace_id:dummy_trace_id_ ~span_id:dummy_span_id ()
|
||||
in
|
||||
f scope
|
||||
)
|
||||
|
|
|
|||
|
|
@ -809,6 +809,10 @@ module Scope = struct
|
|||
mutable links: Span_link.t list;
|
||||
}
|
||||
|
||||
let make ~trace_id ~span_id ?(events = []) ?(attrs = []) ?(links = []) () : t
|
||||
=
|
||||
{ trace_id; span_id; events; attrs; links }
|
||||
|
||||
(** Turn the scope into a span context *)
|
||||
let[@inline] to_span_ctx (self : t) : Span_ctx.t =
|
||||
Span_ctx.make ~trace_id:self.trace_id ~parent_id:self.span_id ()
|
||||
|
|
@ -1049,7 +1053,7 @@ module Trace = struct
|
|||
in
|
||||
let start_time = Timestamp_ns.now_unix_ns () in
|
||||
let span_id = Span_id.create () in
|
||||
let scope = { trace_id; span_id; events = []; attrs; links } in
|
||||
let scope = Scope.make ~trace_id ~span_id ~attrs ~links () in
|
||||
(* called once we're done, to emit a span *)
|
||||
let finally res =
|
||||
let status =
|
||||
|
|
|
|||
|
|
@ -111,15 +111,7 @@ end = struct
|
|||
| Some v ->
|
||||
(match Traceparent.of_value v with
|
||||
| Ok (trace_id, parent_id) ->
|
||||
Some
|
||||
Otel.Trace.
|
||||
{
|
||||
trace_id;
|
||||
span_id = parent_id;
|
||||
events = [];
|
||||
attrs = [];
|
||||
links = [];
|
||||
}
|
||||
Some (Otel.Scope.make ~trace_id ~span_id:parent_id ())
|
||||
| Error _ -> None)
|
||||
|
||||
let remove_trace_context req =
|
||||
|
|
|
|||
|
|
@ -121,15 +121,7 @@ module Internal = struct
|
|||
| None, None -> None
|
||||
in
|
||||
|
||||
let new_scope =
|
||||
{
|
||||
Scope.span_id = otel_id;
|
||||
trace_id;
|
||||
events = [];
|
||||
attrs = data;
|
||||
links = [];
|
||||
}
|
||||
in
|
||||
let new_scope = Otel.Scope.make ~trace_id ~span_id:otel_id ~attrs:data () in
|
||||
|
||||
let start_time = Timestamp_ns.now_unix_ns () in
|
||||
let sb =
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue