Maybe you, like me, have found Telemetry while reading Elixir but have had no time to learn more details about it. I recently put some time aside to learn it and decided to write about it. In this article I am going to show you what Telemetry is, why...
blog.miguelcoba.com9 min read
Great article!!!
As you say, we could send telemetry reports to an external service. In that case, it occurs to me that we could use a Task to do it.
For example:
def handle_event([:grocery, :store, :sale], measurements, metadata, _config) do
Task.start(fn ->
:timer.sleep(5_000)
Logger.info("[Sale telemetry: #{measurements.total}] total for #{metadata.product}")
end)
end
In this case, :timer.sleep(5_000) would be the time it takes to send the info to that service (a lot 😂😂😂). It's just an example.
But we wouldn't be blocking the function then.
My question is:
Do you recommend doing it like that? Is there a recommended way of doing it or it's fine like that?
xiaoqiang han
A Elixir Developer
Awesome!