tesla icon indicating copy to clipboard operation
tesla copied to clipboard

Telemetry legacy event is sending duration in native_time instead of millisecond

Open 3duard0 opened this issue 6 years ago • 1 comments

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

3duard0 avatar May 15 '20 20:05 3duard0

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 🙇

teamon avatar May 18 '20 07:05 teamon