mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-09 20:33:36 -04:00
(style lwt ppx dep) Use try%lwt over Lwt.catch
This commit is contained in:
parent
de0d5ea197
commit
3e46458499
5 changed files with 15 additions and 14 deletions
|
|
@ -1,4 +1,3 @@
|
||||||
open Lwt.Syntax
|
|
||||||
module Atomic = Opentelemetry_atomic.Atomic
|
module Atomic = Opentelemetry_atomic.Atomic
|
||||||
|
|
||||||
let[@inline] ( let@ ) f x = f x
|
let[@inline] ( let@ ) f x = f x
|
||||||
|
|
|
||||||
|
|
@ -2,5 +2,6 @@
|
||||||
(name opentelemetry_client_cohttp_lwt)
|
(name opentelemetry_client_cohttp_lwt)
|
||||||
(public_name opentelemetry-client-cohttp-lwt)
|
(public_name opentelemetry-client-cohttp-lwt)
|
||||||
(synopsis "Opentelemetry collector using cohttp+lwt+unix")
|
(synopsis "Opentelemetry collector using cohttp+lwt+unix")
|
||||||
|
(preprocess (pps lwt_ppx))
|
||||||
(libraries opentelemetry lwt cohttp-lwt cohttp-lwt-unix pbrt mtime
|
(libraries opentelemetry lwt cohttp-lwt cohttp-lwt-unix pbrt mtime
|
||||||
mtime.clock.os))
|
mtime.clock.os))
|
||||||
|
|
|
||||||
|
|
@ -105,11 +105,11 @@ end = struct
|
||||||
let body = Cohttp_lwt.Body.of_string bod in
|
let body = Cohttp_lwt.Body.of_string bod in
|
||||||
|
|
||||||
let* r =
|
let* r =
|
||||||
Lwt.catch
|
try%lwt
|
||||||
(fun () ->
|
let+ r = Httpc.post ~headers ~body uri in
|
||||||
let+ r = Httpc.post ~headers ~body uri in
|
Ok r
|
||||||
Ok r)
|
with e ->
|
||||||
(fun e -> Lwt.return @@ Error e)
|
Lwt.return @@ Error e
|
||||||
in
|
in
|
||||||
match r with
|
match r with
|
||||||
| Error e ->
|
| Error e ->
|
||||||
|
|
|
||||||
|
|
@ -2,4 +2,6 @@
|
||||||
(name opentelemetry_lwt)
|
(name opentelemetry_lwt)
|
||||||
(public_name opentelemetry-lwt)
|
(public_name opentelemetry-lwt)
|
||||||
(synopsis "Lwt frontend for opentelemetry")
|
(synopsis "Lwt frontend for opentelemetry")
|
||||||
|
(preprocess
|
||||||
|
(pps lwt_ppx))
|
||||||
(libraries lwt opentelemetry))
|
(libraries lwt opentelemetry))
|
||||||
|
|
|
||||||
|
|
@ -47,14 +47,13 @@ module Trace = struct
|
||||||
in
|
in
|
||||||
emit ?service_name [ span ]
|
emit ?service_name [ span ]
|
||||||
in
|
in
|
||||||
Lwt.catch
|
try%lwt
|
||||||
(fun () ->
|
let* x = f scope in
|
||||||
let* x = f scope in
|
let () = finally (Ok ()) in
|
||||||
let () = finally (Ok ()) in
|
Lwt.return x
|
||||||
Lwt.return x)
|
with e ->
|
||||||
(fun e ->
|
let () = finally (Error (Printexc.to_string e)) in
|
||||||
let () = finally (Error (Printexc.to_string e)) in
|
Lwt.fail e
|
||||||
Lwt.fail e)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
module Metrics = struct
|
module Metrics = struct
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue