Example #1
0
 public virtual MetricsBuffer SampleMetrics()
 {
     lock (this)
     {
         collector.Clear();
         MetricsBufferBuilder bufferBuilder = new MetricsBufferBuilder();
         foreach (KeyValuePair <string, MetricsSourceAdapter> entry in sources)
         {
             if (sourceFilter == null || sourceFilter.Accepts(entry.Key))
             {
                 SnapshotMetrics(entry.Value, bufferBuilder);
             }
         }
         if (publishSelfMetrics)
         {
             SnapshotMetrics(sysSource, bufferBuilder);
         }
         MetricsBuffer buffer = bufferBuilder.Get();
         return(buffer);
     }
 }
Example #2
0
 /// <summary>Publish a metrics snapshot to all the sinks</summary>
 /// <param name="buffer">the metrics snapshot to publish</param>
 /// <param name="immediate">
 /// indicates that we should publish metrics immediately
 /// instead of using a separate thread.
 /// </param>
 internal virtual void PublishMetrics(MetricsBuffer buffer, bool immediate)
 {
     lock (this)
     {
         int dropped = 0;
         foreach (MetricsSinkAdapter sa in sinks.Values)
         {
             long startTime = Time.Now();
             bool result;
             if (immediate)
             {
                 result = sa.PutMetricsImmediate(buffer);
             }
             else
             {
                 result = sa.PutMetrics(buffer, logicalTime);
             }
             dropped += result ? 0 : 1;
             publishStat.Add(Time.Now() - startTime);
         }
         droppedPubAll.Incr(dropped);
     }
 }
 public WaitableMetricsBuffer(MetricsBuffer metricsBuffer)
     : base(metricsBuffer)
 {
 }