imandra-ai / ocaml-opentelemetry

Instrumentation for https://opentelemetry.io
http://docs.imandra.ai/ocaml-opentelemetry/
33 stars 7 forks source link

Collector that uses EIO #51

Open emjin opened 7 months ago

emjin commented 7 months ago

Thanks for this API and the backends! It's a great project. In addition to the existing collectors, it would be great to have one that uses EIO, which is nicer than Lwt.

I was also wondering if you had any advice for how best to integrate opentelemetry. In particular, I would rather use the cohttp-lwt collector over the ocurl one since it doesn't require having libcurl, but since our codebase already uses lwt in multiple places, with multiple Lwt_main.run scopes, adding a new toplevel Lwt_main.run scope is fairly annoying.

c-cube commented 7 months ago

Hi! To run the lwt collector you don't need Lwt_main.run if it's already running. I think the with_setup is a bit useless actually though, if that's what you are referring to, but Opentelemetry_client_cohttp_lwt.setup(); … inside a running Lwt_main.run should work just fine.

emjin commented 7 months ago

My problem is that at the top level entry point where I want to instrument our code, it's possible that we call a function that would create a Lwt_main.run scope, and it's also possible we don't. My understanding is that I would have to create a Lwt_main.run scope before calling the function that I want to instrument, and then for the later ones I would pass down the Lwt monad.

ELLIOTTCABLE commented 7 months ago

Hm. An EIO collector might be on my eventual todo-list (I maintain the Lwt one), but I need to deeply test ambient-context w/ Eio first.

Unfortunately, we aren't really using OCaml 5 internally at Ahrefs yet, so I don't get to spend a lot of work-time on this 😓; it'll depend on my available free-time, tbh …

emjin commented 7 months ago

Maybe we (Semgrep) will take a stab at it in a few months (we haven't switched to OCaml 5 but we hope to). I'll let you know if we do and ask for advice 🙏