set PostgreSQL connection variable "application_name" on ActiveRecord connection.
Ruby JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
spec
.gitignore
.rspec
Gemfile
Gemfile.lock
LICENSE
README
Rakefile
pg_application_name.gemspec

README

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}")