diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ff924cff..47f93677 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -40,12 +40,12 @@ jobs: - run: opam exec -- dune build @install -p opentelemetry,opentelemetry-lwt,opentelemetry-client-ocurl,opentelemetry-cohttp-lwt,opentelemetry-client-cohttp-lwt - - run: opam pin ocaml-protoc 2.3 -y + - run: opam pin ocaml-protoc 2.4 -y - run: opam exec -- dune build @lint # check that nothing changed - - run: git diff --quiet --exit-code + - run: git diff --exit-code - run: opam exec -- dune build @runtest if: ${{ matrix.os == 'ubuntu-latest' }} diff --git a/dune-project b/dune-project index c7d242e6..3938038b 100644 --- a/dune-project +++ b/dune-project @@ -30,14 +30,6 @@ ambient-context (odoc :with-doc) (alcotest :with-test) - (opentelemetry-client-cohttp-lwt - (and - :with-test - (= :version))) - (opentelemetry-client-ocurl - (and - :with-test - (= :version))) (pbrt (>= 2.3)) (ocaml-lsp-server :with-dev-setup) @@ -70,15 +62,7 @@ (>= "5.3")) (lwt_ppx (>= "2.0")) - (alcotest :with-test) - (opentelemetry-client-cohttp-lwt - (and - :with-test - (= :version))) - (opentelemetry-client-ocurl - (and - :with-test - (= :version)))) + (alcotest :with-test)) (tags (instrumentation tracing opentelemetry datadog lwt))) @@ -99,11 +83,7 @@ (ezcurl (>= 0.2.3)) ocurl - (alcotest :with-test) - (opentelemetry-client-cohttp-lwt - (and - :with-test - (= :version)))) + (alcotest :with-test)) (synopsis "Collector client for opentelemetry, using http + ezcurl")) (package @@ -120,15 +100,7 @@ (>= "5.3")) (cohttp-lwt (>= "4.0.0")) - (alcotest :with-test) - (opentelemetry-client-cohttp-lwt - (and - :with-test - (= :version))) - (opentelemetry-client-ocurl - (and - :with-test - (= :version)))) + (alcotest :with-test)) (synopsis "Opentelemetry tracing for Cohttp HTTP servers")) (package @@ -150,9 +122,5 @@ (>= "2.0")) cohttp-lwt cohttp-lwt-unix - (alcotest :with-test) - (opentelemetry-client-ocurl - (and - :with-test - (= :version)))) + (alcotest :with-test)) (synopsis "Collector client for opentelemetry, using cohttp + lwt")) diff --git a/opentelemetry-client-cohttp-lwt.opam b/opentelemetry-client-cohttp-lwt.opam index 93b11939..8ded95ec 100644 --- a/opentelemetry-client-cohttp-lwt.opam +++ b/opentelemetry-client-cohttp-lwt.opam @@ -23,7 +23,6 @@ depends: [ "cohttp-lwt" "cohttp-lwt-unix" "alcotest" {with-test} - "opentelemetry-client-ocurl" {with-test & = version} ] build: [ ["dune" "subst"] {dev} diff --git a/opentelemetry-client-ocurl.opam b/opentelemetry-client-ocurl.opam index 0a32fc67..21d01814 100644 --- a/opentelemetry-client-ocurl.opam +++ b/opentelemetry-client-ocurl.opam @@ -21,7 +21,6 @@ depends: [ "ezcurl" {>= "0.2.3"} "ocurl" "alcotest" {with-test} - "opentelemetry-client-cohttp-lwt" {with-test & = version} ] build: [ ["dune" "subst"] {dev} diff --git a/opentelemetry-cohttp-lwt.opam b/opentelemetry-cohttp-lwt.opam index 94ec245d..20c5321a 100644 --- a/opentelemetry-cohttp-lwt.opam +++ b/opentelemetry-cohttp-lwt.opam @@ -20,8 +20,6 @@ depends: [ "lwt" {>= "5.3"} "cohttp-lwt" {>= "4.0.0"} "alcotest" {with-test} - "opentelemetry-client-cohttp-lwt" {with-test & = version} - "opentelemetry-client-ocurl" {with-test & = version} ] build: [ ["dune" "subst"] {dev} diff --git a/opentelemetry-lwt.opam b/opentelemetry-lwt.opam index ff13e0d6..a03196a2 100644 --- a/opentelemetry-lwt.opam +++ b/opentelemetry-lwt.opam @@ -22,8 +22,6 @@ depends: [ "lwt" {>= "5.3"} "lwt_ppx" {>= "2.0"} "alcotest" {with-test} - "opentelemetry-client-cohttp-lwt" {with-test & = version} - "opentelemetry-client-ocurl" {with-test & = version} ] build: [ ["dune" "subst"] {dev} diff --git a/opentelemetry.opam b/opentelemetry.opam index cfc11eeb..cf4a98f3 100644 --- a/opentelemetry.opam +++ b/opentelemetry.opam @@ -19,8 +19,6 @@ depends: [ "ambient-context" "odoc" {with-doc} "alcotest" {with-test} - "opentelemetry-client-cohttp-lwt" {with-test & = version} - "opentelemetry-client-ocurl" {with-test & = version} "pbrt" {>= "2.3"} "ocaml-lsp-server" {with-dev-setup} "ocamlformat" {with-dev-setup & >= "0.24" & < "0.25"} diff --git a/src/core/dune b/src/core/dune new file mode 100644 index 00000000..f3671f64 --- /dev/null +++ b/src/core/dune @@ -0,0 +1,7 @@ +(library + (name opentelemetry) + (synopsis "API for opentelemetry instrumentation") + (flags :standard -warn-error -a+8) + (libraries opentelemetry.proto ambient-context ptime ptime.clock.os pbrt threads + opentelemetry.atomic) + (public_name opentelemetry)) diff --git a/src/lock.ml b/src/core/lock.ml similarity index 100% rename from src/lock.ml rename to src/core/lock.ml diff --git a/src/lock.mli b/src/core/lock.mli similarity index 100% rename from src/lock.mli rename to src/core/lock.mli diff --git a/src/opentelemetry.ml b/src/core/opentelemetry.ml similarity index 99% rename from src/opentelemetry.ml rename to src/core/opentelemetry.ml index 66ca27d2..983ca128 100644 --- a/src/opentelemetry.ml +++ b/src/core/opentelemetry.ml @@ -19,6 +19,8 @@ end This is mostly useful internally. Users should not need to touch it. *) module Proto = struct + open Opentelemetry_proto + module Common = struct include Common_types include Common_pp @@ -887,6 +889,7 @@ end See {{: https://opentelemetry.io/docs/reference/specification/overview/#metric-signal} the spec} *) module Metrics = struct + open Opentelemetry_proto open Metrics_types type t = Metrics_types.metric @@ -989,6 +992,7 @@ end See {{: https://opentelemetry.io/docs/reference/specification/overview/#log-signal} the spec} *) module Logs = struct + open Opentelemetry_proto open Logs_types type t = log_record diff --git a/src/rand_bytes.ml b/src/core/rand_bytes.ml similarity index 100% rename from src/rand_bytes.ml rename to src/core/rand_bytes.ml diff --git a/src/rand_bytes.mli b/src/core/rand_bytes.mli similarity index 100% rename from src/rand_bytes.mli rename to src/core/rand_bytes.mli diff --git a/src/proto/.ocamlformat-ignore b/src/proto/.ocamlformat-ignore new file mode 100644 index 00000000..72e8ffc0 --- /dev/null +++ b/src/proto/.ocamlformat-ignore @@ -0,0 +1 @@ +* diff --git a/src/common_pb.ml b/src/proto/common_pb.ml similarity index 100% rename from src/common_pb.ml rename to src/proto/common_pb.ml diff --git a/src/common_pb.mli b/src/proto/common_pb.mli similarity index 100% rename from src/common_pb.mli rename to src/proto/common_pb.mli diff --git a/src/common_pp.ml b/src/proto/common_pp.ml similarity index 100% rename from src/common_pp.ml rename to src/proto/common_pp.ml diff --git a/src/common_pp.mli b/src/proto/common_pp.mli similarity index 100% rename from src/common_pp.mli rename to src/proto/common_pp.mli diff --git a/src/common_types.ml b/src/proto/common_types.ml similarity index 100% rename from src/common_types.ml rename to src/proto/common_types.ml diff --git a/src/common_types.mli b/src/proto/common_types.mli similarity index 100% rename from src/common_types.mli rename to src/proto/common_types.mli diff --git a/src/dune b/src/proto/dune similarity index 95% rename from src/dune rename to src/proto/dune index f91ee2aa..b786b70e 100644 --- a/src/dune +++ b/src/proto/dune @@ -1,10 +1,9 @@ (library - (name opentelemetry) - (synopsis "API for opentelemetry instrumentation") + (name opentelemetry_proto) + (public_name opentelemetry.proto) + (synopsis "Protobuf generated code for opentelemetry") (flags :standard -warn-error -a+8) - (libraries ambient-context ptime ptime.clock.os pbrt threads - opentelemetry.atomic) - (public_name opentelemetry)) + (libraries pbrt)) ; ### protobuf rules ### diff --git a/src/logs_pb.ml b/src/proto/logs_pb.ml similarity index 100% rename from src/logs_pb.ml rename to src/proto/logs_pb.ml diff --git a/src/logs_pb.mli b/src/proto/logs_pb.mli similarity index 100% rename from src/logs_pb.mli rename to src/proto/logs_pb.mli diff --git a/src/logs_pp.ml b/src/proto/logs_pp.ml similarity index 100% rename from src/logs_pp.ml rename to src/proto/logs_pp.ml diff --git a/src/logs_pp.mli b/src/proto/logs_pp.mli similarity index 100% rename from src/logs_pp.mli rename to src/proto/logs_pp.mli diff --git a/src/logs_service_pb.ml b/src/proto/logs_service_pb.ml similarity index 100% rename from src/logs_service_pb.ml rename to src/proto/logs_service_pb.ml diff --git a/src/logs_service_pb.mli b/src/proto/logs_service_pb.mli similarity index 100% rename from src/logs_service_pb.mli rename to src/proto/logs_service_pb.mli diff --git a/src/logs_service_pp.ml b/src/proto/logs_service_pp.ml similarity index 100% rename from src/logs_service_pp.ml rename to src/proto/logs_service_pp.ml diff --git a/src/logs_service_pp.mli b/src/proto/logs_service_pp.mli similarity index 100% rename from src/logs_service_pp.mli rename to src/proto/logs_service_pp.mli diff --git a/src/logs_service_types.ml b/src/proto/logs_service_types.ml similarity index 100% rename from src/logs_service_types.ml rename to src/proto/logs_service_types.ml diff --git a/src/logs_service_types.mli b/src/proto/logs_service_types.mli similarity index 100% rename from src/logs_service_types.mli rename to src/proto/logs_service_types.mli diff --git a/src/logs_types.ml b/src/proto/logs_types.ml similarity index 100% rename from src/logs_types.ml rename to src/proto/logs_types.ml diff --git a/src/logs_types.mli b/src/proto/logs_types.mli similarity index 100% rename from src/logs_types.mli rename to src/proto/logs_types.mli diff --git a/src/metrics_pb.ml b/src/proto/metrics_pb.ml similarity index 100% rename from src/metrics_pb.ml rename to src/proto/metrics_pb.ml diff --git a/src/metrics_pb.mli b/src/proto/metrics_pb.mli similarity index 100% rename from src/metrics_pb.mli rename to src/proto/metrics_pb.mli diff --git a/src/metrics_pp.ml b/src/proto/metrics_pp.ml similarity index 100% rename from src/metrics_pp.ml rename to src/proto/metrics_pp.ml diff --git a/src/metrics_pp.mli b/src/proto/metrics_pp.mli similarity index 100% rename from src/metrics_pp.mli rename to src/proto/metrics_pp.mli diff --git a/src/metrics_service_pb.ml b/src/proto/metrics_service_pb.ml similarity index 100% rename from src/metrics_service_pb.ml rename to src/proto/metrics_service_pb.ml diff --git a/src/metrics_service_pb.mli b/src/proto/metrics_service_pb.mli similarity index 100% rename from src/metrics_service_pb.mli rename to src/proto/metrics_service_pb.mli diff --git a/src/metrics_service_pp.ml b/src/proto/metrics_service_pp.ml similarity index 100% rename from src/metrics_service_pp.ml rename to src/proto/metrics_service_pp.ml diff --git a/src/metrics_service_pp.mli b/src/proto/metrics_service_pp.mli similarity index 100% rename from src/metrics_service_pp.mli rename to src/proto/metrics_service_pp.mli diff --git a/src/metrics_service_types.ml b/src/proto/metrics_service_types.ml similarity index 100% rename from src/metrics_service_types.ml rename to src/proto/metrics_service_types.ml diff --git a/src/metrics_service_types.mli b/src/proto/metrics_service_types.mli similarity index 100% rename from src/metrics_service_types.mli rename to src/proto/metrics_service_types.mli diff --git a/src/metrics_types.ml b/src/proto/metrics_types.ml similarity index 100% rename from src/metrics_types.ml rename to src/proto/metrics_types.ml diff --git a/src/metrics_types.mli b/src/proto/metrics_types.mli similarity index 100% rename from src/metrics_types.mli rename to src/proto/metrics_types.mli diff --git a/src/resource_pb.ml b/src/proto/resource_pb.ml similarity index 100% rename from src/resource_pb.ml rename to src/proto/resource_pb.ml diff --git a/src/resource_pb.mli b/src/proto/resource_pb.mli similarity index 100% rename from src/resource_pb.mli rename to src/proto/resource_pb.mli diff --git a/src/resource_pp.ml b/src/proto/resource_pp.ml similarity index 100% rename from src/resource_pp.ml rename to src/proto/resource_pp.ml diff --git a/src/resource_pp.mli b/src/proto/resource_pp.mli similarity index 100% rename from src/resource_pp.mli rename to src/proto/resource_pp.mli diff --git a/src/resource_types.ml b/src/proto/resource_types.ml similarity index 100% rename from src/resource_types.ml rename to src/proto/resource_types.ml diff --git a/src/resource_types.mli b/src/proto/resource_types.mli similarity index 100% rename from src/resource_types.mli rename to src/proto/resource_types.mli diff --git a/src/status.proto b/src/proto/status.proto similarity index 100% rename from src/status.proto rename to src/proto/status.proto diff --git a/src/status_pb.ml b/src/proto/status_pb.ml similarity index 100% rename from src/status_pb.ml rename to src/proto/status_pb.ml diff --git a/src/status_pb.mli b/src/proto/status_pb.mli similarity index 100% rename from src/status_pb.mli rename to src/proto/status_pb.mli diff --git a/src/status_pp.ml b/src/proto/status_pp.ml similarity index 100% rename from src/status_pp.ml rename to src/proto/status_pp.ml diff --git a/src/status_pp.mli b/src/proto/status_pp.mli similarity index 100% rename from src/status_pp.mli rename to src/proto/status_pp.mli diff --git a/src/status_types.ml b/src/proto/status_types.ml similarity index 100% rename from src/status_types.ml rename to src/proto/status_types.ml diff --git a/src/status_types.mli b/src/proto/status_types.mli similarity index 100% rename from src/status_types.mli rename to src/proto/status_types.mli diff --git a/src/trace_pb.ml b/src/proto/trace_pb.ml similarity index 100% rename from src/trace_pb.ml rename to src/proto/trace_pb.ml diff --git a/src/trace_pb.mli b/src/proto/trace_pb.mli similarity index 100% rename from src/trace_pb.mli rename to src/proto/trace_pb.mli diff --git a/src/trace_pp.ml b/src/proto/trace_pp.ml similarity index 100% rename from src/trace_pp.ml rename to src/proto/trace_pp.ml diff --git a/src/trace_pp.mli b/src/proto/trace_pp.mli similarity index 100% rename from src/trace_pp.mli rename to src/proto/trace_pp.mli diff --git a/src/trace_service_pb.ml b/src/proto/trace_service_pb.ml similarity index 100% rename from src/trace_service_pb.ml rename to src/proto/trace_service_pb.ml diff --git a/src/trace_service_pb.mli b/src/proto/trace_service_pb.mli similarity index 100% rename from src/trace_service_pb.mli rename to src/proto/trace_service_pb.mli diff --git a/src/trace_service_pp.ml b/src/proto/trace_service_pp.ml similarity index 100% rename from src/trace_service_pp.ml rename to src/proto/trace_service_pp.ml diff --git a/src/trace_service_pp.mli b/src/proto/trace_service_pp.mli similarity index 100% rename from src/trace_service_pp.mli rename to src/proto/trace_service_pp.mli diff --git a/src/trace_service_types.ml b/src/proto/trace_service_types.ml similarity index 100% rename from src/trace_service_types.ml rename to src/proto/trace_service_types.ml diff --git a/src/trace_service_types.mli b/src/proto/trace_service_types.mli similarity index 100% rename from src/trace_service_types.mli rename to src/proto/trace_service_types.mli diff --git a/src/trace_types.ml b/src/proto/trace_types.ml similarity index 100% rename from src/trace_types.ml rename to src/proto/trace_types.ml diff --git a/src/trace_types.mli b/src/proto/trace_types.mli similarity index 100% rename from src/trace_types.mli rename to src/proto/trace_types.mli diff --git a/tests/cohttp/dune b/tests/cohttp/dune new file mode 100644 index 00000000..b467b27c --- /dev/null +++ b/tests/cohttp/dune @@ -0,0 +1,4 @@ +(tests + (names test_get_url) + (package opentelemetry-client-cohttp-lwt) + (libraries opentelemetry opentelemetry-client-cohttp-lwt)) diff --git a/tests/test_get_url.expected b/tests/cohttp/test_get_url.expected similarity index 50% rename from tests/test_get_url.expected rename to tests/cohttp/test_get_url.expected index bafd6ea4..400f46eb 100644 --- a/tests/test_get_url.expected +++ b/tests/cohttp/test_get_url.expected @@ -1,2 +1 @@ -ocurl url = http://localhost:3000 cohttp url = http://localhost:3000 diff --git a/tests/test_get_url.ml b/tests/cohttp/test_get_url.ml similarity index 51% rename from tests/test_get_url.ml rename to tests/cohttp/test_get_url.ml index 397996d3..3a271956 100644 --- a/tests/test_get_url.ml +++ b/tests/cohttp/test_get_url.ml @@ -1,17 +1,9 @@ let url = "http://localhost:3000" -let ocurl () = - let config = Opentelemetry_client_ocurl.Config.make ~url () in - Opentelemetry_client_ocurl.with_setup ~config () @@ fun () -> - let url = Opentelemetry_client_ocurl.get_url () in - print_endline @@ Printf.sprintf "ocurl url = %s" url - let cohttp () = let config = Opentelemetry_client_cohttp_lwt.Config.make ~url () in Opentelemetry_client_cohttp_lwt.with_setup ~config () @@ fun () -> let url = Opentelemetry_client_cohttp_lwt.get_url () in print_endline @@ Printf.sprintf "cohttp url = %s" url -let () = - ocurl (); - cohttp () +let () = cohttp () diff --git a/tests/core/dune b/tests/core/dune new file mode 100644 index 00000000..da93554f --- /dev/null +++ b/tests/core/dune @@ -0,0 +1,5 @@ + +(tests + (names test_trace_context ) + (package opentelemetry) + (libraries opentelemetry)) diff --git a/tests/test_trace_context.expected b/tests/core/test_trace_context.expected similarity index 100% rename from tests/test_trace_context.expected rename to tests/core/test_trace_context.expected diff --git a/tests/test_trace_context.ml b/tests/core/test_trace_context.ml similarity index 100% rename from tests/test_trace_context.ml rename to tests/core/test_trace_context.ml diff --git a/tests/dune b/tests/dune deleted file mode 100644 index c005f866..00000000 --- a/tests/dune +++ /dev/null @@ -1,4 +0,0 @@ -(tests - (names test_trace_context test_get_url) - (libraries opentelemetry opentelemetry-client-ocurl - opentelemetry-client-cohttp-lwt)) diff --git a/tests/implicit_scope/sync/dune b/tests/implicit_scope/sync/dune index 072eee77..8b5407f4 100644 --- a/tests/implicit_scope/sync/dune +++ b/tests/implicit_scope/sync/dune @@ -1,3 +1,4 @@ (tests (names test_implicit_scope_sync) + (package opentelemetry-client-cohttp-lwt) (libraries alcotest opentelemetry opentelemetry-client-cohttp-lwt)) diff --git a/tests/ocurl/dune b/tests/ocurl/dune new file mode 100644 index 00000000..18a15fca --- /dev/null +++ b/tests/ocurl/dune @@ -0,0 +1,5 @@ + +(tests + (names test_get_url) + (package opentelemetry-client-ocurl) + (libraries opentelemetry opentelemetry-client-ocurl)) diff --git a/tests/ocurl/test_get_url.expected b/tests/ocurl/test_get_url.expected new file mode 100644 index 00000000..0b9a4214 --- /dev/null +++ b/tests/ocurl/test_get_url.expected @@ -0,0 +1 @@ +ocurl url = http://localhost:3000 diff --git a/tests/ocurl/test_get_url.ml b/tests/ocurl/test_get_url.ml new file mode 100644 index 00000000..1e142015 --- /dev/null +++ b/tests/ocurl/test_get_url.ml @@ -0,0 +1,9 @@ +let url = "http://localhost:3000" + +let ocurl () = + let config = Opentelemetry_client_ocurl.Config.make ~url () in + Opentelemetry_client_ocurl.with_setup ~config () @@ fun () -> + let url = Opentelemetry_client_ocurl.get_url () in + print_endline @@ Printf.sprintf "ocurl url = %s" url + +let () = ocurl ()