class HostedGraphite::Protocol

Constants

API_URI
HOST
PORT

Public Instance Methods

api_key() click to toggle source
# File lib/hosted_graphite/protocol.rb, line 9
def api_key
  HostedGraphite.api_key
end
send_metric(name, value, timestamp = nil) click to toggle source
# File lib/hosted_graphite/protocol.rb, line 13
def send_metric(name, value, timestamp = nil)
  raise MissingAPIKey unless api_key
  send_message(build_message(name, value, timestamp))
rescue MissingAPIKey => e
  raise e
rescue => e
  # set HOSTEDGRAPHITE_DEBUG to to raise errors instead of silencing them.
  raise e if ENV['HOSTEDGRAPHITE_DEBUG']
  0
end

Private Instance Methods

build_message(name, value, timestamp = nil) click to toggle source
# File lib/hosted_graphite/protocol.rb, line 26
def build_message(name, value, timestamp = nil)
  unless timestamp
    return [name, value].join ' '
  end

  [name, value, timestamp].join ' '
end