// 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();
        }
Exemple #2
0
        /// <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);
        }