Class: FFWD::Plugin::KairosDB::Hook
- Inherits:
-
FlushingOutputHook
- Object
- FlushingOutputHook
- FFWD::Plugin::KairosDB::Hook
- Defined in:
- lib/ffwd/plugin/kairosdb/hook.rb
Constant Summary collapse
- HEADER =
{ "Content-Type" => "application/json" }
- API_PATH =
"/api/v1/series"
Instance Method Summary collapse
- #active? ⇒ Boolean
- #close ⇒ Object
- #connect ⇒ Object
-
#initialize(url) ⇒ Hook
constructor
A new instance of Hook.
- #reporter_meta ⇒ Object
- #send(metrics) ⇒ Object
Constructor Details
#initialize(url) ⇒ Hook
Returns a new instance of Hook.
30 31 32 33 |
# File 'lib/ffwd/plugin/kairosdb/hook.rb', line 30 def initialize url @c = nil @url = url end |
Instance Method Details
#active? ⇒ Boolean
35 36 37 |
# File 'lib/ffwd/plugin/kairosdb/hook.rb', line 35 def active? not @c.nil? end |
#close ⇒ Object
43 44 45 46 |
# File 'lib/ffwd/plugin/kairosdb/hook.rb', line 43 def close @c.close @c = nil end |
#connect ⇒ Object
39 40 41 |
# File 'lib/ffwd/plugin/kairosdb/hook.rb', line 39 def connect @c = EM::HttpRequest.new(@url) end |
#reporter_meta ⇒ Object
54 55 56 |
# File 'lib/ffwd/plugin/kairosdb/hook.rb', line 54 def {:component => :datadog} end |
#send(metrics) ⇒ Object
48 49 50 51 52 |
# File 'lib/ffwd/plugin/kairosdb/hook.rb', line 48 def send metrics metrics = Utils.make_metrics(metrics) metrics = JSON.dump(metrics) @c.post(:path => API_PATH, :head => HEADER, :body => metrics) end |