/// <summary> /// Creates the counter and adds it to the internal collection. /// </summary> /// <param name="name">The name for the new counter.</param> /// <param name="openCounterCount">The open counter count.</param> /// <param name="closeCounterCount">The close counter count.</param> /// <returns>instance of the created counter</returns> protected ExecutionCounter CreateCounter(string name, int openCounterCount, int closeCounterCount) { var counter = new ExecutionCounter(name, openCounterCount, closeCounterCount); _counters.Add(counter); return(counter); }
/// <summary> /// Creates a new instance of the Scheduler class. /// </summary> /// <param name="serviceProvider">Provider of available cloud services</param> /// <param name="schedule">Action to be invoked when a service is scheduled to run</param> public Scheduler(Func<IEnumerable<CloudService>> serviceProvider, Func<CloudService, ServiceExecutionFeedback> schedule) { _serviceProvider = serviceProvider; _schedule = schedule; // Instrumentation ExecutionCounters.Default.RegisterRange(new[] { _countIdleSleep = new ExecutionCounter("Runtime.IdleSleep", 0, 0), _countBusyExecute = new ExecutionCounter("Runtime.BusyExecute", 0, 0) }); }
/// <summary> /// Static Constructor /// </summary> static AzurePolicies() { // Instrumentation ExecutionCounters.Default.RegisterRange(new[] { CountOnTransientServerError = new ExecutionCounter("Policies.ServerErrorRetryWait", 0, 0), CountOnTransientTableError = new ExecutionCounter("Policies.TableErrorRetryWait", 0, 0), CountOnSlowInstantiation = new ExecutionCounter("Policies.SlowInstantiationRetryWait", 0, 0) }); // Initialize Policies TransientServerErrorBackOff = ActionPolicy.With(TransientServerErrorExceptionFilter) .Retry(30, OnTransientServerErrorRetry); TransientTableErrorBackOff = ActionPolicy.With(TransientTableErrorExceptionFilter) .Retry(30, OnTransientTableErrorRetry); SlowInstantiation = ActionPolicy.With(SlowInstantiationExceptionFilter) .Retry(30, OnSlowInstantiationRetry); }
public void Execution_profiles_make_it_to_the_statistics() { var monitor = new ExecutionProfilingMonitor(GlobalSetup.Container.Resolve<ICloudDiagnosticsRepository>()); var statistics = new CloudStatistics(GlobalSetup.Container.Resolve<ICloudDiagnosticsRepository>()); var count = statistics.GetProfilesOfDay(DateTime.UtcNow) .SelectMany(s => s.Statistics) .Where(e => e.Name.Contains("Test Profile")) .Sum(e => e.OpenCount); var counter = new ExecutionCounter("Test Profile", 0, 0); var timestamp = counter.Open(); counter.Close(timestamp); ExecutionCounters.Default.RegisterRange(new[] {counter}); monitor.UpdateDefaultStatistics(); Assert.AreEqual( count + 1, statistics.GetProfilesOfDay(DateTime.UtcNow) .SelectMany(s => s.Statistics) .Where(e => e.Name.Contains("Test Profile")) .Sum(e => e.OpenCount)); }