Skip to content

Commit

Permalink
do not use deprecated functions
Browse files Browse the repository at this point in the history
  • Loading branch information
tatchi committed Oct 18, 2024
1 parent 6a1f1eb commit 1a78802
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/integrations/cohttp/opentelemetry_cohttp_lwt.ml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ end = struct
let open Lwt.Syntax in
let req = set_trace_context scope req in
let* res, body = callback conn req body in
Otel.Trace.add_attrs scope (fun () -> attrs_of_response res);
Otel.Scope.add_attrs scope (fun () -> attrs_of_response res);
Lwt.return (res, body))

let with_ ?trace_state ?service_name ?attrs
Expand Down Expand Up @@ -190,7 +190,7 @@ let client ?(scope : Otel.Scope.t option) (module C : Cohttp_lwt.S.Client) =
~attrs (fun scope ->
let headers = add_traceparent scope headers in
let* res, body = C.call ?ctx ~headers ?body ?chunked meth uri in
Otel.Trace.add_attrs scope (fun () ->
Otel.Scope.add_attrs scope (fun () ->
let code = Response.status res in
let code = Code.code_of_status code in
[ "http.status_code", `Int code ]);
Expand Down Expand Up @@ -220,7 +220,7 @@ let client ?(scope : Otel.Scope.t option) (module C : Cohttp_lwt.S.Client) =
~attrs (fun scope ->
let headers = add_traceparent scope headers in
let* res, body = C.post_form ?ctx ~headers ~params uri in
Otel.Trace.add_attrs scope (fun () ->
Otel.Scope.add_attrs scope (fun () ->
let code = Response.status res in
let code = Code.code_of_status code in
[ "http.status_code", `Int code ]);
Expand Down
3 changes: 2 additions & 1 deletion tests/bin/emit1.ml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ let run_job () =
if j = 4 && !i mod 13 = 0 then failwith "oh no";

(* simulate a failure *)
T.Trace.add_event scope (fun () -> T.Event.make "done with alloc")
Opentelemetry.Scope.add_event scope (fun () ->
T.Event.make "done with alloc")
with Failure _ -> ()
done
done
Expand Down
3 changes: 2 additions & 1 deletion tests/bin/emit1_cohttp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ let run_job () : unit Lwt.t =
if j = 4 && !i mod 13 = 0 then failwith "oh no";

(* simulate a failure *)
T.Trace.add_event scope (fun () -> T.Event.make "done with alloc");
Opentelemetry.Scope.add_event scope (fun () ->
T.Event.make "done with alloc");
Lwt.return ()
with Failure _ -> Lwt.return ()
done
Expand Down

0 comments on commit 1a78802

Please sign in to comment.