Class: Vitals::Formats::HostLastFormat
- Inherits:
-
Object
- Object
- Vitals::Formats::HostLastFormat
- Defined in:
- lib/vitals/formats/host_last_format.rb
Instance Attribute Summary collapse
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#facility ⇒ Object
Returns the value of attribute facility.
-
#host ⇒ Object
Returns the value of attribute host.
Instance Method Summary collapse
- #format(m) ⇒ Object
-
#initialize(environment: 'development', facility: 'default', host: 'localhost') ⇒ HostLastFormat
constructor
A new instance of HostLastFormat.
Constructor Details
#initialize(environment: 'development', facility: 'default', host: 'localhost') ⇒ HostLastFormat
Returns a new instance of HostLastFormat.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/vitals/formats/host_last_format.rb', line 7 def initialize(environment:'development', facility:'default', host:'localhost') @environment = environment @facility = facility @host = host @host = Vitals::Utils.normalize_metric(host).freeze if @host @prefix = [environment, facility].compact.map{|m| Vitals::Utils.normalize_metric(m) } .join(Vitals::Utils::SEPARATOR).freeze @prefix_with_host = [environment, facility, @host].compact.map{|m| Vitals::Utils.normalize_metric(m) } .join(Vitals::Utils::SEPARATOR).freeze end |
Instance Attribute Details
#environment ⇒ Object
Returns the value of attribute environment.
3 4 5 |
# File 'lib/vitals/formats/host_last_format.rb', line 3 def environment @environment end |
#facility ⇒ Object
Returns the value of attribute facility.
5 6 7 |
# File 'lib/vitals/formats/host_last_format.rb', line 5 def facility @facility end |
#host ⇒ Object
Returns the value of attribute host.
4 5 6 |
# File 'lib/vitals/formats/host_last_format.rb', line 4 def host @host end |
Instance Method Details
#format(m) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/vitals/formats/host_last_format.rb', line 18 def format(m) return @prefix_with_host if (m.nil? || m.empty?) # TODO optimize by building a renderer function (inlining this) in the initializer. # see https://github.com/evanphx/benchmark-ips/blob/master/lib/benchmark/ips/job/entry.rb#L63 [@prefix, Vitals::Utils.normalize_metric(m), @host].reject{|s| s.nil? || s.empty? }.join(Vitals::Utils::SEPARATOR) end |