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

Constructor Details

#initializeProtocol

Returns a new instance of Protocol.



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

def initialize
  fail MissingAPIKey unless HostedGraphite.api_key
  @api_key = HostedGraphite.api_key
end

Instance Method Details

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



14
15
16
17
18
19
20
# File 'lib/hosted_graphite/protocol.rb', line 14

def send_metric(name, value, timestamp = nil)
  send_message(build_message(name, value, timestamp))
rescue => e
  # set HOSTEDGRAPHITE_DEBUG to to raise errors instead of silencing them.
  raise e if ENV['HOSTEDGRAPHITE_DEBUG']
  0
end