Hi Family how are you?
I have been reading about Ecto telemetry events, but I am not sure about how these telemetry events work.
for example the documentation says:
defmodule MyApp.Telemetry do
def handle_event([:my_app, :repo, :query], measurements, metadata, config) do
IO.inspect binding()
end
end
This event is thrown when a query is performed. but I am not sure if this event is thrown automatically or really I need to write the execute command:
as is shown in the following code:
:telemetry.execute(
[:credit_card_information, :repo, :query],
%{query: 1},
%{table: "customer"}
)
For example, if I want to know how much time a query spent, how can I measure that?
-
:query_time
- the time spent executing the query.
url documentation Ecto.Repo — Ecto v3.10.1