Class: PMetric::Configuration
- Inherits:
-
Object
- Object
- PMetric::Configuration
- Defined in:
- lib/pmetric/configuration.rb
Instance Attribute Summary collapse
-
#async ⇒ Object
Returns the value of attribute async.
-
#collector ⇒ Object
Returns the value of attribute collector.
-
#database ⇒ Object
Returns the value of attribute database.
-
#default_tags ⇒ Object
Returns the value of attribute default_tags.
-
#host ⇒ Object
Returns the value of attribute host.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#password ⇒ Object
Returns the value of attribute password.
-
#port ⇒ Object
Returns the value of attribute port.
-
#retry ⇒ Object
Returns the value of attribute retry.
-
#time_precision ⇒ Object
Returns the value of attribute time_precision.
-
#udp_host ⇒ Object
Returns the value of attribute udp_host.
-
#udp_port ⇒ Object
Returns the value of attribute udp_port.
-
#use_ssl ⇒ Object
Returns the value of attribute use_ssl.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
-
#client_opts ⇒ Hash
Builds client options for the PMetric::Collector::Influx collector.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/pmetric/configuration.rb', line 19 def initialize @host = ENV.fetch('INFLUXDB_HOST', 'influxdb.500friends.com'.freeze) @port = ENV.fetch('INFLUXDB_PORT', 8086) @username = ENV.fetch('INFLUXDB_USERNAME', nil) @password = ENV.fetch('INFLUXDB_PASSWORD', nil) @database = ENV.fetch('INFLUXDB_DATABASE', 'prism'.freeze) @time_precision = 'ns'.freeze @retry = 10 @use_ssl = false # Logging is off by default @logger = false # PMetric must be intentionally enabled @collector = :noop # Async options @async = { # InfluxDB async writer uses a custom ruby Queue to keep track of # pending points, and this specifies the max number of items the queue # will allow. Anything greater will just drop off. max_queue_size: 10_000, # Number of post points to write at once. For a full queue with a max # size of 10_000, and a max post points of 1_000, it will take 10 batch # calls to post all the data. max_post_points: 1_000, # Number of Threads emptying the async queue. This will be per-process, # as the collector is shared globally. num_worker_threads: 2, # Time each thread waits to check for new points. The InfluxDB client # will actually sleep at `rand(sleep_interval)`, fyi. sleep_interval: 5 } # Default to no udp_port. Setting udp_port && udp_host enables UDP on. @udp_host = ENV.fetch('INFLUXDB_UDP_HOST', @host) @udp_port = ENV.fetch('INFLUXDB_UDP_PORT', nil) # Default Event Tags = nil end |
Instance Attribute Details
#async ⇒ Object
Returns the value of attribute async.
3 4 5 |
# File 'lib/pmetric/configuration.rb', line 3 def async @async end |
#collector ⇒ Object
Returns the value of attribute collector.
3 4 5 |
# File 'lib/pmetric/configuration.rb', line 3 def collector @collector end |
#database ⇒ Object
Returns the value of attribute database.
3 4 5 |
# File 'lib/pmetric/configuration.rb', line 3 def database @database end |
#default_tags ⇒ Object
Returns the value of attribute default_tags.
3 4 5 |
# File 'lib/pmetric/configuration.rb', line 3 def end |
#host ⇒ Object
Returns the value of attribute host.
3 4 5 |
# File 'lib/pmetric/configuration.rb', line 3 def host @host end |
#logger ⇒ Object
Returns the value of attribute logger.
3 4 5 |
# File 'lib/pmetric/configuration.rb', line 3 def logger @logger end |
#password ⇒ Object
Returns the value of attribute password.
3 4 5 |
# File 'lib/pmetric/configuration.rb', line 3 def password @password end |
#port ⇒ Object
Returns the value of attribute port.
3 4 5 |
# File 'lib/pmetric/configuration.rb', line 3 def port @port end |
#retry ⇒ Object
Returns the value of attribute retry.
3 4 5 |
# File 'lib/pmetric/configuration.rb', line 3 def retry @retry end |
#time_precision ⇒ Object
Returns the value of attribute time_precision.
3 4 5 |
# File 'lib/pmetric/configuration.rb', line 3 def time_precision @time_precision end |
#udp_host ⇒ Object
Returns the value of attribute udp_host.
3 4 5 |
# File 'lib/pmetric/configuration.rb', line 3 def udp_host @udp_host end |
#udp_port ⇒ Object
Returns the value of attribute udp_port.
3 4 5 |
# File 'lib/pmetric/configuration.rb', line 3 def udp_port @udp_port end |
#use_ssl ⇒ Object
Returns the value of attribute use_ssl.
3 4 5 |
# File 'lib/pmetric/configuration.rb', line 3 def use_ssl @use_ssl end |
#username ⇒ Object
Returns the value of attribute username.
3 4 5 |
# File 'lib/pmetric/configuration.rb', line 3 def username @username end |
Instance Method Details
#client_opts ⇒ Hash
Builds client options for the PMetric::Collector::Influx collector.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/pmetric/configuration.rb', line 68 def client_opts opts = { host: @host, port: @port, database: @database, time_precision: @time_precision, retry: @retry } opts[:username] = @username if @username opts[:password] = @password if @password if @use_ssl opts[:use_ssl] = true opts[:verify_ssl] = true end if @udp_host && @udp_port opts[:udp] = { host: @udp_host, port: @udp_port } opts[:async] = false else opts[:async] = @async || false end opts end |