elixir-ecto / db_connection

Database connection behaviour
http://hexdocs.pm/db_connection/DBConnection.html
309 stars 112 forks source link

Telemetry event for capturing DBConnection.ConnectionError #234

Closed polvalente closed 3 years ago

polvalente commented 3 years ago

Is there any way to measure through telemetry if the database keeps dropping connections with DBConnection.ConnectionError?

I noticed that the drop private function in deps/db_connection/lib/db_connection/connection_pool.ex does print a custom inspect whenever the connection is dropped due to timeout. Maybe that could be a place to add the event? Or is there a better place in :ecto or :ecto_sql to do so?

I could work on the PR myself given the right direction!

Thanks in advance

josevalim commented 3 years ago

We can definitely add a telemetry event for that. And likely one for when connections are established too.

polvalente commented 3 years ago

@josevalim Cool! Can I help in any way?

polvalente commented 3 years ago

@josevalim I was reading #228 and maybe adding another message for timeouts could also be a way to handle this. What do you think?

josevalim commented 3 years ago

That also sounds good to me! PRs are welcome!

polvalente commented 3 years ago

That also sounds good to me! PRs are welcome!

Ok then! I'll try to come up with something

polvalente commented 3 years ago

Resolved in #236