Esempio n. 1
0
 private void SetSupplier(ISupplyCounterDefinitions definitionSupplier)
 {
     if (_definitionSupplier != null)
     {
         _definitionSupplier.DefinitionsChanged -= DefinitionsChanged;
     }
     _definitionSupplier = definitionSupplier;
     _definitionSupplier.DefinitionsChanged += DefinitionsChanged;
 }
Esempio n. 2
0
 public BaseSetup()
 {
     var sinkMock = new Mock<ISendInfo>();
     sinkMock.Setup(s => s.Send(It.IsAny<string>(), It.IsAny<float>())).Returns<string, float>(RecordSend);
     Sink = sinkMock.Object;
     var supplierMock = new Mock<ISupplyCounterDefinitions>();
     supplierMock.Setup(s => s.CreateDefinitions()).Returns(() => new[]
     {
         new CounterDefinition
         {
             CategoryName = "Processor",
             CounterName = "% Processor Time",
             InstanceName = "_Total",
             CollectInterval = 50
         }
     });
     Supplier = supplierMock.Object;
 }
Esempio n. 3
0
        public Collector(ISupplyCounterDefinitions definitionSupplier, IEnumerable<ISendInfo> sinks, IMachineNameProvider machineNameProvider = null, ICounterIdentifierGenerator counterIdentifierGenerator = null)
        {
            SetSupplier(definitionSupplier);
            SetMachineNameProvider(machineNameProvider);
            SetCounterIdentifierGenerator(counterIdentifierGenerator);

            _sinks = sinks.ToList();
            try
            {
                if (_definitionSupplier == null)
                {
                    Logger.Error("No definition supplier specified!");
                    throw new ArgumentException("definitionSupplier");
                }
                ConfigureReaders(_sinks);
            }
            catch (Exception ex)
            {
                Logger.ErrorFormat("error trying to configure the collector {@exception}", ex);
                throw;
            }
        }