Class: DasboardClient
- Inherits:
-
Object
- Object
- DasboardClient
- Defined in:
- lib/dasboard_client.rb
Class Method Summary collapse
Class Method Details
.load_config ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/dasboard_client.rb', line 6 def self.load_config begin config_location = Rails.root.join('config/dasboard.yml') @@config = YAML.load_file(config_location)[Rails.env] rescue Exception => err puts config_location throw Exception.new("Error loading DasBoard config from #{config_location}: #{err.}") end end |
.post_stat(metric_name, value, date = Time.now) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/dasboard_client.rb', line 16 def self.post_stat(metric_name, value, date = Time.now) metric_id = @@config["metrics"][metric_name.to_s] url = "#{@@config["instance"]}/metrics/#{metric_id}/data" data = { data: { date: date.to_i, value: value } } puts `curl -X POST -H "Content-Type: application/json" -d \ '#{data.to_json}' #{url}` end |