Skip to content

Commit

Permalink
Merge pull request #48 from imandra-ai/wip-protoc-3.0
Browse files Browse the repository at this point in the history
use ocaml-protoc 3.0.x
  • Loading branch information
c-cube authored Dec 20, 2023
2 parents e53cffb + 8164ae5 commit 47f7f1d
Show file tree
Hide file tree
Showing 84 changed files with 6,522 additions and 5,610 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: build
on:
pull_request:
push:
branches:
- main

jobs:
build:
Expand Down Expand Up @@ -35,13 +37,18 @@ jobs:
with:
ocaml-compiler: ${{ matrix.ocaml-compiler }}
opam-depext-flags: --with-test
dune-cache: true
allow-prerelease-opam: true

- run: |
opam pin ocaml-protoc 3.0.1 -y -n
opam pin pbrt 3.0.1 -y -n
opam install ocaml-protoc pbrt -y
- run: opam install . --deps-only --with-test

- 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.4 -y

- run: opam exec -- dune build @lint

# check that nothing changed
Expand Down
10 changes: 3 additions & 7 deletions dune-project
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(lang dune 2.7)
(lang dune 2.9)

(name opentelemetry)

Expand Down Expand Up @@ -31,7 +31,7 @@
(odoc :with-doc)
(alcotest :with-test)
(pbrt
(and (>= 2.3) (< 3.0)))
(and (>= 3.0) (< 4.0)))
(ocaml-lsp-server :with-dev-setup)
(ocamlformat
(and
Expand All @@ -43,7 +43,7 @@
(trace
(or
(< 0.4)
(>= 0.5))))
(>= 0.6))))
(tags
(instrumentation tracing opentelemetry datadog jaeger)))

Expand Down Expand Up @@ -77,8 +77,6 @@
; atomic ; vendored
(opentelemetry
(= :version))
(pbrt
(and (>= 2.3) (< 3.0)))
(odoc :with-doc)
(ezcurl
(>= 0.2.3))
Expand Down Expand Up @@ -113,8 +111,6 @@
; for spans
(opentelemetry
(= :version))
(pbrt
(and (>= 2.2) (< 3.0)))
(odoc :with-doc)
(lwt
(>= "5.3"))
Expand Down
5 changes: 3 additions & 2 deletions opentelemetry-client-cohttp-lwt.opam
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ license: "MIT"
homepage: "https://github.com/imandra-ai/ocaml-opentelemetry"
bug-reports: "https://github.com/imandra-ai/ocaml-opentelemetry/issues"
depends: [
"dune" {>= "2.7"}
"dune" {>= "2.9"}
"ocaml" {>= "4.08"}
"mtime" {>= "1.4"}
"opentelemetry" {= version}
"pbrt" {>= "2.2" & < "3.0"}
"odoc" {with-doc}
"lwt" {>= "5.3"}
"lwt_ppx" {>= "2.0"}
Expand All @@ -33,9 +32,11 @@ build: [
name
"-j"
jobs
"--promote-install-files=false"
"@install"
"@runtest" {with-test}
"@doc" {with-doc}
]
["dune" "install" "-p" name "--create-install-files" name]
]
dev-repo: "git+https://github.com/imandra-ai/ocaml-opentelemetry.git"
5 changes: 3 additions & 2 deletions opentelemetry-client-ocurl.opam
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ license: "MIT"
homepage: "https://github.com/imandra-ai/ocaml-opentelemetry"
bug-reports: "https://github.com/imandra-ai/ocaml-opentelemetry/issues"
depends: [
"dune" {>= "2.7"}
"dune" {>= "2.9"}
"ocaml" {>= "4.08"}
"mtime" {>= "1.4"}
"opentelemetry" {= version}
"pbrt" {>= "2.3" & < "3.0"}
"odoc" {with-doc}
"ezcurl" {>= "0.2.3"}
"ocurl"
Expand All @@ -31,9 +30,11 @@ build: [
name
"-j"
jobs
"--promote-install-files=false"
"@install"
"@runtest" {with-test}
"@doc" {with-doc}
]
["dune" "install" "-p" name "--create-install-files" name]
]
dev-repo: "git+https://github.com/imandra-ai/ocaml-opentelemetry.git"
4 changes: 3 additions & 1 deletion opentelemetry-cohttp-lwt.opam
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ license: "MIT"
homepage: "https://github.com/imandra-ai/ocaml-opentelemetry"
bug-reports: "https://github.com/imandra-ai/ocaml-opentelemetry/issues"
depends: [
"dune" {>= "2.7"}
"dune" {>= "2.9"}
"ocaml" {>= "4.08"}
"opentelemetry" {= version}
"opentelemetry-lwt" {= version}
Expand All @@ -30,9 +30,11 @@ build: [
name
"-j"
jobs
"--promote-install-files=false"
"@install"
"@runtest" {with-test}
"@doc" {with-doc}
]
["dune" "install" "-p" name "--create-install-files" name]
]
dev-repo: "git+https://github.com/imandra-ai/ocaml-opentelemetry.git"
4 changes: 3 additions & 1 deletion opentelemetry-lwt.opam
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ tags: ["instrumentation" "tracing" "opentelemetry" "datadog" "lwt"]
homepage: "https://github.com/imandra-ai/ocaml-opentelemetry"
bug-reports: "https://github.com/imandra-ai/ocaml-opentelemetry/issues"
depends: [
"dune" {>= "2.7"}
"dune" {>= "2.9"}
"ocaml" {>= "4.08"}
"ambient-context"
"opentelemetry" {= version}
Expand All @@ -32,9 +32,11 @@ build: [
name
"-j"
jobs
"--promote-install-files=false"
"@install"
"@runtest" {with-test}
"@doc" {with-doc}
]
["dune" "install" "-p" name "--create-install-files" name]
]
dev-repo: "git+https://github.com/imandra-ai/ocaml-opentelemetry.git"
8 changes: 5 additions & 3 deletions opentelemetry.opam
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ tags: ["instrumentation" "tracing" "opentelemetry" "datadog" "jaeger"]
homepage: "https://github.com/imandra-ai/ocaml-opentelemetry"
bug-reports: "https://github.com/imandra-ai/ocaml-opentelemetry/issues"
depends: [
"dune" {>= "2.7"}
"dune" {>= "2.9"}
"ocaml" {>= "4.08"}
"ptime"
"ambient-context"
"odoc" {with-doc}
"alcotest" {with-test}
"pbrt" {>= "2.3" & < "3.0"}
"pbrt" {>= "3.0" & < "4.0"}
"ocaml-lsp-server" {with-dev-setup}
"ocamlformat" {with-dev-setup & >= "0.24" & < "0.25"}
]
depopts: ["trace"]
conflicts: [
"trace" {< "0.4" | >= "0.5"}
"trace" {< "0.4" | >= "0.6"}
]
build: [
["dune" "subst"] {dev}
Expand All @@ -36,9 +36,11 @@ build: [
name
"-j"
jobs
"--promote-install-files=false"
"@install"
"@runtest" {with-test}
"@doc" {with-doc}
]
["dune" "install" "-p" name "--create-install-files" name]
]
dev-repo: "git+https://github.com/imandra-ai/ocaml-opentelemetry.git"
8 changes: 4 additions & 4 deletions src/client-cohttp-lwt/opentelemetry_client_cohttp_lwt.ml
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ end = struct

