diff --git a/tests/client_e2e/signal_gatherer.ml b/tests/client_e2e/signal_gatherer.ml index ac4e6c26..41e98eef 100644 --- a/tests/client_e2e/signal_gatherer.ml +++ b/tests/client_e2e/signal_gatherer.ml @@ -2,7 +2,6 @@ module Client = Opentelemetry_client module Signal = Client.Signal -module Proto = Opentelemetry.Proto open Lwt.Syntax (* Server to collect telemetry data *) @@ -18,11 +17,6 @@ module Server = struct (* in *) Lwt.return () - let metrics req data = - let metrics = Signal.Decode.metrics data in - let+ () = dbg_request "metrics" req Signal.Pp.metrics metrics in - Signal.Metrics metrics - let handler push_signal _socket (request : Http.Request.t) (body : Cohttp_lwt.Body.t) = let* data = Cohttp_lwt.Body.to_string body in @@ -89,14 +83,6 @@ module Tested_program = struct validate_exit result end -let collect_traces ~port program_to_test push_signals () = - let* () = - Lwt.pick - [ Server.run port push_signals; Tested_program.run program_to_test ] - in - (* Let the tester know all the signals have be sent *) - Lwt.return (push_signals None) - let default_port = String.split_on_char ':' Client.Config.default_url |> function (* Extracting the port from 'http://foo:' *) @@ -107,7 +93,11 @@ let gather_signals ?(port = default_port) program_to_test = Lwt_main.run @@ let stream, push = Lwt_stream.create () in - let* () = collect_traces ~port program_to_test push () in + let* () = + Lwt.pick [ Server.run port push; Tested_program.run program_to_test ] + in + (* Close out the stream *) + push None; Lwt_stream.to_list stream (* Just run the server, and print the signals gathered. *) diff --git a/tests/client_e2e/signal_gatherer.mli b/tests/client_e2e/signal_gatherer.mli new file mode 100644 index 00000000..b948d059 --- /dev/null +++ b/tests/client_e2e/signal_gatherer.mli @@ -0,0 +1,21 @@ +(** A test utility for running a signal emitting executable alongside a minimal + server that can receive the signals make them available for inspection. *) + +val gather_signals : + ?port:int -> string list -> Opentelemetry_client.Signal.t list +(** [gather_signals program_to_test] is a list of all the signals emitted by the + [program_to_test], which the server was able to record. This function + assumes that the program to test will be sending its signals to the + localhost on [port]. + + @param port + the port where signals will be received. Default is port set in + {!Opentelemetry_client.Config.default_url}. *) + +val run : ?port:int -> unit -> unit +(** [run ()] runs a signal gathering server and prints all batches of signals + received to stdout. + + @param port + the port where signals will be received. Default is port set in + {!Opentelemetry_client.Config.default_url}. *)