dogstatsd-ruby 0.4.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.md +72 -0
  2. data/lib/statsd.rb +19 -6
  3. metadata +4 -4
  4. data/README.rdoc +0 -36
data/README.md ADDED
@@ -0,0 +1,72 @@
1
+
2
+ dogstatsd-ruby
3
+ ==============
4
+
5
+ A client for DogStatsd, an extension of the Statsd metric server for Datadog.
6
+
7
+ [![Build Status](https://secure.travis-ci.org/DataDog/dogstatsd-ruby.png)](http://travis-ci.org/DataDog/dogstatsd-ruby)
8
+
9
+ Quick Start Guide
10
+ -----------------
11
+
12
+ First install the library:
13
+
14
+ gem install dogstatsd-ruby
15
+
16
+ Then start instrumenting your code:
17
+
18
+ # Load the dogstats module.
19
+ require 'statsd'
20
+
21
+ # Create a stats instance.
22
+ statsd = Statsd.new('localhost', 8125)
23
+
24
+ # Increment a counter.
25
+ statsd.increment('page.views')
26
+
27
+ # Record a gauge 50% of the time.
28
+ statsd.gauge('users.online', 123, :sample_rate=>0.5)
29
+
30
+ # Sample a histogram
31
+ statsd.histogram('file.upload.size', 1234)
32
+
33
+ # Time a block of code
34
+ statsd.time('page.render') do
35
+ render_page('home.html')
36
+ end
37
+
38
+ # Tag a metric.
39
+ statsd.histogram('query.time', 10, :tags => ["version:1"])
40
+
41
+ Documentation
42
+ -------------
43
+
44
+ Full API documentation is available
45
+ [here](http://www.rubydoc.info/github/DataDog/dogstatsd-ruby/master/frames).
46
+
47
+
48
+ Feedback
49
+ --------
50
+
51
+ To suggest a feature, report a bug, or general discussion, head over
52
+ [here](http://github.com/DataDog/dogstatsd-ruby/issues/).
53
+
54
+
55
+ Change Log
56
+ ----------
57
+
58
+
59
+ - 1.1.0
60
+ - Added `sets` metrics.
61
+ - 1.0.0
62
+ - Initial release.
63
+
64
+
65
+ Credits
66
+ -------
67
+
68
+ dogstatsd-ruby is forked from Rien Henrichs [original Statsd
69
+ client](https://github.com/reinh/statsd).
70
+
71
+ Copyright (c) 2011 Rein Henrichs. See LICENSE.txt for
72
+ further details.
data/lib/statsd.rb CHANGED
@@ -1,13 +1,14 @@
1
1
  require 'socket'
2
2
 
3
- # = Statsd: A Statsd client (https://github.com/etsy/statsd)
3
+ # = Statsd: A DogStatsd client (https://www.datadoghq.com)
4
4
  #
5
- # @example Set up a global Statsd client for a server on localhost:9125
5
+ # @example Set up a global Statsd client for a server on localhost:8125
6
+ # require 'statsd'
6
7
  # $statsd = Statsd.new 'localhost', 8125
7
8
  # @example Send some stats
8
- # $statsd.increment 'garets'
9
- # $statsd.timing 'glork', 320
10
- # $statsd.gauge 'bork', 100
9
+ # $statsd.increment 'page.views'
10
+ # $statsd.timing 'page.load', 320
11
+ # $statsd.gauge 'users.online', 100
11
12
  # @example Use {#time} to time the execution of a block
12
13
  # $statsd.time('account.activate') { @account.activate! }
13
14
  # @example Create a namespaced statsd client and increment 'account.activate'
@@ -30,7 +31,7 @@ class Statsd
30
31
 
31
32
  # Return the current version of the library.
32
33
  def self.VERSION
33
- "0.4.0"
34
+ "1.1.0"
34
35
  end
35
36
 
36
37
  # @param [String] host your statsd host
@@ -147,6 +148,18 @@ class Statsd
147
148
  timing(stat, ((Time.now - start) * 1000).round, opts)
148
149
  result
149
150
  end
151
+ # Sends a value to be tracked as a set to the statsd server.
152
+ #
153
+ # @param [String] stat stat name.
154
+ # @param [Numeric] set value.
155
+ # @param [Hash] opts the options to create the metric with
156
+ # @option opts [Numeric] :sample_rate sample rate, 1 for always
157
+ # @option opts [Array<String>] :tags An array of tags
158
+ # @example Record a unique visitory by id:
159
+ # $statsd.set('visitors.uniques', User.id)
160
+ def set(stat, value, opts={})
161
+ send_stats stat, value, :s, opts
162
+ end
150
163
 
151
164
  private
152
165
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dogstatsd-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-14 00:00:00.000000000 Z
12
+ date: 2012-09-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
@@ -81,10 +81,10 @@ executables: []
81
81
  extensions: []
82
82
  extra_rdoc_files:
83
83
  - LICENSE.txt
84
- - README.rdoc
84
+ - README.md
85
85
  files:
86
86
  - LICENSE.txt
87
- - README.rdoc
87
+ - README.md
88
88
  - lib/statsd.rb
89
89
  homepage: http://github.com/datadog/dogstatsd-ruby
90
90
  licenses:
data/README.rdoc DELETED
@@ -1,36 +0,0 @@
1
- = dogstatsd-ruby {<img src="https://secure.travis-ci.org/DataDog/dogstatsd-ruby.png"/>}[http://travis-ci.org/DataDog/dogstatsd-ruby]
2
-
3
- A Ruby client for DogStatsd, a fork of {Statsd}[https://github.com/etsy/statsd]
4
- for Datadog. It will work fine for Statsd, but the extra Datadog features will
5
- not work.
6
-
7
- = Installing
8
-
9
- Bundler:
10
- gem 'dogstatsd-ruby', '~> 0.4.0', github: 'datadog/dogstatsd-ruby', require: 'statsd'
11
-
12
- = Testing
13
-
14
- Run the specs with <tt>rake spec</tt>
15
-
16
- Run the specs and include live integration specs with <tt>LIVE=true rake spec</tt>. Note: This will test over a real UDP socket.
17
-
18
- == Contributing to statsd
19
-
20
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
21
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
22
- * Fork the project
23
- * Start a feature/bugfix branch
24
- * Commit and push until you are happy with your contribution
25
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
26
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
27
-
28
- == Contributors
29
-
30
- * Rein Henrichs
31
- * Ray Krueger
32
-
33
- == Copyright
34
-
35
- Copyright (c) 2011 Rein Henrichs. See LICENSE.txt for
36
- further details.