mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-09 04:17:56 -04:00
Merge pull request #31 from ELLIOTTCABLE/try-lwt-over-lwt-catch
Use try%lwt over Lwt.catch
This commit is contained in:
commit
67f4f5b9cc
7 changed files with 20 additions and 16 deletions
|
|
@ -32,7 +32,8 @@
|
||||||
(opentelemetry (= :version))
|
(opentelemetry (= :version))
|
||||||
(cohttp-lwt-unix :with-test)
|
(cohttp-lwt-unix :with-test)
|
||||||
(odoc :with-doc)
|
(odoc :with-doc)
|
||||||
(lwt (>= "5.3")))
|
(lwt (>= "5.3"))
|
||||||
|
lwt_ppx)
|
||||||
(tags
|
(tags
|
||||||
(instrumentation tracing opentelemetry datadog lwt)))
|
(instrumentation tracing opentelemetry datadog lwt)))
|
||||||
|
|
||||||
|
|
@ -69,7 +70,7 @@
|
||||||
(pbrt (>= 2.2))
|
(pbrt (>= 2.2))
|
||||||
(odoc :with-doc)
|
(odoc :with-doc)
|
||||||
(lwt (>= "5.3"))
|
(lwt (>= "5.3"))
|
||||||
(lwt_ppx :with-test)
|
lwt_ppx
|
||||||
cohttp-lwt
|
cohttp-lwt
|
||||||
cohttp-lwt-unix)
|
cohttp-lwt-unix)
|
||||||
(synopsis "Collector client for opentelemetry, using cohttp + lwt"))
|
(synopsis "Collector client for opentelemetry, using cohttp + lwt"))
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ depends: [
|
||||||
"pbrt" {>= "2.2"}
|
"pbrt" {>= "2.2"}
|
||||||
"odoc" {with-doc}
|
"odoc" {with-doc}
|
||||||
"lwt" {>= "5.3"}
|
"lwt" {>= "5.3"}
|
||||||
"lwt_ppx" {with-test}
|
"lwt_ppx"
|
||||||
"cohttp-lwt"
|
"cohttp-lwt"
|
||||||
"cohttp-lwt-unix"
|
"cohttp-lwt-unix"
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ depends: [
|
||||||
"cohttp-lwt-unix" {with-test}
|
"cohttp-lwt-unix" {with-test}
|
||||||
"odoc" {with-doc}
|
"odoc" {with-doc}
|
||||||
"lwt" {>= "5.3"}
|
"lwt" {>= "5.3"}
|
||||||
|
"lwt_ppx"
|
||||||
]
|
]
|
||||||
build: [
|
build: [
|
||||||
["dune" "subst"] {dev}
|
["dune" "subst"] {dev}
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
(fun e -> Lwt.return @@ Error e)
|
with 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
|
||||||
(fun e ->
|
with 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