Closed mecampbellsoup closed 3 years ago
I see this param referenced here but I cannot see how to set its value in the initialized connection object:
pg_settings = {
host = ip,
port = '5432',
database = os.getenv('POSTGRES_DATABASE'),
user = os.getenv('POSTGRES_USERNAME'),
password = os.getenv('POSTGRES_PASSWORD'),
application_name = 'api-gateway',
socket_type = 'haproxy'
}
local pg = pgmoon.new(pg_settings)
However the connection is not named:
cloud-app=# select count(*) from pg_stat_activity where application_name = 'api-gateway';
count
-------
0
(1 row)
OK, update - when I drop in a SELECT pg_sleep(5);
and inspect the connections, I do see named connections but instead of being named to the value I try to set i.e. api-gateway
it seems hardcoded to simply pgmoon
:
cloud-app=# SELECT count(*), usename, application_name, state
FROM pg_stat_activity
GROUP BY usename, application_name, state
ORDER BY application_name
;
count | usename | application_name | state
-------+------------+-------------------------------------------------------------+--------
2 | apigateway | pgmoon | active
1 | postgres | psql | active
Is it possible to set
application_name
i.e. https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PARAMKEYWORDS: