StatHat::Json
StatHat JSON API Client.
Installation
Add this line to your application's Gemfile:
gem 'stathat-json'
And then execute:
$ bundle
Or install it yourself as:
$ gem install stathat-json
Usage
Batch post stats
require 'stathat/json'
StatHat::Json::Api.ez_key = 'YOUR_EZ_KEY' # will also be picked up from ENV['STATHAT_EZKEY']
stats = []
stats << {stat: 'count_stat1'} # implicit count and time
stats << {stat: 'count_stat2', count: 2, t: 1420428506} # explicit count and time
stats << {stat: 'value_stat1', value: 3.14159} # delicious Pi
StatHat::Json::Api.post_stats(stats)
Post individual stats
require 'stathat/json'
StatHat::Json::Api.ez_key = 'YOUR_EZ_KEY' # will also be picked up from ENV['STATHAT_EZKEY']
StatHat::Json::Api.post_count('count_stat1') # implicit count and time
StatHat::Json::Api.post_count('count_stat2', 2, 1420428506) # explicit count and time
StatHat::Json::Api.post_value('value_stat1', 3.14159) # delicious Pi
Short lived processes
StatHat::Json::Api
uses Celluloid::IO for threading and async network IO for long runing processes.
Use StatHat::Json::SyncApi
for short lived processes, the API is identical.
Tested with the following Rubies
- 1.9.3
- 2.0.0
- 2.1.0
- rbx-2.2.10
- jruby-19mode
- ruby-head
- jruby-head
Contributing
- Fork it ( https://github.com/[my-github-username]/stathat-json/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request