let r =
try
let status = Status.decode_status dec in
let status = Status.decode_pb_status dec in
Error (`Status (code, status))
with e ->
let bt = Printexc.get_backtrace () in
Expand Down Expand Up @@ -318,23 +318,23 @@ let mk_emitter ~stop ~(config : Config.t) () : (module EMITTER) =
~resource_metrics:l ()
in
send_http_ curl encoder ~path:"/v1/metrics"
~encode:Metrics_service.encode_export_metrics_service_request x
~encode:Metrics_service.encode_pb_export_metrics_service_request x

let send_traces_http curl encoder (l : Trace.resource_spans list list) =
let l = List.fold_left (fun acc l -> List.rev_append l acc) [] l in
let x =
Trace_service.default_export_trace_service_request ~resource_spans:l ()
in
send_http_ curl encoder ~path:"/v1/traces"
~encode:Trace_service.encode_export_trace_service_request x
~encode:Trace_service.encode_pb_export_trace_service_request x

let send_logs_http curl encoder (l : Logs.resource_logs list list) =
let l = List.fold_left (fun acc l -> List.rev_append l acc) [] l in
let x =
Logs_service.default_export_logs_service_request ~resource_logs:l ()
in
send_http_ curl encoder ~path:"/v1/logs"
~encode:Logs_service.encode_export_logs_service_request x
~encode:Logs_service.encode_pb_export_logs_service_request x

(* emit metrics, if the batch is full or timeout lapsed *)
let emit_metrics_maybe ~now ?force httpc encoder : bool Lwt.t =
Expand Down
8 changes: 4 additions & 4 deletions src/client-ocurl/opentelemetry_client_ocurl.ml
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ end = struct
let dec = Pbrt.Decoder.of_string body in
let body =
try
let status = Status.decode_status dec in
let status = Status.decode_pb_status dec in
Format.asprintf "%a" Status.pp_status status
with _ ->
spf "(could not decode status)\nraw bytes: %s" (str_to_hex body)
Expand Down Expand Up @@ -175,7 +175,7 @@ end = struct
Logs_service.default_export_logs_service_request ~resource_logs:l ()
in
send_http_ ~stop ~config client encoder ~path:"/v1/logs"
~encode:Logs_service.encode_export_logs_service_request x
~encode:Logs_service.encode_pb_export_logs_service_request x

let send_metrics_http ~stop ~config curl encoder
(l : Metrics.resource_metrics list list) : unit =
Expand All @@ -185,7 +185,7 @@ end = struct
()
in
send_http_ ~stop ~config curl encoder ~path:"/v1/metrics"
~encode:Metrics_service.encode_export_metrics_service_request x
~encode:Metrics_service.encode_pb_export_metrics_service_request x

let send_traces_http ~stop ~config curl encoder
(l : Trace.resource_spans list list) : unit =
Expand All @@ -194,7 +194,7 @@ end = struct
Trace_service.default_export_trace_service_request ~resource_spans:l ()
in
send_http_ ~stop ~config curl encoder ~path:"/v1/traces"
~encode:Trace_service.encode_export_trace_service_request x
~encode:Trace_service.encode_pb_export_trace_service_request x

let[@inline] send_event (self : t) ev : unit = B_queue.push self.q ev

Expand Down
Loading

0 comments on commit 47f7f1d

Please sign in to comment.