Skip to content

set PostgreSQL connection variable "application_name" on ActiveRecord connection.

License

Notifications You must be signed in to change notification settings

dembskoi/pg_application_name

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pg_application_name
===================

Sets the postgres connection variable "application_name" an ActiveRecord connections.


By default all ActiveRecord connections will be stamped with the
Rails application name and its process id, as:

    throttle_development=# \x
    Expanded display is on.
    rails_development=# select * from pg_stat_activity;
    -[ RECORD 1 ]----+--------------------------------
    datid            | 107874
    datname          | rails_development
    procpid          | 56598
    usesysid         | 16384
    usename          | postgres
    application_name | Example::Application/56587
    client_addr      | 127.0.0.1
    client_hostname  | 
    client_port      | 59444
    backend_start    | 2012-09-14 15:39:07.177778+00
    xact_start       | 
    query_start      | 2012-09-14 15:39:07.181641+00
    waiting          | f
    current_query    | <IDLE>

The application name can be set:

  ActiveRecord::Base.connection.
    set_server_application_name("#{Rails.application.class.name}-8.0.5/pid=#{Process.pid}")

About

set PostgreSQL connection variable "application_name" on ActiveRecord connection.

Resources

License

Stars

Watchers

Forks

Packages

No packages published