@@ -6,6 +6,7 @@ defmodule DBConnection.Connection do
66 require Logger
77 alias DBConnection.Backoff
88 alias DBConnection.Holder
9+ alias DBConnection.Util
910
1011 @ timeout 15_000
1112
@@ -47,6 +48,10 @@ defmodule DBConnection.Connection do
4748 @ doc false
4849 @ impl :gen_statem
4950 def init ( { mod , opts , pool , tag } ) do
51+ pool_index = Keyword . get ( opts , :pool_index )
52+ label = if pool_index , do: "db_conn_#{ pool_index } " , else: "db_conn"
53+ Util . set_label ( label )
54+
5055 s = % {
5156 mod: mod ,
5257 opts: opts ,
@@ -267,15 +272,19 @@ defmodule DBConnection.Connection do
267272 :no_state ,
268273 % { client: { ref , :after_connect } } = s
269274 ) do
270- message = "client #{ inspect ( pid ) } exited: " <> Exception . format_exit ( reason )
275+ message =
276+ "client #{ Util . inspect_pid ( pid ) } exited: " <> Exception . format_exit ( reason )
277+
271278 err = DBConnection.ConnectionError . exception ( message )
272279
273280 { :keep_state , % { s | client: { nil , :after_connect } } ,
274281 { :next_event , :internal , { :disconnect , { down_log ( reason ) , err } } } }
275282 end
276283
277284 def handle_event ( :info , { :DOWN , mon , _ , pid , reason } , :no_state , % { client: { ref , mon } } = s ) do
278- message = "client #{ inspect ( pid ) } exited: " <> Exception . format_exit ( reason )
285+ message =
286+ "client #{ Util . inspect_pid ( pid ) } exited: " <> Exception . format_exit ( reason )
287+
279288 err = DBConnection.ConnectionError . exception ( message )
280289
281290 { :keep_state , % { s | client: { ref , nil } } ,
@@ -290,14 +299,14 @@ defmodule DBConnection.Connection do
290299 )
291300 when is_reference ( timer ) do
292301 message =
293- "client #{ inspect ( pid ) } timed out because it checked out " <>
302+ "client #{ Util . inspect_pid ( pid ) } timed out because it checked out " <>
294303 "the connection for longer than #{ timeout } ms"
295304
296305 exc =
297306 case Process . info ( pid , :current_stacktrace ) do
298307 { :current_stacktrace , stacktrace } ->
299308 message <>
300- "\n \n #{ inspect ( pid ) } was at location:\n \n " <>
309+ "\n \n #{ Util . inspect_pid ( pid ) } was at location:\n \n " <>
301310 Exception . format_stacktrace ( stacktrace )
302311
303312 _ ->
0 commit comments