Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
6e8877f
test: reference test for encoding size
c-cube Oct 31, 2025
4066cad
test: improve t_size
c-cube Oct 31, 2025
2a2baeb
update test core
c-cube Oct 31, 2025
30d446c
makefile
c-cube Oct 30, 2025
bf09b58
update generated protobuf code
c-cube Oct 30, 2025
f000c11
update the emit test so it records how many bytes were emitted
c-cube Oct 30, 2025
0f1452e
update generated code
c-cube Oct 31, 2025
a35ea4c
fixes
c-cube Oct 31, 2025
c27cb13
fix test
c-cube Oct 31, 2025
6f75e90
fix test
c-cube Oct 31, 2025
81b6a81
update core test
c-cube Oct 31, 2025
5ef84a4
update test output
c-cube Oct 31, 2025
49ca5be
test
c-cube Oct 31, 2025
15140e0
chore: update OTEL to 1.8.0
c-cube Oct 31, 2025
51f783a
udpate generated proto code
c-cube Oct 31, 2025
41d8b0c
fix
c-cube Oct 31, 2025
5dcf26b
update generated tests
c-cube Oct 31, 2025
f51d52a
chore: CI: pin specific commit for pbrt/ocaml-protoc
c-cube Nov 3, 2025
8290b9b
fix warnings
c-cube Nov 3, 2025
6da4aa4
yes yes use the right commit please
c-cube Nov 3, 2025
ef5b5f5
nix
c-cube Nov 3, 2025
e2c545d
luv2edit sha256
c-cube Nov 3, 2025
d4b4424
update generated code again, repeated fields are optional again
c-cube Nov 3, 2025
5400f52
update generated code
c-cube Nov 4, 2025
2e69dd5
update ocaml-protoc in CI
c-cube Nov 4, 2025
ba1a8ee
update protobuf code
c-cube Nov 4, 2025
2544493
fix nix sha256
c-cube Nov 4, 2025
d2478f1
update test output
c-cube Nov 4, 2025
7839ba9
test
c-cube Nov 4, 2025
4b91971
more test output
c-cube Nov 4, 2025
3182064
update opam constraints for pbrt
c-cube Dec 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ jobs:
allow-prerelease-opam: true

- run: |
opam pin ocaml-protoc 3.0.1 -y -n
opam pin pbrt 3.0.1 -y -n
opam pin https://github.com/mransan/ocaml-protoc.git#5510694deffde13283742b8ad116fab61b65dfbc -y -n
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi a nice way to do this even for testing is using a pin-depends field in an *.opam.template file:
https://github.com/semgrep/semgrep/blob/develop/semgrep.opam.template#L17-L20

this gets picked up picked up by dune when it generates the opam file. Additionally, this will also get picked up by nix so you don't have to make the change to flake.nix you have

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that currently this opam package fails to install w/out this change

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that ocaml-protoc 4.0 is released, pinning 4.0 should also work!

opam install pbrt -y

# We cannot install packages that need eio on ocaml versions before 5
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ clean:
@dune clean

protoc-gen:
FORCE_GENPROTO=true @dune build @lint
FORCE_GENPROTO=true dune build @lint

