improvement: don't call telemetry when compiling

This commit is contained in:
Zach Daniel 2024-02-08 10:48:12 -05:00
parent d47eb086a2
commit 2074cbe997

View file

@ -82,17 +82,22 @@ defmodule Ash.Tracer do
start = System.monotonic_time() start = System.monotonic_time()
compiling? = Code.can_await_module_compilation?()
unless compiling? do
:telemetry.execute( :telemetry.execute(
telemetry_name ++ [:start], telemetry_name ++ [:start],
%{system_time: System.system_time()}, %{system_time: System.system_time()},
metadata metadata
) )
end
try do try do
unquote(opts[:do]) unquote(opts[:do])
after after
duration = System.monotonic_time() - start duration = System.monotonic_time() - start
unless compiling? do
:telemetry.execute( :telemetry.execute(
telemetry_name ++ [:stop], telemetry_name ++ [:stop],
%{system_time: System.system_time(), duration: duration}, %{system_time: System.system_time(), duration: duration},
@ -101,6 +106,7 @@ defmodule Ash.Tracer do
end end
end end
end end
end
def stop_span(nil), do: :ok def stop_span(nil), do: :ok