class Librato::Rack::ValidatingQueue
Queue with special upfront validating logic, this should probably be available in librato-metrics but spiking here to work out the kinks
Constants
- DEFAULT_TAGS_LIMIT
- METRIC_NAME_REGEX
- TAGS_KEY_REGEX
- TAGS_VALUE_REGEX
Attributes
logger[RW]
Public Instance Methods
submit()
click to toggle source
Calls superclass method
# File lib/librato/rack/validating_queue.rb, line 15 def submit validate_measurements super end
validate_measurements()
click to toggle source
screen all measurements for validity before sending
# File lib/librato/rack/validating_queue.rb, line 22 def validate_measurements @queued[:measurements].delete_if do |entry| name = entry[:name].to_s tags = entry[:tags] if name !~ METRIC_NAME_REGEX log :warn, "invalid metric name '#{name}', not sending." true # delete elsif tags && tags.any? { |k,v| k.to_s !~ TAGS_KEY_REGEX || v.to_s !~ TAGS_VALUE_REGEX } log :warn, "halting: '#{tags}' are invalid tags." true # delete else false # preserve end end end
Private Instance Methods
log(level, msg)
click to toggle source
# File lib/librato/rack/validating_queue.rb, line 40 def log(level, msg) return unless logger logger.log level, msg end