Module: Dashboarder::Instrument

Defined in:
lib/dashboarder/instrument.rb

Class Method Summary collapse

Class Method Details

.compose(definition) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/dashboarder/instrument.rb', line 15

def self.compose(definition)
  name = definition.first
  instrument = get(name)

  unless instrument
    instrument = compose!(definition)  
  end
  instrument
end

.compose!(definition) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/dashboarder/instrument.rb', line 7

def self.compose!(definition)
  name = definition.first
  metric_names = definition[1..-1]

  streams = metric_names.map { |n| { :metric => n, :source => '*' } }
  Dashboarder.api.post('/v1/instruments', { :name => name, :streams => streams })
end

.get(name) ⇒ Object



3
4
5
# File 'lib/dashboarder/instrument.rb', line 3

def self.get(name)
  Dashboarder.api.get('/v1/instruments', :query => {:name => name})['instruments'].first
end