Class: StatsdTaggable::Client
- Inherits:
-
Object
- Object
- StatsdTaggable::Client
- Extended by:
- Forwardable
- Defined in:
- lib/statsd-opentsdb-client/statsd_taggable.rb
Instance Method Summary collapse
- #count_with_tags(metric, count, tags, sample_rate = 1) ⇒ Object
- #decrement_with_tags(metric, tags, sample_rate = 1) ⇒ Object
- #gauge_with_tags(metric, value, tags, sample_rate = 1) ⇒ Object
- #increment_with_tags(metric, tags, sample_rate = 1) ⇒ Object
-
#initialize(config) ⇒ Client
constructor
A new instance of Client.
- #set_with_tags(metric, value, tags, sample_rate = 1) ⇒ Object
- #time_with_tags(metric, tags, sample_rate = 1, &block) ⇒ Object
- #timing_with_tags(metric, tim, tags, sample_rate = 1) ⇒ Object
Constructor Details
#initialize(config) ⇒ Client
Returns a new instance of Client.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/statsd-opentsdb-client/statsd_taggable.rb', line 8 def initialize(config) @host = config[:host] || 'localhost' @port = (config[:port] || 8125).to_i @app_name = config[:app_name] || "my_app" @tag_prefix = config[:tag_prefix] || '_t_' @hostname = `hostname`.split(".").first @client = Statsd.new(@host, @port) if config.include? :logger Statsd.logger = config[:logger] end @default_tags = { 'host' => @hostname, 'app' => @app_name } end |
Instance Method Details
#count_with_tags(metric, count, tags, sample_rate = 1) ⇒ Object
37 38 39 |
# File 'lib/statsd-opentsdb-client/statsd_taggable.rb', line 37 def (metric, count, , sample_rate = 1) with_tagged_name(metric, ) { |new_metric_name| @client.count(new_metric_name, count, sample_rate) } end |
#decrement_with_tags(metric, tags, sample_rate = 1) ⇒ Object
33 34 35 |
# File 'lib/statsd-opentsdb-client/statsd_taggable.rb', line 33 def (metric, , sample_rate = 1) with_tagged_name(metric, ) { |new_metric_name| @client.decrement(new_metric_name, sample_rate) } end |
#gauge_with_tags(metric, value, tags, sample_rate = 1) ⇒ Object
25 26 27 |
# File 'lib/statsd-opentsdb-client/statsd_taggable.rb', line 25 def (metric, value, , sample_rate = 1) with_tagged_name(metric, ) { |new_metric_name| @client.gauge(new_metric_name, *[value, sample_rate]) } end |
#increment_with_tags(metric, tags, sample_rate = 1) ⇒ Object
29 30 31 |
# File 'lib/statsd-opentsdb-client/statsd_taggable.rb', line 29 def (metric, , sample_rate = 1) with_tagged_name(metric, ) { |new_metric_name| @client.increment(new_metric_name, sample_rate) } end |
#set_with_tags(metric, value, tags, sample_rate = 1) ⇒ Object
41 42 43 |
# File 'lib/statsd-opentsdb-client/statsd_taggable.rb', line 41 def (metric, value, , sample_rate = 1) with_tagged_name(metric, ) { |new_metric_name| @client.set(new_metric_name, value, sample_rate) } end |
#time_with_tags(metric, tags, sample_rate = 1, &block) ⇒ Object
49 50 51 |
# File 'lib/statsd-opentsdb-client/statsd_taggable.rb', line 49 def (metric, , sample_rate = 1, &block) with_tagged_name(metric, ) { |new_metric_name| @client.time(new_metric_name, sample_rate, &block) } end |
#timing_with_tags(metric, tim, tags, sample_rate = 1) ⇒ Object
45 46 47 |
# File 'lib/statsd-opentsdb-client/statsd_taggable.rb', line 45 def (metric, tim, , sample_rate = 1) with_tagged_name(metric, ) { |new_metric_name| @client.timing(new_metric_name, tim, sample_rate) } end |