TAG Aggregation
scout.Watcher
will be notified whenever a tag is used by an event and track each tag in amap[]
.- Periodically (every 10 seconds)
scout.Watcher
will iterate over themap[]
and call the methodWorkerPool.UpdateTags()
which will run a job inside a go routine that runs the following
func (t *tagAggregate) Update(id types.LevelID, tag string) {
// Retrieve the tag entry
item, err := t.tagger.GetItem(id, tag)
if err != nil {
log.Warningf("Update: GetItem(%s, %s) error - %v", id, tag, err)
return
}
// If first-seen is not set
if item.FirstSeen.IsZero() {
// Calculate the first seen
item.FirstSeen, err = t.findFirstSeen(id, tag)
if err != nil {
log.Warningf("findFirstSeen(%s, %s) error - %v", id, tag, err)
return
}
}
// Update the last and last_month entries
item.LastSeen = time.Now().UTC()
// Calculate the total count this tag has been seen for the last 30 days
item.MonthTotal, err = t.calculate30Days(id, tag)
if err != nil {
log.Warningf("calculateMonthUsage(%s, %s) error - %v", id, tag, err)
return
}
if err = t.tagger.UpdateItem(id, item); err != nil {
log.Warningf("UpdateItem(%s, %s) error - %v", id, tag, err)
}
}