jackc / pgx

PostgreSQL driver and toolkit for Go
MIT License
10.67k stars 837 forks source link

Feature request: support for adding instrumentation/APM #652

Open bnkamalesh opened 4 years ago

bnkamalesh commented 4 years ago

Provision of adding instrumentation to pgx/v4/pgxpool. Right now, when using pgxpool, instrumentation has to be manually added, record errors etc. I glanced through the pgxpool sourcecode, though couldn't find any relevant interfaces or structs where I could plug in instrumentation. I think it would be awesome to have provision of adding it, as any production ready system at a decent scale would make use of monitoring.

E.g. https://www.elastic.co/guide/en/apm/agent/go/current/instrumenting-source.html#builtin-modules-apmsql

jackc commented 4 years ago

Would wrapping the relevant pgxpool structs do what you want? pgxpool was specifically designed in a composable fashion. I suspect that a wrapper around pgxpool.Pool, pgxpool.Conn, and possibly pgxpool.Tx could do it.

bnkamalesh commented 4 years ago

@jackc Yes I believe it would help. I don't know if it already exists, I will have to spend some more time going through the code figure out. Thanks for the help!

P.S: it's an awesome package nevertheless