Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional Application Name to Postgres Connection Info #228

Open
neilt opened this issue Mar 11, 2022 · 3 comments
Open

Add optional Application Name to Postgres Connection Info #228

neilt opened this issue Mar 11, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@neilt
Copy link

neilt commented Mar 11, 2022

Is your feature request related to a problem? Please describe.
Our problem is how to determine which of our applications is causing problems by observing the Postgres database connections in the Postgres Server.

Describe the solution you'd like
We have multiple applications connecting to the Postgres database and would like to be able to differentiate connections between our various applications. Traditionally, we have used the application name. We would like to be able to optionally specify the application name in PostgresConfiguration.

Describe alternatives you've considered
Any solution would work as long as we can determine which application is connected to which pids in the Postgres server.

We thought about just using SET application_name = 'test_activity'; after the connection is established, but could not figure out how to get this set in all connections from the pool in all threads.

Additional context
None.

@neilt neilt added the enhancement New feature or request label Mar 11, 2022
@fabianfett
Copy link

I think this is an issue for PostgresKit. @gwynne?

@neilt
Copy link
Author

neilt commented Mar 12, 2022

Yes it does apply to PostgresKit. Sorry about that, I should have caught it. Our intent at this point was to be using postgres-nio, but we are experimenting with postgres-kit and it seems we've co-mingled the code.

But I looked at PSQLConnection.Configuration and there is no way to set application_name here during the connection either.

Should I move or add this issue to PostgresKit. It seems they are related.

@fabianfett
Copy link

Yes. The problem you are describing can be resolved with a custom Source when using the AsyncKit EventLoopGroupConnectionPool.

https://github.com/vapor/async-kit/blob/main/Sources/AsyncKit/ConnectionPool/EventLoopGroupConnectionPool.swift

I guess just reask your question in PostgresKit again and @gwynne can probably help you out there.

@0xTim 0xTim transferred this issue from vapor/postgres-nio Jun 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants