Class: HostedGraphite::Protocol

Inherits:
Object
  • Object
show all
Defined in:
lib/hosted_graphite/protocol.rb

Direct Known Subclasses

HTTP, TCP, UDP

Constant Summary collapse

HOST =
'carbon.hostedgraphite.com'.freeze
API_URI =
'https://hostedgraphite.com/api/v1/sink'.freeze
PORT =
2003.freeze

Instance Method Summary collapse

Instance Method Details

#api_keyObject



9
10
11
# File 'lib/hosted_graphite/protocol.rb', line 9

def api_key
  HostedGraphite.api_key
end

#send_metric(name, value, timestamp = nil) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# 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