format:
@dune build @fmt --auto-promote
Expand Down
4 changes: 2 additions & 2 deletions dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
(alcotest :with-test)
(pbrt
(and
(>= 3.0)
(< 4.0)))
(>= 4.0)
(< 5.0)))
(ocaml-lsp-server :with-dev-setup)
(ocamlformat
(and
Expand Down
7 changes: 7 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@
overlay = final: prev:
{
# You can add overrides here
pbrt = prev.pbrt.overrideAttrs (oldAttrs: {
src = pkgs.fetchgit {
url = "https://github.com/mransan/ocaml-protoc.git";
rev = "5510694deffde13283742b8ad116fab61b65dfbc";
sha256 = "sha256-0eQEaAZMs/OydNLsEKxdbdwx0/Ots6fLEpYg89VxK3k=";
};
});
};
scope' = scope.overrideScope overlay;
# Packages from devPackagesQuery
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry.opam
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ depends: [
"thread-local-storage" {>= "0.2" & < "0.3"}
"odoc" {with-doc}
"alcotest" {with-test}
"pbrt" {>= "3.0" & < "4.0"}
"pbrt" {>= "4.0" & < "5.0"}
"ocaml-lsp-server" {with-dev-setup}
"ocamlformat" {with-dev-setup & >= "0.27" & < "0.28"}
"mtime" {>= "1.4"}
Expand Down
10 changes: 8 additions & 2 deletions src/client-cohttp-eio/opentelemetry_client_cohttp_eio.ml
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,14 @@ let report_err_ = function
| `Sysbreak -> Printf.eprintf "opentelemetry: ctrl-c captured, stopping\n%!"
| `Failure msg ->
Format.eprintf "@[<2>opentelemetry: export failed: %s@]@." msg
| `Status (code, { Opentelemetry.Proto.Status.code = scode; message; details })
->
| `Status
( code,
{
Opentelemetry.Proto.Status.code = scode;
message;
details;
_presence = _;
} ) ->
let pp_details out l =
List.iter
(fun s -> Format.fprintf out "%S;@ " (Bytes.unsafe_to_string s))
Expand Down
10 changes: 8 additions & 2 deletions src/client-cohttp-lwt/opentelemetry_client_cohttp_lwt.ml
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,14 @@ let report_err_ = function
| `Sysbreak -> Printf.eprintf "opentelemetry: ctrl-c captured, stopping\n%!"
| `Failure msg ->
Format.eprintf "@[<2>opentelemetry: export failed: %s@]@." msg
| `Status (code, { Opentelemetry.Proto.Status.code = scode; message; details })
->
| `Status
( code,
{
Opentelemetry.Proto.Status.code = scode;
message;
details;
_presence = _;
} ) ->
let pp_details out l =
List.iter
(fun s -> Format.fprintf out "%S;@ " (Bytes.unsafe_to_string s))
Expand Down
12 changes: 11 additions & 1 deletion src/client-ocurl/opentelemetry_client_ocurl.ml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ module Backend_impl : sig

val send_event : t -> Event.t -> unit

val n_bytes_sent : unit -> int

val shutdown : t -> on_done:(unit -> unit) -> unit
end = struct
open Opentelemetry.Proto
Expand Down Expand Up @@ -187,6 +189,10 @@ end = struct

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

let n_bytes_sent_ = Atomic.make 0

let[@inline] n_bytes_sent () = Atomic.get n_bytes_sent_

(** Thread that, in a loop, reads from [q] to get the next message to send via
http *)
let bg_thread_loop (self : t) : unit =
Expand All @@ -199,7 +205,9 @@ end = struct
Self_trace.with_ ~kind:Span_kind_producer name
~attrs:[ "n", `Int (List.length l) ]
in
conv l |> send_http_ ~stop ~config ~url client
let msg = conv l in
ignore (Atomic.fetch_and_add n_bytes_sent_ (String.length msg) : int);
send_http_ ~stop ~config ~url client msg
in
try
while not (Atomic.get stop) do
Expand Down Expand Up @@ -471,3 +479,5 @@ let with_setup ?stop ?config ?(enable = true) () f =
Fun.protect ~finally:remove_backend f
) else
f ()

let n_bytes_sent = Backend_impl.n_bytes_sent
3 changes: 3 additions & 0 deletions src/client-ocurl/opentelemetry_client_ocurl.mli
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ val set_headers : (string * string) list -> unit
module Atomic = Opentelemetry_atomic.Atomic
module Config = Config

val n_bytes_sent : unit -> int
(** Global counter of bytes sent (or attempted to be sent) *)

val create_backend :
?stop:bool Atomic.t ->
?config:Config.t ->
Expand Down
2 changes: 1 addition & 1 deletion src/client/self_trace.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module OT = Opentelemetry

let enabled = Atomic.make true
let enabled = Atomic.make false

let add_event (scope : OT.Scope.t) ev = OT.Scope.add_event scope (fun () -> ev)

Expand Down
7 changes: 3 additions & 4 deletions src/client/signal.ml
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,22 @@ module Encode = struct
resource_logs
|> resource_to_string ~encoder
~ctor:(fun r ->
Logs_service.default_export_logs_service_request ~resource_logs:r ())
Logs_service.make_export_logs_service_request ~resource_logs:r ())
~enc:Logs_service.encode_pb_export_logs_service_request

let metrics ?encoder resource_metrics =
resource_metrics
|> resource_to_string ~encoder
~ctor:(fun r ->
Metrics_service.default_export_metrics_service_request
Metrics_service.make_export_metrics_service_request
~resource_metrics:r ())
~enc:Metrics_service.encode_pb_export_metrics_service_request

let traces ?encoder resource_spans =
resource_spans
|> resource_to_string ~encoder
~ctor:(fun r ->
Trace_service.default_export_trace_service_request ~resource_spans:r
())
Trace_service.make_export_trace_service_request ~resource_spans:r ())
~enc:Trace_service.encode_pb_export_trace_service_request
end

Expand Down
Loading
Loading