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?