Merge pull request #11 from AestheticIntegration/trace-with-scope

feat: allow passing ~scope back to Trace.with_
This commit is contained in:
Matt Bray 2022-03-25 16:14:37 +00:00 committed by GitHub
commit 89dae63114
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 3 deletions

View file

@ -15,8 +15,20 @@ module Trace = struct
(** Sync span guard *)
let with_
?trace_state ?service_name ?(attrs=[])
?kind ?(trace_id=Trace_id.create()) ?parent ?links
?kind ?trace_id ?parent ?scope ?links
name (f:Trace.scope -> 'a Lwt.t) : 'a Lwt.t =
let trace_id =
match trace_id, scope with
| Some trace_id, _ -> trace_id
| None, Some scope -> scope.trace_id
| None, None -> Trace_id.create ()
in
let parent =
match parent, scope with
| Some span_id, _ -> Some span_id
| None, Some scope -> Some scope.span_id
| None, None -> None
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} in

View file

@ -463,9 +463,20 @@ module Trace = struct
(** Sync span guard *)
let with_
?trace_state ?service_name ?(attrs = [])
?kind ?(trace_id=Trace_id.create()) ?parent ?links
?kind ?trace_id ?parent ?scope ?links
name (f: scope -> 'a) : 'a =
let trace_id =
match trace_id, scope with
| Some trace_id, _ -> trace_id
| None, Some scope -> scope.trace_id
| None, None -> Trace_id.create ()
in
let parent =
match parent, scope with
| Some span_id, _ -> Some span_id
| None, Some scope -> Some scope.span_id
| None, None -> None
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} in