/// <summary> /// This executes every time a local configuration change is made. It is more convenient /// that OnConfigurationChanged /// </summary> /// <param name="_"></param> private void AgentConnected(AgentConnectedEvent _) { _spanStreamingService.Shutdown(false); _schedulerSvc.StopExecuting(ReportSupportabilityMetrics); var oldCapacity = (_spanEvents?.Capacity).GetValueOrDefault(0); var oldPartitionCount = (_spanEvents?.PartitionCount).GetValueOrDefault(0); var oldCount = (_spanEvents?.Count).GetValueOrDefault(0); var oldCollection = _spanEvents != null ? Interlocked.Exchange(ref _spanEvents, null) : null; var newCapacity = _configuration.InfiniteTracingQueueSizeSpans; var newPartitionCount = Math.Min(_configuration.InfiniteTracingQueueSizeSpans, _configuration.InfiniteTracingPartitionCountSpans); if (!IsServiceEnabled || newCapacity <= 0 || newPartitionCount <= 0 || newPartitionCount > 62) { if (oldCount > 0) { RecordDroppedSpans(oldCount); } if (IsServiceEnabled) { Log.Info($"SpanEventAggregatorInfiniteTracing: Configuration is invalid - Infinite Tracing will NOT be enabled."); LogConfiguration(); } return; } if (oldCapacity == newCapacity && oldPartitionCount == newPartitionCount && oldCollection != null) { _spanEvents = oldCollection; } else { var overflowCount = oldCount - newCapacity; if (overflowCount > 0) { RecordDroppedSpans(overflowCount); } _spanEvents = oldCollection != null ? new PartitionedBlockingCollection <Span>(newCapacity, newPartitionCount, oldCollection) : new PartitionedBlockingCollection <Span>(newCapacity, newPartitionCount); } LogConfiguration(); _schedulerSvc.ExecuteEvery(ReportSupportabilityMetrics, TimeSpan.FromMinutes(1)); _spanStreamingService.StartConsumingCollection(_spanEvents); }
private void OnAgentConnected(AgentConnectedEvent _) { if (IsEnabled) { _scheduler.ExecuteEvery(Harvest, HarvestCycle); } else { _scheduler.StopExecuting(Harvest, TimeSpan.FromSeconds(2)); } }