Class: StatsD::Instrument::LegacyClient
- Inherits:
-
Object
- Object
- StatsD::Instrument::LegacyClient
- Defined in:
- lib/statsd/instrument/legacy_client.rb
Instance Attribute Summary collapse
- #backend ⇒ Object
-
#default_sample_rate ⇒ Object
Returns the value of attribute default_sample_rate.
-
#default_tags ⇒ Object
Returns the value of attribute default_tags.
-
#prefix ⇒ Object
Returns the value of attribute prefix.
Class Method Summary collapse
Instance Method Summary collapse
-
#distribution(name, value = nil, sample_rate: nil, tags: nil, &block) ⇒ Object
Emits a distribution metric.
-
#event(title, text, tags: nil, hostname: nil, timestamp: nil, aggregation_key: nil, priority: nil, source_type_name: nil, alert_type: nil) ⇒ void
Emits an event.
-
#gauge(name, value, sample_rate: nil, tags: nil) ⇒ void
Emits a gauge metric.
-
#histogram(name, value, sample_rate: nil, tags: nil) ⇒ void
Emits a histogram metric.
-
#increment(name, value = 1, sample_rate: nil, tags: nil) ⇒ void
Emits a counter metric.
-
#key_value(name, value) ⇒ void
Emits a key/value metric.
-
#measure(name, value = nil, sample_rate: nil, tags: nil, &block) ⇒ Object
Emits a timing metric.
-
#service_check(name, status, tags: nil, hostname: nil, timestamp: nil, message: nil) ⇒ void
Emits a service check.
-
#set(name, value, sample_rate: nil, tags: nil) ⇒ void
Emits a set metric, which counts the number of distinct values that have occurred.
Instance Attribute Details
#backend ⇒ Object
16 17 18 |
# File 'lib/statsd/instrument/legacy_client.rb', line 16 def backend @backend ||= StatsD::Instrument::Environment.default_backend end |
#default_sample_rate ⇒ Object
Returns the value of attribute default_sample_rate.
8 9 10 |
# File 'lib/statsd/instrument/legacy_client.rb', line 8 def default_sample_rate @default_sample_rate end |
#default_tags ⇒ Object
Returns the value of attribute default_tags.
10 11 12 |
# File 'lib/statsd/instrument/legacy_client.rb', line 10 def @default_tags end |
#prefix ⇒ Object
Returns the value of attribute prefix.
8 9 10 |
# File 'lib/statsd/instrument/legacy_client.rb', line 8 def prefix @prefix end |
Class Method Details
.singleton ⇒ Object
4 5 6 |
# File 'lib/statsd/instrument/legacy_client.rb', line 4 def self.singleton @singleton ||= new end |
Instance Method Details
#distribution(name, value, sample_rate: nil, tags: nil) ⇒ void #distribution(key, metric_options = {}) { ... } ⇒ Object
Supported by the datadog implementation only.
Emits a distribution metric.
187 188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'lib/statsd/instrument/legacy_client.rb', line 187 def distribution( key, value_arg = nil, deprecated_sample_rate_arg = nil, = nil, value: value_arg, sample_rate: deprecated_sample_rate_arg, tags: , prefix: self.prefix, no_prefix: false, &block ) prefix = nil if no_prefix if block_given? measure_latency(:d, key, sample_rate: sample_rate, tags: , prefix: prefix, &block) else collect_metric(:d, key, value, sample_rate: sample_rate, tags: , prefix: prefix) end end |
#event(title, text, tags: nil, hostname: nil, timestamp: nil, aggregation_key: nil, priority: nil, source_type_name: nil, alert_type: nil) ⇒ void
Supported by the Datadog implementation only.
This method returns an undefined value.
Emits an event.
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 |
# File 'lib/statsd/instrument/legacy_client.rb', line 234 def event( title, text, deprecated_sample_rate_arg = nil, = nil, sample_rate: deprecated_sample_rate_arg, tags: , prefix: self.prefix, no_prefix: false, hostname: nil, date_happened: nil, timestamp: date_happened, aggregation_key: nil, priority: nil, source_type_name: nil, alert_type: nil, **_ignored ) prefix = nil if no_prefix collect_metric(:_e, title, text, sample_rate: sample_rate, tags: , prefix: prefix, metadata: { hostname: hostname, timestamp: , aggregation_key: aggregation_key, priority: priority, source_type_name: source_type_name, alert_type: alert_type }) end |
#gauge(name, value, sample_rate: nil, tags: nil) ⇒ void
This method returns an undefined value.
Emits a gauge metric.
110 111 112 113 114 115 116 117 |
# File 'lib/statsd/instrument/legacy_client.rb', line 110 def gauge( key, value_arg = nil, deprecated_sample_rate_arg = nil, = nil, value: value_arg, sample_rate: deprecated_sample_rate_arg, tags: , prefix: self.prefix, no_prefix: false ) prefix = nil if no_prefix collect_metric(:g, key, value, sample_rate: sample_rate, tags: , prefix: prefix) end |
#histogram(name, value, sample_rate: nil, tags: nil) ⇒ void
Supported by the datadog implementation only.
This method returns an undefined value.
Emits a histogram metric.
150 151 152 153 154 155 156 157 |
# File 'lib/statsd/instrument/legacy_client.rb', line 150 def histogram( key, value_arg = nil, deprecated_sample_rate_arg = nil, = nil, value: value_arg, sample_rate: deprecated_sample_rate_arg, tags: , prefix: self.prefix, no_prefix: false ) prefix = nil if no_prefix collect_metric(:h, key, value, sample_rate: sample_rate, tags: , prefix: prefix) end |
#increment(name, value = 1, sample_rate: nil, tags: nil) ⇒ void
This method returns an undefined value.
Emits a counter metric.
92 93 94 95 96 97 98 99 |
# File 'lib/statsd/instrument/legacy_client.rb', line 92 def increment( key, value_arg = 1, deprecated_sample_rate_arg = nil, = nil, value: value_arg, sample_rate: deprecated_sample_rate_arg, tags: , prefix: self.prefix, no_prefix: false ) prefix = nil if no_prefix collect_metric(:c, key, value, sample_rate: sample_rate, tags: , prefix: prefix) end |
#key_value(name, value) ⇒ void
Supported by the statsite implementation only.
This method returns an undefined value.
Emits a key/value metric.
210 211 212 213 214 215 216 |
# File 'lib/statsd/instrument/legacy_client.rb', line 210 def key_value( key, value_arg = nil, deprecated_sample_rate_arg = nil, value: value_arg, sample_rate: deprecated_sample_rate_arg, no_prefix: false ) prefix = nil if no_prefix collect_metric(:kv, key, value, sample_rate: sample_rate, prefix: prefix) end |
#measure(key, value, sample_rate: nil, tags: nil) ⇒ void #measure(key, sample_rate: nil, tags: nil) { ... } ⇒ Object
Emits a timing metric
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/statsd/instrument/legacy_client.rb', line 52 def measure( key, value_arg = nil, deprecated_sample_rate_arg = nil, = nil, value: value_arg, sample_rate: deprecated_sample_rate_arg, tags: , prefix: self.prefix, no_prefix: false, as_dist: false, &block ) # TODO: in the next version, hardcode this to :ms when the as_dist argument is dropped. type = as_dist ? :d : :ms prefix = nil if no_prefix if block_given? measure_latency(type, key, sample_rate: sample_rate, tags: , prefix: prefix, &block) else collect_metric(type, key, value, sample_rate: sample_rate, tags: , prefix: prefix) end end |
#service_check(name, status, tags: nil, hostname: nil, timestamp: nil, message: nil) ⇒ void
Supported by the Datadog implementation only.
This method returns an undefined value.
Emits a service check.
263 264 265 266 267 268 269 270 271 272 273 274 |
# File 'lib/statsd/instrument/legacy_client.rb', line 263 def service_check( name, status, deprecated_sample_rate_arg = nil, = nil, sample_rate: deprecated_sample_rate_arg, tags: , prefix: self.prefix, no_prefix: false, hostname: nil, timestamp: nil, message: nil, **_ignored ) prefix = nil if no_prefix collect_metric(:_sc, name, status, sample_rate: sample_rate, prefix: prefix, tags: , metadata: { hostname: hostname, timestamp: , message: }) end |
#set(name, value, sample_rate: nil, tags: nil) ⇒ void
This method returns an undefined value.
Emits a set metric, which counts the number of distinct values that have occurred.
131 132 133 134 135 136 137 138 |
# File 'lib/statsd/instrument/legacy_client.rb', line 131 def set( key, value_arg = nil, deprecated_sample_rate_arg = nil, = nil, value: value_arg, sample_rate: deprecated_sample_rate_arg, tags: , prefix: self.prefix, no_prefix: false ) prefix = nil if no_prefix collect_metric(:s, key, value, sample_rate: sample_rate, tags: , prefix: prefix) end |