Transferring and persisting diagnostic data
As diagnostic data are logged, the data are buffered in memory. In order for us to retain the data for analysis, we need to make sure that the data persists in a proper storage container. This is not set up by default, but it takes only a couple of lines of code to configure the transfer of data into the storage location. We can set this transfer to be either scheduled, or on demand.
To automatically transfer the diagnostic data on a schedule, we just need to add a single line to our role's OnStart
method:
diagConfig.PerformanceCounters.ScheduledTransferPeriod = System.TimeSpan.FromMinutes(1.0)
The entire OnStart
method for our web role now reads like this:
Public Overrides Function OnStart() As Boolean OnStart methodDim diagConfig As DiagnosticMonitorConfiguration = DiagnosticMonitor.GetDefaultInitialConfiguration() Dim procTimeConfig As PerformanceCounterConfiguration = New PerformanceCounterConfiguration() procTimeConfig.CounterSpecifier = "...