Module: Synapse::StatsD
Constant Summary
collapse
- @@STATSD_HOST =
"localhost"
- @@STATSD_PORT =
8125
- @@STATSD_SAMPLE_RATE =
{}
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Logging
configure_logger_for, log, logger_for
Class Method Details
32
33
34
35
36
37
|
# File 'lib/synapse/statsd.rb', line 32
def configure_statsd(opts)
@@STATSD_HOST = opts['host'] || @@STATSD_HOST
@@STATSD_PORT = (opts['port'] || @@STATSD_PORT).to_i
@@STATSD_SAMPLE_RATE = opts['sample_rate'] || {}
log.info "synapse: configuring statsd on host '#{@@STATSD_HOST}' port #{@@STATSD_PORT}"
end
|
.statsd_for(classname) ⇒ Object
27
28
29
30
|
# File 'lib/synapse/statsd.rb', line 27
def statsd_for(classname)
log.debug "synapse: creating statsd client for class '#{classname}' on host '#{@@STATSD_HOST}' port #{@@STATSD_PORT}"
Datadog::Statsd.new(@@STATSD_HOST, @@STATSD_PORT)
end
|
Instance Method Details
#statsd ⇒ Object
6
7
8
|
# File 'lib/synapse/statsd.rb', line 6
def statsd
@@STATSD ||= StatsD.statsd_for(self.class.name)
end
|
#statsd_increment(key, tags = []) ⇒ Object
10
11
12
|
# File 'lib/synapse/statsd.rb', line 10
def statsd_increment(key, tags = [])
statsd.increment(key, tags: tags, sample_rate: sample_rate_for(key))
end
|
#statsd_time(key, tags = []) ⇒ Object
14
15
16
17
18
|
# File 'lib/synapse/statsd.rb', line 14
def statsd_time(key, tags = [])
statsd.time(key, tags: tags, sample_rate: sample_rate_for(key)) do
yield
end
end
|