//------------------------------------------------------------------------------ // // Method: PerformanceCounterMetricLoggerImplementation (constructor) // //------------------------------------------------------------------------------ /// <summary> /// Initialises a new instance of the ApplicationMetrics.PerformanceCounterMetricLoggerImplementation class. /// </summary> /// <param name="metricCategoryName">The name of the performance counter category which the metric events should be logged under.</param> /// <param name="metricCategoryDescription">The description of the performance counter category which the metric events should be logged under.</param> /// <param name="bufferProcessingStrategy">Object which implements a processing strategy for the buffers (queues).</param> /// <param name="intervalMetricChecking">Specifies whether an exception should be thrown if the correct order of interval metric logging is not followed (e.g. End() method called before Begin()).</param> public PerformanceCounterMetricLoggerImplementation(string metricCategoryName, string metricCategoryDescription, IBufferProcessingStrategy bufferProcessingStrategy, bool intervalMetricChecking) : base(bufferProcessingStrategy, intervalMetricChecking) { InitialisePrivateMembers(metricCategoryName, metricCategoryDescription); counterCreationDataFactory = new CounterCreationDataFactory(); performanceCounterCategory = new PerformanceCounterCategory(); performanceCounterFactory = new PerformanceCounterFactory(); }
public static IPerformanceCounter <double> CreateProcessCategoryCounter( this IPerformanceCounterFactory factory, string counter, int processId) => factory .Create <double>() .AddCounter("Process", counter, (context, value) => context.Result = value) .Build(InstanceNameProviders.Process.ForPid(processId));
public static IPerformanceCounter <double> CreateCounter( this IPerformanceCounterFactory factory, string category, string counter, Func <string> instanceNameProvider) => factory .Create <double>() .AddCounter(category, counter, (context, value) => context.Result = value) .Build(instanceNameProvider);
//------------------------------------------------------------------------------ // // Method: PerformanceCounterMetricLoggerImplementation (constructor) // //------------------------------------------------------------------------------ /// <summary> /// Initialises a new instance of the ApplicationMetrics.PerformanceCounterMetricLoggerImplementation class. Note this is an additional constructor to facilitate unit tests, and should not be used to instantiate the class under normal conditions. /// </summary> /// <param name="metricCategoryName">The name of the performance counter category which the metric events should be logged under.</param> /// <param name="metricCategoryDescription">The description of the performance counter category which the metric events should be logged under.</param> /// <param name="bufferProcessingStrategy">Object which implements a processing strategy for the buffers (queues).</param> /// <param name="intervalMetricChecking">Specifies whether an exception should be thrown if the correct order of interval metric logging is not followed (e.g. End() method called before Begin()).</param> /// <param name="counterCreationDataCollection">A test (mock) counter creation data collection object.</param> /// <param name="counterCreationDataFactory">A test (mock) counter creation data factory object.</param> /// <param name="performanceCounterCategory">A test (mock) performance counter category object.</param> /// <param name="performanceCounterFactory">A test (mock) performance counter factory object.</param> /// <param name="dateTime">A test (mock) DateTime object.</param> /// <param name="exceptionHandler">A test (mock) exception handler object.</param> public PerformanceCounterMetricLoggerImplementation(string metricCategoryName, string metricCategoryDescription, IBufferProcessingStrategy bufferProcessingStrategy, bool intervalMetricChecking, ICounterCreationDataCollection counterCreationDataCollection, ICounterCreationDataFactory counterCreationDataFactory, IPerformanceCounterCategory performanceCounterCategory, IPerformanceCounterFactory performanceCounterFactory, IDateTime dateTime, IExceptionHandler exceptionHandler) : base(bufferProcessingStrategy, intervalMetricChecking, dateTime, exceptionHandler) { InitialisePrivateMembers(metricCategoryName, metricCategoryDescription); this.counterCreationDataCollection = counterCreationDataCollection; this.counterCreationDataFactory = counterCreationDataFactory; this.performanceCounterCategory = performanceCounterCategory; this.performanceCounterFactory = performanceCounterFactory; }
public static IPerformanceCounter <double> CreateCounter( this IPerformanceCounterFactory factory, string category, string counter, string instance = null) => factory .Create <double>() .AddCounter(category, counter, (context, value) => context.Result = value) .Build(instance);
public TargetStartedHandler( [NotNull] ILoggerContext context, [NotNull] IPerformanceCounterFactory performanceCounterFactory, [NotNull] IBuildEventManager buildEventManager) { _buildEventManager = buildEventManager ?? throw new ArgumentNullException(nameof(buildEventManager)); _context = context ?? throw new ArgumentNullException(nameof(context)); _performanceCounterFactory = performanceCounterFactory ?? throw new ArgumentNullException(nameof(performanceCounterFactory)); }
private LogicalDiskMeter(char?driveLetter, IPerformanceCounterFactory counterFactory) { var instanceName = driveLetter.HasValue ? driveLetter.ToString() + Path.VolumeSeparatorChar : "_Total"; driveName = driveLetter.HasValue ? instanceName : "Total"; counter = LogicalDiskMeterHelper .CreateCounters(counterFactory) .Build(instanceName); }
//TODO: remove performance counters and make lightweight only-for-current-process GG meter public GarbageCollectionMeter(IPerformanceCounterFactory counterFactory, Func <string> instanceNameProvider) { counter = counterFactory .Create <GarbageCollectionInfo>() // .Create<T> .AddCounter(".NET CLR Memory", "# Gen 0 Collections", (c, x) => c.Result.Gen0CollectionsSinceStart = (long)x) .AddCounter(".NET CLR Memory", "# Gen 1 Collections", (c, x) => c.Result.Gen1CollectionsSinceStart = (long)x) .AddCounter(".NET CLR Memory", "# Gen 2 Collections", (c, x) => c.Result.Gen2CollectionsSinceStart = (long)x) .AddCounter(".NET CLR Memory", "% Time in GC", (c, x) => c.Result.TimeInGCPercent = x) .Build(instanceNameProvider); }
public PerformanceCounter( [NotNull] string scopeName, [NotNull] ILogWriter logWriter, [NotNull] IPerformanceCounterFactory performanceCounterFactory, [NotNull] IMessageWriter messageWriter) { _messageWriter = messageWriter ?? throw new ArgumentNullException(nameof(messageWriter)); _scopeName = scopeName ?? throw new ArgumentNullException(nameof(scopeName)); _logWriter = logWriter ?? throw new ArgumentNullException(nameof(logWriter)); _performanceCounterFactory = performanceCounterFactory ?? throw new ArgumentNullException(nameof(performanceCounterFactory)); }
private HostNetworkUsageMeter(IPerformanceCounterFactory counterFactory) { counter = counterFactory.Create <InterfaceUsageMetrics>() .AddCounter("Network Interface", "Bytes Received/sec", (c, v) => c.Result.ReceivedBytesPerSecond = (long)v) .AddCounter("Network Interface", "Bytes Sent/sec", (c, v) => c.Result.SentBytesPerSecond = (long)v) .AddCounter("Network Interface", "Current Bandwidth", (c, v) => c.Result.BandwidthBytes = (long)(v / 8)) .BuildForMultipleInstances("*"); }
public TaskFinishedHandler( [NotNull] ILoggerContext context, [NotNull] ILogWriter logWriter, [NotNull] IPerformanceCounterFactory performanceCounterFactory, [NotNull] IMessageWriter messageWriter, [NotNull] IDeferredMessageWriter deferredMessageWriter, [NotNull] IStringService stringService) { _stringService = stringService ?? throw new ArgumentNullException(nameof(stringService)); _deferredMessageWriter = deferredMessageWriter ?? throw new ArgumentNullException(nameof(deferredMessageWriter)); _messageWriter = messageWriter ?? throw new ArgumentNullException(nameof(messageWriter)); _context = context ?? throw new ArgumentNullException(nameof(context)); _logWriter = logWriter ?? throw new ArgumentNullException(nameof(logWriter)); _performanceCounterFactory = performanceCounterFactory ?? throw new ArgumentNullException(nameof(performanceCounterFactory)); }
public GlobalMemoryMeter(IPerformanceCounterFactory counterFactory) { counter = counterFactory.Create <GlobalMemoryInfo>() .AddCounter("Memory", "Pool Paged Bytes", (c, value) => c.Result.Kernel.PagedPoolBytes = (long)value) .AddCounter("Memory", "Pool Nonpaged Bytes", (c, value) => c.Result.Kernel.NonpagedPoolBytes = (long)value) .AddCounter("Memory", "Standby Cache Normal Priority Bytes", (c, value) => c.Result.Cache.Standby.NormalPriorityBytes = (long)value) .AddCounter("Memory", "Standby Cache Reserve Bytes", (c, value) => c.Result.Cache.Standby.ReserveBytes = (long)value) .AddCounter("Memory", "Committed Bytes", (c, value) => c.Result.Commit.CommittedBytes = (long)value) .AddCounter("Memory", "Commit Limit", (c, value) => c.Result.Commit.LimitBytes = (long)value) .AddCounter("Memory", "System Cache Resident Bytes", (c, value) => c.Result.Cache.FileCacheBytes = (long)value) .Build(); }
public ProjectFinishedHandler( [NotNull] ILoggerContext context, [NotNull] ILogWriter logWriter, [NotNull] IPerformanceCounterFactory performanceCounterFactory, [NotNull] IMessageWriter messageWriter, [NotNull] IHierarchicalMessageWriter hierarchicalMessageWriter, [NotNull] IDeferredMessageWriter deferredMessageWriter, [NotNull] IBuildEventManager buildEventManager, [NotNull] IStringService stringService) { _stringService = stringService ?? throw new ArgumentNullException(nameof(stringService)); _hierarchicalMessageWriter = hierarchicalMessageWriter ?? throw new ArgumentNullException(nameof(hierarchicalMessageWriter)); _buildEventManager = buildEventManager ?? throw new ArgumentNullException(nameof(buildEventManager)); _deferredMessageWriter = deferredMessageWriter ?? throw new ArgumentNullException(nameof(deferredMessageWriter)); _messageWriter = messageWriter ?? throw new ArgumentNullException(nameof(messageWriter)); _context = context ?? throw new ArgumentNullException(nameof(context)); _performanceCounterFactory = performanceCounterFactory ?? throw new ArgumentNullException(nameof(performanceCounterFactory)); _logWriter = logWriter ?? throw new ArgumentNullException(nameof(logWriter)); }
public static IPerformanceCounterBuilder <DiskMetrics> CreateCounters(IPerformanceCounterFactory counterFactory) => counterFactory.Create <DiskMetrics>() .AddCounter(Category.LogicalDisk, "Current Disk Queue Length", (c, v) => c.Result.QueueLength = (int)v) .AddCounter(Category.LogicalDisk, "Disk Read Bytes/sec", (c, v) => c.Result.ReadBytesPerSecond = (long)v) .AddCounter(Category.LogicalDisk, "Disk Write Bytes/sec", (c, v) => c.Result.WriteBytesPerSecond = (long)v) .AddCounter(Category.LogicalDisk, "Disk Reads/sec", (c, v) => c.Result.ReadsPerSecond = (int)v) .AddCounter(Category.LogicalDisk, "Disk Writes/sec", (c, v) => c.Result.WritesPerSecond = (int)v) .AddCounter(Category.LogicalDisk, "Avg. Disk sec/Read", (c, v) => c.Result.ReadLatency = TimeSpan.FromSeconds(v)) .AddCounter(Category.LogicalDisk, "Avg. Disk sec/Write", (c, v) => c.Result.WriteLatency = TimeSpan.FromSeconds(v)) .AddCounter(Category.LogicalDisk, "Free Megabytes", (c, v) => c.Result.FreeSpaceBytes = (long)v) .AddCounter(Category.LogicalDisk, "% Idle Time", (c, v) => c.Result.Load = Math.Max(0, (100 - v) / 100));
private static IPerformanceCounter <ManagedMemoryInfo> CreateCounter(IPerformanceCounterFactory counterFactory, int pid) { var builder = counterFactory .Create <ManagedMemoryInfo>() // .Create<T> .AddCounter(Category.ClrMemory, "% Time in GC", (c, x) => c.Result.GC.TimeInGCPercent = x) .AddCounter(Category.ClrMemory, "Gen 0 heap size", (c, x) => c.Result.Heap.Gen0SizeBytes = (long)x) .AddCounter(Category.ClrMemory, "Gen 1 heap size", (c, x) => c.Result.Heap.Gen1SizeBytes = (long)x) .AddCounter(Category.ClrMemory, "Gen 2 heap size", (c, x) => c.Result.Heap.Gen2SizeBytes = (long)x) .AddCounter(Category.ClrMemory, "Large Object Heap size", (c, x) => c.Result.Heap.LargeObjectHeapSizeBytes = (long)x) .AddCounter(Category.ClrMemory, "# Bytes in all Heaps", (c, x) => c.Result.Heap.TotalSizeBytes = (long)x) .AddCounter(Category.ClrMemory, "Allocated Bytes/sec", (c, x) => c.Result.Heap.AllocatedBytesPerSecond = (long)x); if (pid != ProcessUtility.CurrentProcessId) { builder = builder .AddCounter(Category.ClrMemory, "# Gen 0 Collections", (c, x) => c.Result.GC.Gen0CollectionsSinceStart = (long)x) .AddCounter(Category.ClrMemory, "# Gen 1 Collections", (c, x) => c.Result.GC.Gen1CollectionsSinceStart = (long)x) .AddCounter(Category.ClrMemory, "# Gen 2 Collections", (c, x) => c.Result.GC.Gen2CollectionsSinceStart = (long)x); } return(builder.Build(InstanceNameProviders.DotNet.ForPid(pid))); }
public PerformanceCounterCoordinatorActor(IActorRef chartingActor, IPerformanceCounterFactory counterFactory, ISeriesFactory seriesFactory, Dictionary <CounterType, IActorRef> counterActors) { _chartingActor = chartingActor; _counterActors = counterActors; Receive <Subscribe>(subscribe => { if (!_counterActors.ContainsKey(subscribe.CounterType)) { // create a child actor to monitor this counter if one doesn't exist already var counterActor = Context.ActorOf(Props.Create(() => new PerformanceCounterActor(subscribe.CounterType, counterFactory))); // add this counter actor to our index _counterActors[subscribe.CounterType] = counterActor; } // register this series with the ChartingActor _chartingActor.Tell(new AddSeries(seriesFactory.Create(subscribe.CounterType))); // tell the counter actor to begin publishing its statistics to the _chartingActor _counterActors[subscribe.CounterType].Tell(new SubscribeCounter(subscribe.CounterType, _chartingActor)); }); Receive <Unsubscribe>(unsubscribe => { if (!_counterActors.ContainsKey(unsubscribe.CounterType)) { return; } // unsubscribe the ChartingActor from receiving any more updates _counterActors[unsubscribe.CounterType].Tell(new UnsubscribeCounter(unsubscribe.CounterType, _chartingActor)); // remove this series from the ChartingActor _chartingActor.Tell(new RemoveSeries(unsubscribe.CounterType.ToString())); }); }
/// <summary> /// Construct a multi instance counter. /// </summary> /// <param name="factory">The factory used to create the counter.</param> /// <param name="categoryName">The category of the counter.</param> /// <param name="counterName">The name of the counter.</param> /// <param name="instanceName">The name of the instance.</param> /// <param name="readOnly">If true the counter will be read only, otherwise false.</param> public CounterTimer(IPerformanceCounterFactory factory, string categoryName, string counterName, string instanceName, bool readOnly) : this(factory.Create(categoryName, counterName, instanceName, readOnly)) { }
/// <summary> /// Construct a single instance counter. /// </summary> /// <param name="factory">The factory used to create the counter.</param> /// <param name="categoryName">The category of the counter.</param> /// <param name="counterName">The name of the counter.</param> /// <param name="readOnly">If true the counter will be read only, otherwise false.</param> public CounterDelta32(IPerformanceCounterFactory factory, string categoryName, string counterName, bool readOnly) : this(factory.Create(categoryName, counterName, readOnly)) { }
/// <summary> /// Construct a single instance counter. /// </summary> /// <param name="factory">The factory used to create the counter.</param> /// <param name="categoryName">The category of the counter.</param> /// <param name="counterName">The name of the counter.</param> /// <param name="readOnly">If true the counter will be read only, otherwise false.</param> public Timer100NsInverse(IPerformanceCounterFactory factory, string categoryName, string counterName, bool readOnly) : this(factory.Create(categoryName, counterName, readOnly)) { }
/// <summary> /// Construct a read only performance counter on a remote machine. /// </summary> /// <param name="factory">The factory used to create the counter.</param> /// <param name="categoryName">The category of the counter.</param> /// <param name="counterName">The name of the counter.</param> /// <param name="instanceName">The name of the instance.</param> /// <param name="machineName">The machine name.</param> public NumberOfItems32(IPerformanceCounterFactory factory, string categoryName, string counterName, string instanceName, string machineName) : this(factory.Create(categoryName, counterName, instanceName, machineName)) { }
/// <summary> /// Creates the multi instance version of the composite counter. The base suffix is applied to the counter name to create the base performance counter. /// </summary> /// <param name="factory">The factory for creating the counters.</param> /// <param name="categoryName">The category name.</param> /// <param name="counterName">The counter name of the primary couter. The base suffice will be used to create the name of the base counter.</param> /// <param name="instanceName">The instance name.</param> /// <param name="readOnly">If true the counters will be read only, otherwise they will be writeable.</param> public SampleFraction(IPerformanceCounterFactory factory, string categoryName, string counterName, string instanceName, bool readOnly) : this( factory.Create(categoryName, counterName, instanceName, readOnly), factory.Create(categoryName, counterName + CompositeCounterCreator.BaseSuffix, instanceName, readOnly)) { }
private HostNetworkUsageMeter_BatchCounter(IPerformanceCounterFactory counterFactory) { this.counterFactory = counterFactory; }
internal ManagedMemoryMeter(IPerformanceCounterFactory counterFactory, int pid) { this.pid = pid; counter = CreateCounter(counterFactory, pid); }
/// <summary> /// Construct a multi instance counter. /// </summary> /// <param name="factory">The factory used to create the counter.</param> /// <param name="categoryName">The category of the counter.</param> /// <param name="counterName">The name of the counter.</param> /// <param name="instanceName">The name of the instance.</param> /// <param name="readOnly">If true the counter will be read only, otherwise false.</param> public RateOfCountsPerSecond32(IPerformanceCounterFactory factory, string categoryName, string counterName, string instanceName, bool readOnly) : this(factory.Create(categoryName, counterName, instanceName, readOnly)) { }
private LockContentionRateMeter(IPerformanceCounterFactory counterFactory, Func <string> instanceNameProvider) { counter = counterFactory.CreateCounter(Category.ClrLocksAndThreads, "Contention Rate / Sec", instanceNameProvider); }
private DotNetThreadsMeter(IPerformanceCounterFactory factory, Func <string> instanceNameProvider) { physicalThreadsCounter = factory.CreateCounter( Category.ClrLocksAndThreads, "# of current physical Threads", instanceNameProvider); }
/// <summary> /// Creates the composite counter. The base suffix is applied to the counter name to create the base performance counter. /// </summary> /// <param name="factory">The factory for creating the counters.</param> /// <param name="categoryName">The category name.</param> /// <param name="counterName">The counter name of the primary couter. The base suffice will be used to create the name of the base counter.</param> /// <param name="readOnly">If true the counters will be read only, otherwise they will be writeable.</param> public AverageTimer(IPerformanceCounterFactory factory, string categoryName, string counterName, bool readOnly) : this( factory.Create(categoryName, counterName, readOnly), factory.Create(categoryName, counterName + CompositeCounterCreator.BaseSuffix, readOnly)) { }
private AllLogicalDisksMeter(IPerformanceCounterFactory counterFactory) { counter = LogicalDiskMeterHelper .CreateCounters(counterFactory) .BuildForMultipleInstances("*:"); }
/// <summary> /// Construct a read only performance counter on a remote machine. /// </summary> /// <param name="factory">The factory used to create the counter.</param> /// <param name="categoryName">The category of the counter.</param> /// <param name="counterName">The name of the counter.</param> /// <param name="instanceName">The name of the instance.</param> /// <param name="machineName">The machine name.</param> public CounterTimer(IPerformanceCounterFactory factory, string categoryName, string counterName, string instanceName, string machineName) : this(factory.Create(categoryName, counterName, instanceName, machineName)) { }
//------------------------------------------------------------------------------ // // Method: PerformanceCounterMetricLogger (constructor) // //------------------------------------------------------------------------------ /// <summary> /// Initialises a new instance of the ApplicationMetrics.PerformanceCounterMetricLogger class. Note this is an additional constructor to facilitate unit tests, and should not be used to instantiate the class under normal conditions. /// </summary> /// <param name="metricCategoryName">The name of the performance counter category which the metric events should be logged under.</param> /// <param name="metricCategoryDescription">The description of the performance counter category which the metric events should be logged under.</param> /// <param name="bufferProcessingStrategy">Object which implements a processing strategy for the buffers (queues).</param> /// <param name="intervalMetricChecking">Specifies whether an exception should be thrown if the correct order of interval metric logging is not followed (e.g. End() method called before Begin()).</param> /// <param name="counterCreationDataCollection">A test (mock) counter creation data collection object.</param> /// <param name="counterCreationDataFactory">A test (mock) counter creation data factory object.</param> /// <param name="performanceCounterCategory">A test (mock) performance counter category object.</param> /// <param name="performanceCounterFactory">A test (mock) performance counter factory object.</param> /// <param name="dateTime">A test (mock) DateTime object.</param> /// <param name="exceptionHandler">A test (mock) exception handler object.</param> public PerformanceCounterMetricLogger(string metricCategoryName, string metricCategoryDescription, IBufferProcessingStrategy bufferProcessingStrategy, bool intervalMetricChecking, ICounterCreationDataCollection counterCreationDataCollection, ICounterCreationDataFactory counterCreationDataFactory, IPerformanceCounterCategory performanceCounterCategory, IPerformanceCounterFactory performanceCounterFactory, IDateTime dateTime, IExceptionHandler exceptionHandler) { loggerImplementation = new PerformanceCounterMetricLoggerImplementation(metricCategoryName, metricCategoryDescription, bufferProcessingStrategy, intervalMetricChecking, counterCreationDataCollection, counterCreationDataFactory, performanceCounterCategory, performanceCounterFactory, dateTime, exceptionHandler); }
public PerformanceCounterActor(CounterType counterType, IPerformanceCounterFactory performanceCounterFactory) { _performanceCounterFactory = performanceCounterFactory; _counterType = counterType; _subscriptions = new HashSet <IActorRef>(); }
private FileCacheSizeMeter(IPerformanceCounterFactory counterFactory) { counter = counterFactory.CreateCounter("Memory", "System Cache Resident Bytes", string.Empty); }
public PerformanceCounterCoordinatorActor(IActorRef chartingActor, IPerformanceCounterFactory counterFactory, ISeriesFactory seriesFactory) : this(chartingActor, counterFactory, seriesFactory, new Dictionary <CounterType, IActorRef>()) { }
/// <summary> /// Construct a multi instance counter. /// </summary> /// <param name="factory">The factory used to create the counter.</param> /// <param name="categoryName">The category of the counter.</param> /// <param name="counterName">The name of the counter.</param> /// <param name="instanceName">The name of the instance.</param> /// <param name="readOnly">If true the counter will be read only, otherwise false.</param> public NumberOfItems32(IPerformanceCounterFactory factory, string categoryName, string counterName, string instanceName, bool readOnly) : this(factory.Create(categoryName, counterName, instanceName, readOnly)) { }
/// <summary> /// Creates a read only version of the composite counter targeting a specific machine. The base suffix is applied to the counter name to create the base performance counter. /// </summary> /// <param name="factory">The factory for creating the counters.</param> /// <param name="categoryName">The category name.</param> /// <param name="counterName">The counter name of the primary couter. The base suffice will be used to create the name of the base counter.</param> /// <param name="instanceName">The instance name.</param> /// <param name="machineName">The machine name.</param> public AverageTimer(IPerformanceCounterFactory factory, string categoryName, string counterName, string instanceName, string machineName) : this( factory.Create(categoryName, counterName, instanceName, machineName), factory.Create(categoryName, counterName + CompositeCounterCreator.BaseSuffix, instanceName, machineName)) { }
/// <summary> /// Construct a read only performance counter on a remote machine. /// </summary> /// <param name="factory">The factory used to create the counter.</param> /// <param name="categoryName">The category of the counter.</param> /// <param name="counterName">The name of the counter.</param> /// <param name="instanceName">The name of the instance.</param> /// <param name="machineName">The machine name.</param> public RateOfCountsPerSecond32(IPerformanceCounterFactory factory, string categoryName, string counterName, string instanceName, string machineName) : this(factory.Create(categoryName, counterName, instanceName, machineName)) { }