Class: KubernetesDeploy::StatsD
- Inherits:
-
Object
- Object
- KubernetesDeploy::StatsD
- Extended by:
- StatsD
- Defined in:
- lib/kubernetes-deploy/statsd.rb
Defined Under Namespace
Modules: MeasureMethods
Constant Summary collapse
- PREFIX =
"KubernetesDeploy"
Class Method Summary collapse
- .build ⇒ Object
- .distribution(key, value = nil, **metric_options, &block) ⇒ Object
- .duration(start_time) ⇒ Object
-
.increment(key, value = 1, **metric_options) ⇒ Object
It is not sufficient to set the prefix field on the KubernetesDeploy::StatsD singleton itself, since its value is overridden in the underlying calls to the ::StatsD library, hence the need to pass it in as a custom prefix via the metric_options hash.
Class Method Details
.build ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/kubernetes-deploy/statsd.rb', line 15 def self.build if ENV['STATSD_DEV'].present? self.backend = ::StatsD::Instrument::Backends::LoggerBackend.new(Logger.new($stderr)) elsif ENV['STATSD_ADDR'].present? statsd_impl = ENV['STATSD_IMPLEMENTATION'].present? ? ENV['STATSD_IMPLEMENTATION'] : "datadog" self.backend = ::StatsD::Instrument::Backends::UDPBackend.new(ENV['STATSD_ADDR'], statsd_impl) else self.backend = ::StatsD::Instrument::Backends::NullBackend.new end end |
.distribution(key, value = nil, **metric_options, &block) ⇒ Object
35 36 37 38 |
# File 'lib/kubernetes-deploy/statsd.rb', line 35 def self.distribution(key, value = nil, **, &block) [:prefix] = PREFIX super end |
.duration(start_time) ⇒ Object
11 12 13 |
# File 'lib/kubernetes-deploy/statsd.rb', line 11 def self.duration(start_time) (Time.now.utc - start_time).round(1) end |
.increment(key, value = 1, **metric_options) ⇒ Object
It is not sufficient to set the prefix field on the KubernetesDeploy::StatsD singleton itself, since its value is overridden in the underlying calls to the ::StatsD library, hence the need to pass it in as a custom prefix via the metric_options hash. This is done since KubernetesDeploy may be included as a library and should not change the global StatsD configuration of the importing application.
30 31 32 33 |
# File 'lib/kubernetes-deploy/statsd.rb', line 30 def self.increment(key, value = 1, **) [:prefix] = PREFIX super end |