mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-09 12:23:32 -04:00
test: update cohttp client test to use cohttp backend as well
This commit is contained in:
parent
c3f5b36e36
commit
9fbe9d2df7
2 changed files with 13 additions and 8 deletions
|
|
@ -13,7 +13,8 @@ let mk_client ~scope =
|
||||||
Opentelemetry_cohttp_lwt.client ~scope (module Cohttp_lwt_unix.Client)
|
Opentelemetry_cohttp_lwt.client ~scope (module Cohttp_lwt_unix.Client)
|
||||||
|
|
||||||
let run () =
|
let run () =
|
||||||
Printf.printf "collector is on %S\n%!" (Opentelemetry_client_ocurl.get_url ());
|
Printf.printf "collector is on %S\n%!"
|
||||||
|
(Opentelemetry_client_cohttp_lwt.get_url ());
|
||||||
let open Lwt.Syntax in
|
let open Lwt.Syntax in
|
||||||
let rec go () =
|
let rec go () =
|
||||||
let@ scope =
|
let@ scope =
|
||||||
|
|
@ -35,13 +36,11 @@ let () =
|
||||||
T.Globals.service_namespace := Some "ocaml-otel.test";
|
T.Globals.service_namespace := Some "ocaml-otel.test";
|
||||||
|
|
||||||
let debug = ref false in
|
let debug = ref false in
|
||||||
let thread = ref true in
|
|
||||||
let batch_traces = ref 400 in
|
let batch_traces = ref 400 in
|
||||||
let batch_metrics = ref 3 in
|
let batch_metrics = ref 3 in
|
||||||
let opts =
|
let opts =
|
||||||
[
|
[
|
||||||
"--debug", Arg.Bool (( := ) debug), " enable debug output";
|
"--debug", Arg.Bool (( := ) debug), " enable debug output";
|
||||||
"--thread", Arg.Bool (( := ) thread), " use a background thread";
|
|
||||||
"--batch-traces", Arg.Int (( := ) batch_traces), " size of traces batch";
|
"--batch-traces", Arg.Int (( := ) batch_traces), " size of traces batch";
|
||||||
( "--batch-metrics",
|
( "--batch-metrics",
|
||||||
Arg.Int (( := ) batch_metrics),
|
Arg.Int (( := ) batch_metrics),
|
||||||
|
|
@ -61,17 +60,17 @@ let () =
|
||||||
None
|
None
|
||||||
in
|
in
|
||||||
let config =
|
let config =
|
||||||
Opentelemetry_client_ocurl.Config.make ~debug:!debug
|
Opentelemetry_client_cohttp_lwt.Config.make ~debug:!debug
|
||||||
~batch_traces:(some_if_nzero batch_traces)
|
~batch_traces:(some_if_nzero batch_traces)
|
||||||
~batch_metrics:(some_if_nzero batch_metrics)
|
~batch_metrics:(some_if_nzero batch_metrics)
|
||||||
~thread:!thread ()
|
()
|
||||||
in
|
in
|
||||||
Format.printf "@[<2>sleep outer: %.3fs,@ sleep inner: %.3fs,@ config: %a@]@."
|
Format.printf "@[<2>sleep outer: %.3fs,@ sleep inner: %.3fs,@ config: %a@]@."
|
||||||
!sleep_outer !sleep_inner Opentelemetry_client_ocurl.Config.pp config;
|
!sleep_outer !sleep_inner Opentelemetry_client_cohttp_lwt.Config.pp config;
|
||||||
|
|
||||||
Format.printf
|
Format.printf
|
||||||
"Check HTTP requests at \
|
"Check HTTP requests at \
|
||||||
https://requestbin.com/r/enec1hql02hz/26qShWryt5vJc1JfrOwalhr5vQt@.";
|
https://requestbin.com/r/enec1hql02hz/26qShWryt5vJc1JfrOwalhr5vQt@.";
|
||||||
|
|
||||||
Opentelemetry_client_ocurl.with_setup ~config () (fun () ->
|
Opentelemetry_client_cohttp_lwt.with_setup ~config () (fun () ->
|
||||||
Lwt_main.run (run ()))
|
Lwt_main.run (run ()))
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,14 @@
|
||||||
(modules emit1)
|
(modules emit1)
|
||||||
(libraries unix opentelemetry opentelemetry-client-ocurl))
|
(libraries unix opentelemetry opentelemetry-client-ocurl))
|
||||||
|
|
||||||
|
(executable
|
||||||
|
(name emit1_cohttp)
|
||||||
|
(modules emit1_cohttp)
|
||||||
|
(preprocess (pps lwt_ppx))
|
||||||
|
(libraries unix opentelemetry opentelemetry-lwt opentelemetry-client-cohttp-lwt lwt.unix))
|
||||||
|
|
||||||
(executable
|
(executable
|
||||||
(name cohttp_client)
|
(name cohttp_client)
|
||||||
(modules cohttp_client)
|
(modules cohttp_client)
|
||||||
(libraries cohttp-lwt-unix opentelemetry opentelemetry-client-ocurl
|
(libraries cohttp-lwt-unix opentelemetry opentelemetry-client-cohttp-lwt
|
||||||
opentelemetry-cohttp-lwt))
|
opentelemetry-cohttp-lwt))
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue