// List containing nc1 and nc2.
        /// <summary>
        /// Initializes, for testing, two NoEmitMetricsContext's, and adds one value
        /// to the first of them.
        /// </summary>
        /// <exception cref="System.IO.IOException"/>
        protected override void SetUp()
        {
            nc1 = new NoEmitMetricsContext();
            nc1.Init("test1", ContextFactory.GetFactory());
            nc2 = new NoEmitMetricsContext();
            nc2.Init("test2", ContextFactory.GetFactory());
            contexts = new AList <MetricsContext>();
            contexts.AddItem(nc1);
            contexts.AddItem(nc2);
            MetricsRecord r = nc1.CreateRecord("testRecord");

            r.SetTag("testTag1", "testTagValue1");
            r.SetTag("testTag2", "testTagValue2");
            r.SetMetric("testMetric1", 1);
            r.SetMetric("testMetric2", 33);
            r.Update();
            IDictionary <string, ICollection <OutputRecord> > m = nc1.GetAllRecords();

            Assert.Equal(1, m.Count);
            Assert.Equal(1, m.Values.Count);
            ICollection <OutputRecord> outputRecords = m.Values.GetEnumerator().Next();

            Assert.Equal(1, outputRecords.Count);
            outputRecord = outputRecords.GetEnumerator().Next();
        }
Example #2
0
 /// <summary>Push the metric to the mr.</summary>
 /// <remarks>
 /// Push the metric to the mr.
 /// The metric is pushed only if it was updated since last push
 /// Note this does NOT push to JMX
 /// (JMX gets the info via
 /// <see cref="Get()"/>
 /// </remarks>
 /// <param name="mr"/>
 public override void PushMetric(MetricsRecord mr)
 {
     lock (this)
     {
         if (changed)
         {
             mr.SetMetric(GetName(), value);
         }
         changed = false;
     }
 }
 public virtual void DoUpdates(MetricsContext unused)
 {
     lock (this)
     {
         shuffleMetrics.IncrMetric("shuffle_input_bytes", numBytes);
         shuffleMetrics.IncrMetric("shuffle_failed_fetches", numFailedFetches);
         shuffleMetrics.IncrMetric("shuffle_success_fetches", numSuccessFetches);
         if (numCopiers != 0)
         {
             shuffleMetrics.SetMetric("shuffle_fetchers_busy_percent", 100 * ((float)numThreadsBusy
                                                                              / numCopiers));
         }
         else
         {
             shuffleMetrics.SetMetric("shuffle_fetchers_busy_percent", 0);
         }
         numBytes          = 0;
         numSuccessFetches = 0;
         numFailedFetches  = 0;
     }
     shuffleMetrics.Update();
 }
 /// <summary>Push the delta  metrics to the mr.</summary>
 /// <remarks>
 /// Push the delta  metrics to the mr.
 /// The delta is since the last push/interval.
 /// Note this does NOT push to JMX
 /// (JMX gets the info via
 /// <see cref="GetPreviousIntervalAverageTime()"/>
 /// and
 /// <see cref="GetPreviousIntervalNumOps()"/>
 /// </remarks>
 /// <param name="mr"/>
 public override void PushMetric(MetricsRecord mr)
 {
     lock (this)
     {
         IntervalHeartBeat();
         try
         {
             mr.IncrMetric(GetName() + "_num_ops", GetPreviousIntervalNumOps());
             mr.SetMetric(GetName() + "_avg_time", GetPreviousIntervalAverageTime());
         }
         catch (Exception e)
         {
             Log.Info("pushMetric failed for " + GetName() + "\n", e);
         }
     }
 }
Example #5
0
 /// <summary>Push the metric to the mr.</summary>
 /// <remarks>
 /// Push the metric to the mr.
 /// The metric is pushed only if it was updated since last push
 /// Note this does NOT push to JMX
 /// (JMX gets the info via
 /// <see cref="Get()"/>
 /// </remarks>
 /// <param name="mr"/>
 public override void PushMetric(MetricsRecord mr)
 {
     lock (this)
     {
         if (changed)
         {
             try
             {
                 mr.SetMetric(GetName(), value);
             }
             catch (Exception e)
             {
                 Log.Info("pushMetric failed for " + GetName() + "\n", e);
             }
         }
         changed = false;
     }
 }
Example #6
0
        private void DoMemoryUpdates()
        {
            MemoryMXBean memoryMXBean = ManagementFactory.GetMemoryMXBean();
            MemoryUsage  memNonHeap   = memoryMXBean.GetNonHeapMemoryUsage();
            MemoryUsage  memHeap      = memoryMXBean.GetHeapMemoryUsage();
            Runtime      runtime      = Runtime.GetRuntime();

            metrics.SetMetric("memNonHeapUsedM", memNonHeap.GetUsed() / M);
            metrics.SetMetric("memNonHeapCommittedM", memNonHeap.GetCommitted() / M);
            metrics.SetMetric("memHeapUsedM", memHeap.GetUsed() / M);
            metrics.SetMetric("memHeapCommittedM", memHeap.GetCommitted() / M);
            metrics.SetMetric("maxMemoryM", runtime.MaxMemory() / M);
        }