Skip to content

Commit 93587b9

Browse files
committed
update to trace 0.12 and OTEL main
1 parent 6b59da1 commit 93587b9

5 files changed

Lines changed: 17 additions & 25 deletions

File tree

devkit.opam

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ depends: [
1919
"libevent" {>= "0.8.0"}
2020
"ocurl" {>= "0.7.2"}
2121
"pcre2" {>= "8.0.3"}
22-
"trace" {>= "0.4"}
22+
"trace" {>= "0.12"}
2323
"extunix" {>= "0.1.4"}
2424
"lwt" {>= "5.7.0"}
2525
"lwt_ppx"
@@ -37,6 +37,6 @@ depopts: [
3737
]
3838
conflicts: [
3939
"jemalloc" {< "0.2"}
40-
"opentelemetry" {< "0.6"}
40+
"opentelemetry" {< "0.13"}
4141
]
4242
available: arch != "arm32" & arch != "x86_32"

possibly_otel.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module Otrace := Trace_core
22

33
module Traceparent : sig
44
val name : string
5-
val get_ambient : ?explicit_span:Trace_core.explicit_span -> unit -> string option
5+
val get_ambient : ?explicit_span:Trace_core.span -> unit -> string option
66
end
77

88
val enter_manual_span :
@@ -11,4 +11,4 @@ val enter_manual_span :
1111
__LINE__:int ->
1212
?data:(unit -> (string * Otrace.user_data) list) ->
1313
string ->
14-
Trace_core.explicit_span
14+
Trace_core.span

possibly_otel.real.ml

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,18 @@
11
open Opentelemetry
22

3-
let (let*) o f = Option.map f o
4-
53
module Traceparent = struct
64
let name = Trace_context.Traceparent.name
75

86
let get_ambient ?explicit_span () =
9-
let* Scope.{ trace_id; span_id; _ } = Scope.get_ambient_scope () in
10-
let span_id = match explicit_span with
11-
| Some {Trace_core.span; _} -> Opentelemetry_trace.Internal.otel_of_otrace span
12-
| None -> span_id
13-
in
14-
Trace_context.Traceparent.to_value ~trace_id ~parent_id:span_id ()
7+
match explicit_span, Trace_core.current_span () with
8+
| Some (Opentelemetry_trace.Extensions.Span_otel span), _
9+
| _, Some (Opentelemetry_trace.Extensions.Span_otel span) ->
10+
let ctx = Trace_context.Traceparent.to_value
11+
~trace_id:(Span.trace_id span) ~parent_id:(Span.id span) () in
12+
Some ctx
13+
| _ -> None
1514
end
1615

1716
let enter_manual_span ~__FUNCTION__ ~__FILE__ ~__LINE__ ?data name =
18-
match Scope.get_ambient_scope () with
19-
| None ->
20-
Trace_core.enter_manual_toplevel_span ~__FUNCTION__ ~__FILE__ ~__LINE__ ?data name
21-
| Some Scope.{ span_id; _ } ->
22-
let otrace_espan = Trace_core.{
23-
span = Opentelemetry_trace.Internal.otrace_of_otel span_id;
24-
meta = Trace_core.Meta_map.empty
25-
} in
26-
Trace_core.enter_manual_sub_span ~parent:otrace_espan ~__FUNCTION__ ~__FILE__ ~__LINE__ ?data name
17+
let parent = Trace_core.current_span () in
18+
Trace_core.enter_span ~parent ~__FUNCTION__ ~__FILE__ ~__LINE__ ?data name

possibly_otel.stub.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ module Traceparent = struct
55
end
66

77

8-
let enter_manual_span ~__FUNCTION__ ~__FILE__ ~__LINE__ ?data name =
9-
Trace_core.enter_manual_toplevel_span ~__FUNCTION__ ~__FILE__ ~__LINE__ ?data name
8+
let[@inline] enter_manual_span ~__FUNCTION__ ~__FILE__ ~__LINE__ ?data name =
9+
Trace_core.enter_span ~__FUNCTION__ ~__FILE__ ~__LINE__ ?data name

web.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,9 +362,9 @@ module Http (IO : IO_TYPE) (Curl_IO : CURL with type 'a t = 'a IO.t) : HTTP with
362362
| Some v -> ("http.response.header.x-clickhouse-summary", `String v) :: data in
363363
let data = match !resp_content_encoding with None -> data
364364
| Some v -> ("http.response.header.content-encoding", `String v) :: data in
365-
Trace_core.add_data_to_manual_span explicit_span data
365+
Trace_core.add_data_to_span explicit_span data
366366
);
367-
Trace_core.exit_manual_span explicit_span;
367+
Trace_core.exit_span explicit_span;
368368
return ()
369369
) in
370370

0 commit comments

Comments
 (0)