mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-08 03:47:59 -04:00
Remove cruft from old testing method
Also document the signal reporter executable
This commit is contained in:
parent
5bf8eea5f1
commit
16daccb6df
4 changed files with 20 additions and 43 deletions
|
|
@ -32,4 +32,7 @@
|
|||
(deps %{bin:emit1_cohttp})
|
||||
(libraries clients_e2e_lib alcotest opentelemetry opentelemetry.client))
|
||||
|
||||
; TODO : Add tests for ocurl's emit1
|
||||
(executable
|
||||
(name signal_reporter_server)
|
||||
(modules signal_reporter_server)
|
||||
(libraries signal_gatherer))
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
let () =
|
||||
let program_to_test = Sys.argv |> Array.to_list |> List.tl in
|
||||
Signal_gatherer.run ~program_to_test ()
|
||||
|
|
@ -97,40 +97,6 @@ let collect_traces ~port program_to_test push_signals () =
|
|||
(* Let the tester know all the signals have be sent *)
|
||||
Lwt.return (push_signals None)
|
||||
|
||||
let normalize_scope_span : Proto.Trace.scope_spans -> Proto.Trace.scope_spans =
|
||||
function
|
||||
| scope_span ->
|
||||
{
|
||||
scope_span with
|
||||
spans =
|
||||
scope_span.spans
|
||||
|> List.map (fun (span : Proto.Trace.span) ->
|
||||
{
|
||||
span with
|
||||
start_time_unix_nano = -1L;
|
||||
end_time_unix_nano = -1L;
|
||||
});
|
||||
}
|
||||
|
||||
let normalize_signal : Signal.t -> Signal.t = function
|
||||
| Traces ts ->
|
||||
Traces
|
||||
(ts
|
||||
|> List.map (fun (trace : Proto.Trace.resource_spans) ->
|
||||
{
|
||||
trace with
|
||||
scope_spans = trace.scope_spans |> List.map normalize_scope_span;
|
||||
}))
|
||||
| x -> x
|
||||
|
||||
(* normalize trace output by redacting non-deterministic values from output *)
|
||||
let normalize =
|
||||
let re =
|
||||
Str.regexp
|
||||
{|\(start_time_unix_nano\|time_unix_nano\|end_time_unix_nano\|value\) = \([0-9]*\|As_int([0-9]*)\|As_double([0-9]*\.)\);|}
|
||||
in
|
||||
fun s -> Str.global_replace re {|\1 = <redacted>;|} s
|
||||
|
||||
let default_port =
|
||||
String.split_on_char ':' Client.Config.default_url |> function
|
||||
(* Extracting the port from 'http://foo:<port>' *)
|
||||
|
|
@ -144,8 +110,15 @@ let gather_signals ?(port = default_port) program_to_test =
|
|||
let* () = collect_traces ~port program_to_test push () in
|
||||
Lwt_stream.to_list stream
|
||||
|
||||
let run ?(port = default_port) ~program_to_test () =
|
||||
gather_signals ~port program_to_test
|
||||
|> List.map (fun s -> s |> Format.asprintf "%a" Signal.Pp.pp |> normalize)
|
||||
|> List.stable_sort String.compare (* Produce a deterministic order *)
|
||||
|> List.iter print_string
|
||||
(* Just run the server, and print the signals gathered. *)
|
||||
let run ?(port = default_port) () =
|
||||
Lwt_main.run
|
||||
@@
|
||||
let stream, push = Lwt_stream.create () in
|
||||
Lwt.join
|
||||
[
|
||||
Server.run port push;
|
||||
Lwt_stream.iter_s
|
||||
(fun s -> Format.asprintf "%a" Signal.Pp.pp s |> Lwt_io.printl)
|
||||
stream;
|
||||
]
|
||||
|
|
|
|||
4
tests/client_e2e/signal_reporter_server.ml
Normal file
4
tests/client_e2e/signal_reporter_server.ml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
(** Runs a signal gatherer server, and prints out every batch of signals
|
||||
received to stdout. This can be used to monitor the signals sent by an
|
||||
application, e.g., the test executables defined in /tests/bin/emit1*.ml *)
|
||||
let () = Signal_gatherer.run ()
|
||||
Loading…
Add table
Reference in a new issue