mirror of
https://github.com/jimeh/redistat.git
synced 2026-02-19 05:16:39 +00:00
added label indexing features when using label groupings
This commit is contained in:
@@ -36,6 +36,7 @@ module Redistat
|
||||
KEY_EVENT = ".event:"
|
||||
KEY_LEBELS = "Redistat.lables:"
|
||||
KEY_EVENT_IDS = ".event_ids"
|
||||
LABEL_INDEX = ".label_index:"
|
||||
GROUP_SEPARATOR = "/"
|
||||
|
||||
class InvalidOptions < ArgumentError; end
|
||||
|
||||
@@ -57,6 +57,10 @@ module Redistat
|
||||
@label.parent_group
|
||||
end
|
||||
|
||||
def update_label_index
|
||||
@label.update_index
|
||||
end
|
||||
|
||||
def to_s(depth = nil)
|
||||
depth ||= @options[:depth]
|
||||
key = self.prefix
|
||||
|
||||
@@ -49,8 +49,24 @@ module Redistat
|
||||
@groups.reverse!
|
||||
end
|
||||
|
||||
def parent
|
||||
@parent ||= self.class.new(parent_group)
|
||||
end
|
||||
|
||||
def parent_group
|
||||
groups[-2]
|
||||
groups[1]
|
||||
end
|
||||
|
||||
def sub_group
|
||||
@raw.split(GROUP_SEPARATOR).last
|
||||
end
|
||||
|
||||
def update_index
|
||||
groups.each do |group|
|
||||
label = self.class.new(group)
|
||||
break if label.parent_group.nil?
|
||||
db.sadd("#{LABEL_INDEX}#{label.parent_group}", label.sub_group) == "OK" ? true : false
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -13,6 +13,7 @@ module Redistat
|
||||
stats = inject_group_summaries(stats)
|
||||
key.groups.each { |k|
|
||||
update_key(k, stats, depth_limit, connection_ref)
|
||||
k.update_label_index # TODO: add a label_indexing option
|
||||
}
|
||||
else
|
||||
update_key(key, stats, depth_limit, connection_ref)
|
||||
|
||||
Reference in New Issue
Block a user