Class: Librato::Rack::ValidatingQueue
- Inherits:
-
Metrics::Queue
- Object
- Metrics::Queue
- Librato::Rack::ValidatingQueue
- Defined in:
- lib/librato/rack/validating_queue.rb
Overview
Queue with special upfront validating logic, this should probably be available in librato-metrics but spiking here to work out the kinks
Constant Summary collapse
- DEFAULT_TAGS_LIMIT =
4
- METRIC_NAME_REGEX =
/\A[-.:_\w]{1,255}\z/
- TAGS_KEY_REGEX =
/\A[-.:_\w]{1,64}\z/
- TAGS_VALUE_REGEX =
/\A[-.:_\w\s]{1,255}\z/
Instance Attribute Summary collapse
-
#logger ⇒ Object
Returns the value of attribute logger.
Instance Method Summary collapse
- #submit ⇒ Object
-
#validate_measurements ⇒ Object
screen all measurements for validity before sending.
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
13 14 15 |
# File 'lib/librato/rack/validating_queue.rb', line 13 def logger @logger end |
Instance Method Details
#submit ⇒ Object
15 16 17 18 19 |
# File 'lib/librato/rack/validating_queue.rb', line 15 def submit validate_measurements super end |
#validate_measurements ⇒ Object
screen all measurements for validity before sending
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/librato/rack/validating_queue.rb', line 22 def validate_measurements @queued[:measurements].delete_if do |entry| name = entry[:name].to_s = entry[:tags] if name !~ METRIC_NAME_REGEX log :warn, "invalid metric name '#{name}', not sending." true # delete elsif && .any? { |k,v| k.to_s !~ TAGS_KEY_REGEX || v.to_s !~ TAGS_VALUE_REGEX } log :warn, "halting: '#{}' are invalid tags." true # delete else false # preserve end end end |