You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[receiver/sqlqueryreceiver] Use one connection pool per receiver (open-telemetry#39312)
#### Description
Rather than creating a separate `*sql.DB` provider function for each
query, this creates one provider for the receiver and passes a method
value to each query. The method uses a mutex to ensure exactly one
`*sql.DB` is created when it is called concurrently.
The `max_open_conn` config is defined in `sqlqueryreceiver`, so I put
the implementation in its `internal` package.
#### Link to tracking issue
Fixesopen-telemetry#39270
#### Testing
Using the configuration and steps in open-telemetry#39270, I see only one connection
to Postgres:
```console
$ psql -h localhost -U postgres -c 'SELECT pid, backend_type, datname, usename, query, state FROM pg_stat_activity'
┌─────┬──────────────────────────────┬──────────┬──────────┬────────────────────────────────────────────────────────────────────────────────┬────────┐
│ pid │ backend_type │ datname │ usename │ query │ state │
├─────┼──────────────────────────────┼──────────┼──────────┼────────────────────────────────────────────────────────────────────────────────┼────────┤
│ 68 │ client backend │ postgres │ postgres │ SELECT 3 AS number │ idle │
│ 70 │ client backend │ postgres │ postgres │ SELECT pid, backend_type, datname, usename, query, state FROM pg_stat_activity │ active │
│ 65 │ autovacuum launcher │ ␀ │ ␀ │ │ ␀ │
│ 66 │ logical replication launcher │ ␀ │ postgres │ │ ␀ │
│ 61 │ checkpointer │ ␀ │ ␀ │ │ ␀ │
│ 62 │ background writer │ ␀ │ ␀ │ │ ␀ │
│ 64 │ walwriter │ ␀ │ ␀ │ │ ␀ │
└─────┴──────────────────────────────┴──────────┴──────────┴────────────────────────────────────────────────────────────────────────────────┴────────┘
(7 rows)
```
Signed-off-by: Chris Bandy <[email protected]>
0 commit comments