You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was playing around with this little example that uses opentelemetry_client_cohttp_lwt:
letrun()=letopenLwt.Syntaxinlet*()=Opentelemetry_lwt.Trace.with_ "my trace"@@fun_scope ->
print_endline "bar"|>Lwt.return
inLwt.return_unit
let()=Opentelemetry_lwt.Globals.service_name :="my service";
let config =Opentelemetry_client_cohttp_lwt.Config.make ~debug:true~url:"http://localhost:4318"()inOpentelemetry_client_cohttp_lwt.with_setup ~config()@@fun() ->
Lwt_main.run (run ())
And was surprised to not see any traces in the Jaeger UI (same example with ocurl works fine), especially because I could see a send span in logs
bar
send spans { resource = ... }
opentelemetry: exiting…
Adding a little delay fix the issue
diff --git a/src/bin/main.ml b/src/bin/main.ml
index fc28bf1..1416c72 100644
--- a/src/bin/main.ml+++ b/src/bin/main.ml@@ -6,6 +6,7 @@ let run () =
Opentelemetry_lwt.Trace.with_ "my trace" @@ fun _scope ->
print_endline "bar" |> Lwt.return
in
+ let* () = Lwt_unix.sleep 2.0 in
Lwt.return_unit
let () =
My understanding is that the cleanup function doesn't have the time to finish before the program terminate.
So in the case of opentelemetry_client_cohttp_lwt, the let* () = emit_all_force httpc encoder doesn't have time to complete before the program terminates.
Should we make sure that all data is emitted before the program terminates (both after "normal" completion and after explicit interruption)?
I guess one way to fix this would be to make the cleanup function return a unit Lw.t to be able to properly wait for its resolution. But the problem is that this is part of a common interface that different backends implement, so I don't think it's possible to force a lwt value. Maybe we can make it parametric or something?
The text was updated successfully, but these errors were encountered:
tatchi
changed the title
opentelemetry-cohttp: make sure to send traces before termination
opentelemetry-cohttp: make sure to emit data before termination
Aug 30, 2023
in `Opentelemetry_client_cohttp_lwt.with_setup` we should now wait for
the cleanup to be done, by sneaking in a `unit Lwt.u` that is only
resolved after the cleanup is done.
close#41
I was playing around with this little example that uses
opentelemetry_client_cohttp_lwt
:And was surprised to not see any traces in the Jaeger UI (same example with
ocurl
works fine), especially because I could see asend span
in logsAdding a little delay fix the issue
My understanding is that the cleanup function doesn't have the time to finish before the program terminate.
I see that we use a
Lwt.async
, which doesn't wait for the resolution of the promise. See for example this code:And the output:
So in the case of
opentelemetry_client_cohttp_lwt
, thelet* () = emit_all_force httpc encoder
doesn't have time to complete before the program terminates.Should we make sure that all data is emitted before the program terminates (both after "normal" completion and after explicit interruption)?
I guess one way to fix this would be to make the cleanup function return a
unit Lw.t
to be able to properly wait for its resolution. But the problem is that this is part of a common interface that different backends implement, so I don't think it's possible to force alwt
value. Maybe we can make it parametric or something?The text was updated successfully, but these errors were encountered: