Class: InfluxDB::Metrics::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/influxdb/metrics/configuration.rb

Constant Summary collapse

EVENTS =
{
  action_controller: Controller,
  active_record: Model
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/influxdb/metrics/configuration.rb', line 27

def initialize
  @hosts      = []
  @app_name   = 'rails'
  @username   = 'root'
  @password   = 'root'
  @database   = 'rails'
  @port       = 8086
  @async      = true
  @debug      = false
  @events     = EVENTS.values
  @subscribed = []
end

Instance Attribute Details

#app_nameObject

Returns the value of attribute app_name.



16
17
18
# File 'lib/influxdb/metrics/configuration.rb', line 16

def app_name
  @app_name
end

#asyncObject

Returns the value of attribute async.



19
20
21
# File 'lib/influxdb/metrics/configuration.rb', line 19

def async
  @async
end

#clientObject



57
58
59
60
61
62
63
64
65
66
# File 'lib/influxdb/metrics/configuration.rb', line 57

def client
  @client ||= InfluxDB::Client.new(database,
    hosts: hosts,
    username: username,
    password: password,
    port: port,
    async: async,
    debug: debug
  )
end

#databaseObject

Returns the value of attribute database.



15
16
17
# File 'lib/influxdb/metrics/configuration.rb', line 15

def database
  @database
end

#debugObject

Returns the value of attribute debug.



18
19
20
# File 'lib/influxdb/metrics/configuration.rb', line 18

def debug
  @debug
end

#eventsObject

Returns the value of attribute events.



24
25
26
# File 'lib/influxdb/metrics/configuration.rb', line 24

def events
  @events
end

#hostsObject

Returns the value of attribute hosts.



12
13
14
# File 'lib/influxdb/metrics/configuration.rb', line 12

def hosts
  @hosts
end

#loggerObject

Returns the value of attribute logger.



23
24
25
# File 'lib/influxdb/metrics/configuration.rb', line 23

def logger
  @logger
end

#passwordObject

Returns the value of attribute password.



14
15
16
# File 'lib/influxdb/metrics/configuration.rb', line 14

def password
  @password
end

#portObject

Returns the value of attribute port.



17
18
19
# File 'lib/influxdb/metrics/configuration.rb', line 17

def port
  @port
end

#subscribedObject (readonly)

Returns the value of attribute subscribed.



25
26
27
# File 'lib/influxdb/metrics/configuration.rb', line 25

def subscribed
  @subscribed
end

#usernameObject

Returns the value of attribute username.



13
14
15
# File 'lib/influxdb/metrics/configuration.rb', line 13

def username
  @username
end

Instance Method Details

#host=(value) ⇒ Object



40
41
42
# File 'lib/influxdb/metrics/configuration.rb', line 40

def host=(value)
  hosts << value
end

#subscribeObject



51
52
53
54
55
# File 'lib/influxdb/metrics/configuration.rb', line 51

def subscribe
  @subscribed = events.map do |event|
    event.new.tap(&:subscribe)
  end
end