@@ -10,18 +10,25 @@ defmodule DBConnection.TelemetryListener do
10
10
Start the listener, and pass it under the `:connection_listeners` option when
11
11
starting DBConnection:
12
12
13
- {:ok, pid} = TelemetryListener.start_link()
13
+ {:ok, pid} = DBConnection. TelemetryListener.start_link()
14
14
{:ok, _conn} = DBConnection.start_link(SomeModule, connection_listeners: [pid])
15
15
16
16
# Using a tag, which will be sent in telemetry metadata
17
17
{:ok, _conn} = DBConnection.start_link(SomeModule, connection_listeners: {[pid], :my_tag})
18
18
19
19
# Or, with a Supervisor:
20
20
Supervisor.start_link([
21
- {TelemetryListener, [ name: MyListener] },
21
+ {DBConnection. TelemetryListener, name: MyListener},
22
22
DBConnection.child_spec(SomeModule, connection_listeners: {[MyListener], :my_tag})
23
23
])
24
24
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
+ ])
25
32
26
33
## Telemetry events
27
34
0 commit comments