This topic has not yet been rated - Rate this topic

PerformanceCounterConfiguration.SampleRate Property

Gets or sets the rate at which to sample the performance counter, rounded up to the nearest second.

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

value = instance.SampleRate

instance.SampleRate = value
public TimeSpan SampleRate { get; set; }
/** @property */
public TimeSpan get_SampleRate ()

/** @property */
public void set_SampleRate (TimeSpan value)

public function get SampleRate () : TimeSpan

public function set SampleRate (value : TimeSpan)

Property Value

Type: System.TimeSpan

Returns TimeSpan.

The SampleRate property specifies the frequency for sampling performance counter data. Note that more frequent sampling may incur additional storage costs when the data is transferred to persistent storage at the specified interval.

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

Example

The following code snippet 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();
}


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