Module: StatsD

Defined in:
lib/statsd/instrument.rb,
lib/statsd/instrument/version.rb

Defined Under Namespace

Modules: Instrument

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.backendObject



127
128
129
# File 'lib/statsd/instrument.rb', line 127

def backend
  @backend ||= StatsD::Instrument::Environment.default_backend
end

.default_sample_rateObject

Returns the value of attribute default_sample_rate.



124
125
126
# File 'lib/statsd/instrument.rb', line 124

def default_sample_rate
  @default_sample_rate
end

.loggerObject

Returns the value of attribute logger.



124
125
126
# File 'lib/statsd/instrument.rb', line 124

def logger
  @logger
end

.prefixObject

Returns the value of attribute prefix.



124
125
126
# File 'lib/statsd/instrument.rb', line 124

def prefix
  @prefix
end

Class Method Details

.gauge(key, value, *metric_options) ⇒ Object

gaugor:333|g guagor:1234|kv|@1339864935 (statsite)



157
158
159
# File 'lib/statsd/instrument.rb', line 157

def gauge(key, value, *metric_options)
  collect_metric(hash_argument(metric_options).merge(type: :g, name: key, value: value))
end

.histogram(key, value, *metric_options) ⇒ Object

histogram:123.45|h



162
163
164
# File 'lib/statsd/instrument.rb', line 162

def histogram(key, value, *metric_options)
  collect_metric(hash_argument(metric_options).merge(type: :h, name: key, value: value))
end

.increment(key, value = 1, *metric_options) ⇒ Object

gorets:1|c



146
147
148
149
150
151
152
153
# File 'lib/statsd/instrument.rb', line 146

def increment(key, value = 1, *metric_options)
  if value.is_a?(Hash) && metric_options.empty?
    metric_options = [value]
    value = 1
  end

  collect_metric(hash_argument(metric_options).merge(type: :c, name: key, value: value))
end

.key_value(key, value, *metric_options) ⇒ Object



166
167
168
# File 'lib/statsd/instrument.rb', line 166

def key_value(key, value, *metric_options)
  collect_metric(hash_argument(metric_options).merge(type: :kv, name: key, value: value))
end

.measure(key, value = nil, *metric_options, &block) ⇒ Object

glork:320|ms



132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/statsd/instrument.rb', line 132

def measure(key, value = nil, *metric_options, &block)
  if value.is_a?(Hash) && metric_options.empty?
    metric_options = [value]
    value = nil
  end

  result = nil
  value  = 1000 * StatsD::Instrument.duration { result = block.call } if block_given?
  metric = collect_metric(hash_argument(metric_options).merge(type: :ms, name: key, value: value))
  result = metric unless block_given?
  result
end

.set(key, value, *metric_options) ⇒ Object

uniques:765|s



171
172
173
# File 'lib/statsd/instrument.rb', line 171

def set(key, value, *metric_options)
  collect_metric(hash_argument(metric_options).merge(type: :s, name: key, value: value))
end