Class: PgConnectionCounter::Counter

Inherits:
Object
  • Object
show all
Defined in:
app/models/pg_connection_counter/counter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCounter

Returns a new instance of Counter.



5
6
7
# File 'app/models/pg_connection_counter/counter.rb', line 5

def initialize
  @logger = []
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



3
4
5
# File 'app/models/pg_connection_counter/counter.rb', line 3

def logger
  @logger
end

Instance Method Details

#displayObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/models/pg_connection_counter/counter.rb', line 9

def display
  log "=="*30
  log "Number of connections allowed by Active Record per application: #{active_record_limit_of_number_of_db_connections_per_application}"
  log "Number of connections to the database: #{number_of_connections_to_db} "
  pg_stat_activities.each do |record|
    log "pid: #{record['pid']}, state: #{record['state']}"
    log "application_name: #{record['application_name']}"
    log "query: #{record['query']}"
    log ""
  end
  log "=="*30

  logger.each do |record|
    Rails.logger.info record
    puts record
  end
end