lib/harness/adapters/librato_adapter.rb in harness-0.3.0 vs lib/harness/adapters/librato_adapter.rb in harness-0.4.0
- old
+ new
@@ -10,11 +10,11 @@
def self.config
@config ||= Config.new
end
- def self.log_gauge(gauge)
+ def log_gauge(gauge)
raise Harness::LoggingError if gauge.id.length > 63
post({:gauges => [{
:name => sanitize(gauge.id),
:display_name => gauge.name,
@@ -23,11 +23,11 @@
:source => gauge.source,
:attributes => { :display_units_short => gauge.units }
}]})
end
- def self.log_counter(counter)
+ def log_counter(counter)
raise Harness::LoggingError if counter.id.length > 63
post({:counters => [{
:name => sanitize(counter.id),
:display_name => counter.name,
@@ -37,11 +37,11 @@
:attributes => { :display_units_short => counter.units }
}]})
end
private
- def self.post(params)
+ def post(params)
unless config.email && config.token
raise "Adapter not configured. Ensure email and token are set."
end
uri = URI.parse('https://metrics-api.librato.com/v1/metrics')
@@ -66,10 +66,14 @@
end
true
end
- def self.sanitize(name)
+ def config
+ self.class.config
+ end
+
+ def sanitize(name)
if Harness.config.namespace
key = "#{name}.#{Harness.config.namespace}"
else
key = name
end