Exemplo n.º 1
0
        /// <summary>Update the cache and return the current cached record</summary>
        /// <param name="mr">the update record</param>
        /// <param name="includingTags">cache tag values (for later lookup by name) if true</param>
        /// <returns>the updated cache record</returns>
        public virtual MetricsCache.Record Update(MetricsRecord mr, bool includingTags)
        {
            string name = mr.Name();

            MetricsCache.RecordCache recordCache = map[name];
            if (recordCache == null)
            {
                recordCache = new MetricsCache.RecordCache(this);
                map[name]   = recordCache;
            }
            ICollection <MetricsTag> tags = mr.Tags();

            MetricsCache.Record record = recordCache[tags];
            if (record == null)
            {
                record            = new MetricsCache.Record();
                recordCache[tags] = record;
            }
            foreach (AbstractMetric m in mr.Metrics())
            {
                record.metrics[m.Name()] = m;
            }
            if (includingTags)
            {
                // mostly for some sinks that include tags as part of a dense schema
                foreach (MetricsTag t in mr.Tags())
                {
                    record.tags[t.Name()] = t.Value();
                }
            }
            return(record);
        }
Exemplo n.º 2
0
 /// <summary>Get the cached record</summary>
 /// <param name="name">of the record</param>
 /// <param name="tags">of the record</param>
 /// <returns>the cached record or null</returns>
 public virtual MetricsCache.Record Get(string name, ICollection <MetricsTag> tags)
 {
     MetricsCache.RecordCache rc = map[name];
     if (rc == null)
     {
         return(null);
     }
     return(rc[tags]);
 }