@@ -10,18 +10,25 @@ defmodule DBConnection.TelemetryListener do
1010 Start the listener, and pass it under the `:connection_listeners` option when
1111 starting DBConnection:
1212
13- {:ok, pid} = TelemetryListener.start_link()
13+ {:ok, pid} = DBConnection. TelemetryListener.start_link()
1414 {:ok, _conn} = DBConnection.start_link(SomeModule, connection_listeners: [pid])
1515
1616 # Using a tag, which will be sent in telemetry metadata
1717 {:ok, _conn} = DBConnection.start_link(SomeModule, connection_listeners: {[pid], :my_tag})
1818
1919 # Or, with a Supervisor:
2020 Supervisor.start_link([
21- {TelemetryListener, [ name: MyListener] },
21+ {DBConnection. TelemetryListener, name: MyListener},
2222 DBConnection.child_spec(SomeModule, connection_listeners: {[MyListener], :my_tag})
2323 ])
2424
25+ When using with Ecto, you can pass the `connection_listeners` option to Ecto, and we
26+ recommend passing the repository as the tag. In your supervision tree:
27+
28+ Supervisor.start_link([
29+ {DBConnection.TelemetryListener, name: MyApp.DBListener},
30+ {MyApp.Repo, connection_listeners: {[MyApp.DBListener], MyApp.Repo})
31+ ])
2532
2633 ## Telemetry events
2734
0 commit comments