mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-08 03:47:59 -04:00
port urls test + rename
This commit is contained in:
parent
3daa0d8762
commit
8aafa45896
8 changed files with 165 additions and 12 deletions
|
|
@ -1,4 +1,4 @@
|
|||
(tests
|
||||
(names test_get_url)
|
||||
(names test_urls)
|
||||
(package opentelemetry-client-cohttp-lwt)
|
||||
(libraries opentelemetry opentelemetry-client-cohttp-lwt))
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
cohttp url = http://localhost:3000
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
let url = "http://localhost:3000"
|
||||
|
||||
let cohttp () =
|
||||
let config = Opentelemetry_client_cohttp_lwt.Config.make ~url () in
|
||||
Opentelemetry_client_cohttp_lwt.with_setup ~config () @@ fun () ->
|
||||
print_endline @@ Printf.sprintf "cohttp url = %s" url
|
||||
|
||||
let () = cohttp ()
|
||||
97
tests/cohttp/test_urls.ml
Normal file
97
tests/cohttp/test_urls.ml
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
open Opentelemetry_client_cohttp_lwt
|
||||
|
||||
let test_urls ~name config =
|
||||
Printf.printf "--- %s ---\n" name;
|
||||
Printf.printf "url_traces = %s\n" config.Config.url_traces;
|
||||
Printf.printf "url_metrics = %s\n" config.Config.url_metrics;
|
||||
Printf.printf "url_logs = %s\n" config.Config.url_logs;
|
||||
print_endline "------\n"
|
||||
|
||||
let default_url () =
|
||||
let config = Config.make () in
|
||||
test_urls ~name:"default_url" config
|
||||
|
||||
let base_url_from_config () =
|
||||
let config = Config.make ~url:"http://localhost:3000" () in
|
||||
test_urls ~name:"base_url_from_config" config
|
||||
|
||||
let base_url_from_env () =
|
||||
Unix.putenv "OTEL_EXPORTER_OTLP_ENDPOINT" "http://localhost:5000";
|
||||
let config = Config.make () in
|
||||
test_urls ~name:"base_url_from_env" config
|
||||
|
||||
let base_url_from_both_config_and_env () =
|
||||
(* url from config should take precedence *)
|
||||
Unix.putenv "OTEL_EXPORTER_OTLP_ENDPOINT" "http://localhost:5000";
|
||||
let config = Config.make ~url:"http://localhost:3000" () in
|
||||
test_urls ~name:"base_url_from_both_config_and_env" config
|
||||
|
||||
let override_trace_url_from_config () =
|
||||
let config =
|
||||
Config.make ~url:"http://localhost:3000"
|
||||
~url_traces:"http://localhost:3001/send/traces" ()
|
||||
in
|
||||
test_urls ~name:"override_trace_url_from_config" config
|
||||
|
||||
let override_trace_url_from_env () =
|
||||
Unix.putenv "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT"
|
||||
"http://localhost:3001/send/traces";
|
||||
let config = Config.make () in
|
||||
test_urls ~name:"override_trace_url_from_config" config
|
||||
|
||||
let override_trace_url_from_both_config_and_env () =
|
||||
Unix.putenv "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT"
|
||||
"http://localhost:3001/send/traces/env";
|
||||
let config =
|
||||
Config.make ~url_traces:"http://localhost:3001/send/traces/config" ()
|
||||
in
|
||||
test_urls ~name:"override_trace_url_from_both_config_and_env" config
|
||||
|
||||
let set_all_in_config () =
|
||||
let config =
|
||||
Config.make ~url_traces:"http://localhost:3001/send/traces"
|
||||
~url_metrics:"http://localhost:3002/send/metrics"
|
||||
~url_logs:"http://localhost:3003/send/logs" ()
|
||||
in
|
||||
test_urls ~name:"set_all_in_config" config
|
||||
|
||||
let set_all_in_env () =
|
||||
Unix.putenv "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT"
|
||||
"http://localhost:3001/send/traces";
|
||||
Unix.putenv "OTEL_EXPORTER_OTLP_METRICS_ENDPOINT"
|
||||
"http://localhost:3002/send/metrics";
|
||||
Unix.putenv "OTEL_EXPORTER_OTLP_LOGS_ENDPOINT"
|
||||
"http://localhost:3003/send/logs";
|
||||
let config = Config.make () in
|
||||
test_urls ~name:"set_all_in_config" config
|
||||
|
||||
let remove_trailing_slash_config () =
|
||||
let config = Config.make ~url:"http://localhost:3000/" () in
|
||||
test_urls ~name:"remove_trailing_slash_config" config
|
||||
|
||||
let remove_trailing_slash_env () =
|
||||
Unix.putenv "OTEL_EXPORTER_OTLP_ENDPOINT" "http://localhost:3000/";
|
||||
let config = Config.make () in
|
||||
test_urls ~name:"remove_trailing_slash_config" config
|
||||
|
||||
let () = default_url ()
|
||||
|
||||
let () = base_url_from_config ()
|
||||
|
||||
let () = base_url_from_env ()
|
||||
|
||||
let () = base_url_from_both_config_and_env ()
|
||||
|
||||
let () = override_trace_url_from_config ()
|
||||
|
||||
let () = override_trace_url_from_env ()
|
||||
|
||||
let () = override_trace_url_from_both_config_and_env ()
|
||||
|
||||
let () = set_all_in_config ()
|
||||
|
||||
let () = set_all_in_env ()
|
||||
|
||||
let () = remove_trailing_slash_config ()
|
||||
|
||||
let () = remove_trailing_slash_env ()
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
|
||||
(tests
|
||||
(names test_get_url)
|
||||
(names test_urls)
|
||||
(package opentelemetry-client-ocurl)
|
||||
(libraries opentelemetry opentelemetry-client-ocurl))
|
||||
|
|
|
|||
66
tests/ocurl/test_urls.expected
Normal file
66
tests/ocurl/test_urls.expected
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
--- default_url ---
|
||||
url_traces = http://localhost:4318/v1/traces
|
||||
url_metrics = http://localhost:4318/v1/metrics
|
||||
url_logs = http://localhost:4318/v1/logs
|
||||
------
|
||||
|
||||
--- base_url_from_config ---
|
||||
url_traces = http://localhost:3000/v1/traces
|
||||
url_metrics = http://localhost:3000/v1/metrics
|
||||
url_logs = http://localhost:3000/v1/logs
|
||||
------
|
||||
|
||||
--- base_url_from_env ---
|
||||
url_traces = http://localhost:5000/v1/traces
|
||||
url_metrics = http://localhost:5000/v1/metrics
|
||||
url_logs = http://localhost:5000/v1/logs
|
||||
------
|
||||
|
||||
--- base_url_from_both_config_and_env ---
|
||||
url_traces = http://localhost:3000/v1/traces
|
||||
url_metrics = http://localhost:3000/v1/metrics
|
||||
url_logs = http://localhost:3000/v1/logs
|
||||
------
|
||||
|
||||
--- override_trace_url_from_config ---
|
||||
url_traces = http://localhost:3001/send/traces
|
||||
url_metrics = http://localhost:3000/v1/metrics
|
||||
url_logs = http://localhost:3000/v1/logs
|
||||
------
|
||||
|
||||
--- override_trace_url_from_config ---
|
||||
url_traces = http://localhost:3001/send/traces
|
||||
url_metrics = http://localhost:5000/v1/metrics
|
||||
url_logs = http://localhost:5000/v1/logs
|
||||
------
|
||||
|
||||
--- override_trace_url_from_both_config_and_env ---
|
||||
url_traces = http://localhost:3001/send/traces/config
|
||||
url_metrics = http://localhost:5000/v1/metrics
|
||||
url_logs = http://localhost:5000/v1/logs
|
||||
------
|
||||
|
||||
--- set_all_in_config ---
|
||||
url_traces = http://localhost:3001/send/traces
|
||||
url_metrics = http://localhost:3002/send/metrics
|
||||
url_logs = http://localhost:3003/send/logs
|
||||
------
|
||||
|
||||
--- set_all_in_config ---
|
||||
url_traces = http://localhost:3001/send/traces
|
||||
url_metrics = http://localhost:3002/send/metrics
|
||||
url_logs = http://localhost:3003/send/logs
|
||||
------
|
||||
|
||||
--- remove_trailing_slash_config ---
|
||||
url_traces = http://localhost:3001/send/traces
|
||||
url_metrics = http://localhost:3002/send/metrics
|
||||
url_logs = http://localhost:3003/send/logs
|
||||
------
|
||||
|
||||
--- remove_trailing_slash_config ---
|
||||
url_traces = http://localhost:3001/send/traces
|
||||
url_metrics = http://localhost:3002/send/metrics
|
||||
url_logs = http://localhost:3003/send/logs
|
||||
------
|
||||
|
||||
Loading…
Add table
Reference in a new issue