tesla
tesla copied to clipboard
Telemetry legacy event is sending duration in native_time instead of millisecond
The duration previously sent in the legacy telemetry returned a microsecond duration and now it sends as native_time.
It seems that the snippet below should fix the issue, but for some weird reason my telemetry system is not working properly with this change. May be another bug elsewhere in my code or this doesn't properly fix it. I'm sending the code as it can be helpful.
defp emit_legacy_event(duration, result) do
duration_ms = System.convert_time_unit(duration, :native, :microsecond)
if !@disable_legacy_event do
:telemetry.execute(
[:tesla, :request],
%{request_time: duration_ms},
%{result: result}
)
end
end
The previous version used :timer.tc/3 which reports time in microseconds, the new one uses System.monotonic_time/0 which indeed reports time in native units.
@bryannaegele Would you mind taking a look?
@3duard0 Thanks for the report 🙇