// 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(); }
/// <summary>Creates a new instance of JvmMetrics</summary> private JvmMetrics(string processName, string sessionId, string recordName) { MetricsContext context = MetricsUtil.GetContext("jvm"); metrics = MetricsUtil.CreateRecord(context, recordName); metrics.SetTag("processName", processName); metrics.SetTag("sessionId", sessionId); context.RegisterUpdater(this); }
/// <summary> /// Utility method to create and return new metrics record instance within the /// given context. /// </summary> /// <remarks> /// Utility method to create and return new metrics record instance within the /// given context. This record is tagged with the host name. /// </remarks> /// <param name="context">the context</param> /// <param name="recordName">name of the record</param> /// <returns>newly created metrics record</returns> public static MetricsRecord CreateRecord(MetricsContext context, string recordName ) { MetricsRecord metricsRecord = context.CreateRecord(recordName); metricsRecord.SetTag("hostName", GetHostName()); return(metricsRecord); }
public LocalJobRunnerMetrics(JobConf conf) { string sessionId = conf.GetSessionId(); // Initiate JVM Metrics JvmMetrics.Init("JobTracker", sessionId); // Create a record for map-reduce metrics MetricsContext context = MetricsUtil.GetContext("mapred"); // record name is jobtracker for compatibility metricsRecord = MetricsUtil.CreateRecord(context, "jobtracker"); metricsRecord.SetTag("sessionId", sessionId); context.RegisterUpdater(this); }