when_passing_a_counter_name_with_spaces_should_expand_correctly () { var counter = new CounterDefinition { CategoryName = "PhysicalDisk", CollectInterval = 1000, CounterName = "% Idle Time", InstanceName = "_Total" }; var counters = counter.Expand().ToList(); Assert.Equal(1, counters.Count); Assert.Equal(counter.InstanceName, counters.First().InstanceName); Assert.Equal(counter.CategoryName, counters.First().CategoryName); Assert.Equal(counter.CounterName, counters.First().CounterName); }
when_passing_a_regex_to_return_all_instances_and_the_counter_has_no_instance_should_return_the_default_single_instance_name () { var counter = new CounterDefinition { CategoryName = "Memory", CollectInterval = 1000, CounterName = "Available MBytes", InstanceName = "/.*/" }; var counters = counter.Expand().ToList(); Assert.Equal(1,counters.Count); Assert.Equal(string.Empty,counters.First().InstanceName); Assert.Equal(counter.CategoryName, counters.First().CategoryName); Assert.Equal(counter.CounterName, counters.First().CounterName); }
private void AddReader(CounterDefinition definition, IEnumerable<ISendInfo> sinks) { foreach (var counterDefinition in definition.Expand()) { if (counterDefinition.Exists()) { Interval interval = null; if (!_counters.TryGetValue(counterDefinition.CollectIntervalSpan, out interval)) { interval = new Interval(counterDefinition.CollectIntervalSpan, sinks, _machineNameProvider, _counterIdentifierGenerator); _counters.Add(counterDefinition.CollectIntervalSpan, interval); } interval.AddDefinition(counterDefinition); } else { Logger.ErrorFormat( "received a counter definition for a non existente counter/instance: {@definition}. Ignoring it!", counterDefinition); } } }