/// <summary> /// Rebinds performance counters to Windows resources. /// </summary> public void RefreshPerformanceCounter(PerformanceCounterData pcd, PerformanceCounter pc) { this.performanceCounters.Remove(pcd); this.RegisterPerformanceCounter( pcd.OriginalString, pcd.ReportAs, pc.CategoryName, pc.CounterName, pc.InstanceName, pcd.UsesInstanceNamePlaceholder, pcd.IsCustomCounter); }
private void RefreshCounter( PerformanceCounterData pcd, IEnumerable<string> win32Instances, IEnumerable<string> clrInstances) { string dummy; bool usesInstanceNamePlaceholder; var pc = this.CreateCounter( pcd.OriginalString, win32Instances, clrInstances, out usesInstanceNamePlaceholder, out dummy); try { this.collector.RefreshPerformanceCounter(pcd, pc); PerformanceCollectorEventSource.Log.CounterRegisteredEvent( PerformanceCounterUtility.FormatPerformanceCounter(pc)); } catch (InvalidOperationException e) { PerformanceCollectorEventSource.Log.CounterRegistrationFailedEvent( e.Message, PerformanceCounterUtility.FormatPerformanceCounter(pc)); } }
/// <summary> /// Creates a metric telemetry associated with the PerformanceCounterData, with the respective float value. /// </summary> /// <param name="pc">PerformanceCounterData for which we are generating the telemetry.</param> /// <param name="value">The metric value for the respective performance counter data.</param> /// <returns>Metric telemetry object associated with the specific counter.</returns> private MetricTelemetry CreateTelemetry(PerformanceCounterData pc, double value) { var metricName = !string.IsNullOrWhiteSpace(pc.ReportAs) ? pc.ReportAs : string.Format( CultureInfo.InvariantCulture, "{0} - {1}", pc.CategoryName, pc.CounterName); var metricTelemetry = new MetricTelemetry() { Name = metricName, Count = 1, Sum = value, Min = value, Max = value, StandardDeviation = 0 }; metricTelemetry.Properties.Add("CounterInstanceName", pc.InstanceName); metricTelemetry.Properties.Add("CustomPerfCounter", "true"); return metricTelemetry; }
public void RefreshPerformanceCounter(PerformanceCounterData pcd) { }