Module: Metricsd
- Defined in:
- lib/metricsd.rb,
lib/metricsd/client.rb,
lib/metricsd/version.rb
Overview
Pure Ruby client library for MetricsD server.
Defined Under Namespace
Classes: Client
Constant Summary collapse
- VERSION =
"0.2.6"
Class Method Summary collapse
-
.default_group ⇒ Object
Gets the default group for all metrics.
-
.default_group=(group) ⇒ Object
Sets the default group for all metrics.
-
.default_source ⇒ Object
Gets the default source for all metrics.
-
.default_source=(source) ⇒ Object
Sets the default source for all metrics.
-
.disable! ⇒ Object
Disables Metricsd client.
-
.enable! ⇒ Object
Enables Metricsd client.
-
.enabled=(enabled) ⇒ Object
Sets the value indicating whether Metricsd is enabled.
-
.enabled? ⇒ Boolean
(also: enabled)
Get the value indicating whether Metricsd is enabled.
-
.logger ⇒ Object
Gets the logger used to output errors or warnings.
-
.logger=(logger) ⇒ Object
Sets the logger used to output errors or warnings.
-
.reset_defaults! ⇒ Object
Resets all values to their default state (mostly for testing purpose).
-
.server_host ⇒ Object
Gets the MetricsD server host.
-
.server_host=(host) ⇒ Object
Sets the MetricsD server host.
-
.server_port ⇒ Object
Gets the MetricsD server port.
-
.server_port=(port) ⇒ Object
Sets the MetricsD server port.
-
.source ⇒ Object
Gets the source used to record host-specific metrics.
-
.source=(source) ⇒ Object
Sets the source for host-specific metrics.
Class Method Details
.default_group ⇒ Object
Gets the default group for all metrics.
76 77 78 |
# File 'lib/metricsd.rb', line 76 def default_group @@default_group end |
.default_group=(group) ⇒ Object
Sets the default group for all metrics.
81 82 83 |
# File 'lib/metricsd.rb', line 81 def default_group=(group) @@default_group = group end |
.default_source ⇒ Object
Gets the default source for all metrics. If nil or empty string — all metrics will be host-specific (MetricsD server will generate per-host graphs in addition to summary graph for all hosts for each metric). Default is “all”.
66 67 68 |
# File 'lib/metricsd.rb', line 66 def default_source @@default_source end |
.default_source=(source) ⇒ Object
Sets the default source for all metrics.
71 72 73 |
# File 'lib/metricsd.rb', line 71 def default_source=(source) @@default_source = source end |
.disable! ⇒ Object
Disables Metricsd client.
47 48 49 |
# File 'lib/metricsd.rb', line 47 def disable! @@enabled = false end |
.enable! ⇒ Object
Enables Metricsd client.
42 43 44 |
# File 'lib/metricsd.rb', line 42 def enable! @@enabled = true end |
.enabled=(enabled) ⇒ Object
Sets the value indicating whether Metricsd is enabled.
37 38 39 |
# File 'lib/metricsd.rb', line 37 def enabled=(enabled) @@enabled = !!enabled end |
.enabled? ⇒ Boolean Also known as: enabled
Get the value indicating whether Metricsd is enabled.
31 32 33 |
# File 'lib/metricsd.rb', line 31 def enabled? !!@@enabled end |
.logger ⇒ Object
Gets the logger used to output errors or warnings.
86 87 88 89 90 91 92 93 94 |
# File 'lib/metricsd.rb', line 86 def logger @@logger ||= if defined?(Rails) Rails.logger elsif defined?(Loops) Loops.logger else Logger.new(STDOUT) end end |
.logger=(logger) ⇒ Object
Sets the logger used to output errors or warnings.
97 98 99 |
# File 'lib/metricsd.rb', line 97 def logger=(logger) @@logger = logger end |
.reset_defaults! ⇒ Object
Resets all values to their default state (mostly for testing purpose).
102 103 104 105 106 107 108 109 110 |
# File 'lib/metricsd.rb', line 102 def reset_defaults! @@server_host = '127.0.0.1' @@server_port = 6311 @@enabled = true @@source = Socket.gethostname[/^([^.]+)/, 1] @@default_source = 'all' @@default_group = nil @@logger = nil end |
.server_host ⇒ Object
Gets the MetricsD server host. Default is “127.0.0.1”.
9 10 11 |
# File 'lib/metricsd.rb', line 9 def server_host @@server_host end |
.server_host=(host) ⇒ Object
Sets the MetricsD server host.
14 15 16 17 |
# File 'lib/metricsd.rb', line 14 def server_host=(host) @@server_host = host Client.reset_connection! end |
.server_port ⇒ Object
Gets the MetricsD server port. Default is 6311.
20 21 22 |
# File 'lib/metricsd.rb', line 20 def server_port @@server_port end |
.server_port=(port) ⇒ Object
Sets the MetricsD server port.
25 26 27 28 |
# File 'lib/metricsd.rb', line 25 def server_port=(port) @@server_port = Integer(port) Client.reset_connection! end |
.source ⇒ Object
Gets the source used to record host-specific metrics. Default is the first part of the hostname (e.g. “test” for “test.host.com”).
53 54 55 |
# File 'lib/metricsd.rb', line 53 def source @@source || metricsd.default_source end |
.source=(source) ⇒ Object
Sets the source for host-specific metrics.
58 59 60 |
# File 'lib/metricsd.rb', line 58 def source=(source) @@source = source end |