This topic has not yet been rated - Rate this topic

PerformanceCounterConfiguration Class

Represents the configuration for performance counter data sources.

Namespace: Microsoft.WindowsAzure.Diagnostics
Assembly: Microsoft.WindowsAzure.Diagnostics (in Microsoft.WindowsAzure.Diagnostics.dll)
'Usage
Dim instance As PerformanceCounterConfiguration

public class PerformanceCounterConfiguration
public class PerformanceCounterConfiguration
public class PerformanceCounterConfiguration

The PerformanceCounterConfiguration class provides properties to configure a performance counter for a role instance. When you create a PerformanceCounterConfiguration object, you add it to the DataSources collection of a DiagnosticMonitorConfiguration object.

Performance counters will be transferred to the WADPerformanceCounters table in persistent storage at the specified interval.

Example

The following code snippet demonstrates how to use PerformanceCounterConfiguration in the context of a role’s OnStart() method. This method creates a new PerformanceCounterConfiguration object, specifies the performance counter and sample rate, adds the configuration to our DiagnosticMonitorConfiguration object, and starts the DiagnosticMonitor.

public override bool OnStart()
{
    // Get the default initial configuration for DiagnosticMonitor.
    DiagnosticMonitorConfiguration diagnosticConfiguration = DiagnosticMonitor.GetDefaultInitialConfiguration();

    // Use 30 seconds for the performance counter sample rate.
    TimeSpan perfSampleRate = TimeSpan.FromSeconds(30.0);

    // Add a performance counter for processor time.
    diagnosticConfiguration.PerformanceCounters.DataSources.Add(new PerformanceCounterConfiguration()
    {
        CounterSpecifier = @"\Processor(_Total)\% Processor Time",
        SampleRate = perfSampleRate
    });

    // Add a performance counter for available memory.
    diagnosticConfiguration.PerformanceCounters.DataSources.Add(new PerformanceCounterConfiguration()
    {
        CounterSpecifier = @"\Memory\Available Bytes",
        SampleRate = perfSampleRate
    });
    
    // Schedule a transfer period of 30 minutes.
    diagnosticConfiguration.PerformanceCounters.ScheduledTransferPeriod = TimeSpan.FromMinutes(30.0);

    // Start the DiagnosticMonitor using the diagnosticConfig and our connection string.
    DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString", diagnosticConfiguration);

    return base.OnStart();
}


System.Object
  Microsoft.WindowsAzure.Diagnostics.PerformanceCounterConfiguration
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Development Platforms

Windows Vista, Windows 7 and Windows Server 2008

Target Platforms

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