I have multiple ecto applications as umbrella.
I want to attach prometheus metrics to all of them. In each applicaition.ex from each umbrella I have.
:ok =
:telemetry.attach(
"prometheus-ecto",
[:restaurants_domain, :repo, :query],
&Restaurants.RepoInstrumenter.handle_event/4,
%{}
)
:ok =
:telemetry.attach(
"prometheus-ecto",
[:users_domain, :repo, :query],
&Users.RepoInstrumenter.handle_event/4,
%{}
)
This raises error at runtime though at the second attach:
** (MatchError) no match of right hand side value: {:error, :already_exists}
How can I attach telemetry to multiple ecto repos and delegate the handle event to each one?