/// <summary> /// Initialize method is called after all configuration properties have been loaded from the configuration. /// </summary> /// <param name="configuration">TelemetryConfiguration passed to the module.</param> public void Initialize(TelemetryConfiguration configuration) { if (!this.isInitialized) { lock (this.moduleInitializationLock) { if (!this.isInitialized) { QuickPulseEventSource.Log.ModuleIsBeingInitializedEvent( this.QuickPulseServiceEndpoint, this.DisableFullTelemetryItems, this.DisableTopCpuProcesses, this.AuthenticationApiKey); QuickPulseEventSource.Log.TroubleshootingMessageEvent("Validating configuration..."); this.ValidateConfiguration(configuration); this.config = configuration; QuickPulseEventSource.Log.TroubleshootingMessageEvent("Initializing members..."); this.collectionTimeSlotManager = this.collectionTimeSlotManager ?? new QuickPulseCollectionTimeSlotManager(); this.performanceCollector = this.performanceCollector ?? (PerformanceCounterUtility.IsWebAppRunningInAzure() ? new WebAppPerformanceCollector() : (IPerformanceCollector) new StandardPerformanceCollector()); this.timeProvider = this.timeProvider ?? new Clock(); this.topCpuCollector = this.topCpuCollector ?? new QuickPulseTopCpuCollector(this.timeProvider, new QuickPulseProcessProvider(PerfLib.GetPerfLib())); this.timings = timings ?? QuickPulseTimings.Default; CollectionConfigurationError[] errors; this.collectionConfiguration = new CollectionConfiguration( new CollectionConfigurationInfo() { ETag = string.Empty }, out errors, this.timeProvider); this.dataAccumulatorManager = this.dataAccumulatorManager ?? new QuickPulseDataAccumulatorManager(this.collectionConfiguration); this.InitializeServiceClient(configuration); this.stateManager = new QuickPulseCollectionStateManager( this.serviceClient, this.timeProvider, this.timings, this.OnStartCollection, this.OnStopCollection, this.OnSubmitSamples, this.OnReturnFailedSamples, this.OnUpdatedConfiguration); this.CreateStateThread(); this.isInitialized = true; } } } }
/// <summary> /// Initializes a new instance of the <see cref="QuickPulseTelemetryModule"/> class. Internal constructor for unit tests only. /// </summary> /// <param name="collectionTimeSlotManager">Collection time slot manager.</param> /// <param name="dataAccumulatorManager">Data hub to sink QuickPulse data to.</param> /// <param name="serviceClient">QPS service client.</param> /// <param name="performanceCollector">Performance counter collector.</param> /// <param name="timings">Timings for the module.</param> internal QuickPulseTelemetryModule( QuickPulseCollectionTimeSlotManager collectionTimeSlotManager, QuickPulseDataAccumulatorManager dataAccumulatorManager, IQuickPulseServiceClient serviceClient, IPerformanceCollector performanceCollector, QuickPulseTimings timings) : this() { this.collectionTimeSlotManager = collectionTimeSlotManager; this.dataAccumulatorManager = dataAccumulatorManager; this.serviceClient = serviceClient; this.performanceCollector = performanceCollector; this.timings = timings; }
public void QuickPulseCollectionTimeSlotManagerHandlesMidPointOfSecond() { // ARRANGE var manager = new QuickPulseCollectionTimeSlotManager(); var now = new DateTimeOffset(2016, 1, 1, 0, 0, 1, TimeSpan.Zero); now = now.AddMilliseconds(500); // ACT DateTimeOffset slot = manager.GetNextCollectionTimeSlot(now); // ASSERT Assert.AreEqual(now.AddSeconds(1), slot); }
/// <summary> /// Initialize method is called after all configuration properties have been loaded from the configuration. /// </summary> /// <param name="configuration">TelemetryConfiguration passed to the module.</param> public void Initialize(TelemetryConfiguration configuration) { if (!this.isInitialized) { lock (this.lockObject) { if (!this.isInitialized) { QuickPulseEventSource.Log.ModuleIsBeingInitializedEvent( string.Format( CultureInfo.InvariantCulture, "QuickPulseServiceEndpoint: '{0}', DisableFullTelemetryItems: '{1}'", this.QuickPulseServiceEndpoint, this.DisableFullTelemetryItems)); QuickPulseEventSource.Log.TroubleshootingMessageEvent("Validating configuration..."); this.ValidateConfiguration(configuration); this.config = configuration; QuickPulseEventSource.Log.TroubleshootingMessageEvent("Initializing members..."); this.collectionTimeSlotManager = this.collectionTimeSlotManager ?? new QuickPulseCollectionTimeSlotManager(); this.dataAccumulatorManager = this.dataAccumulatorManager ?? new QuickPulseDataAccumulatorManager(); this.performanceCollector = this.performanceCollector ?? (PerformanceCounterUtility.IsWebAppRunningInAzure() ? (IPerformanceCollector) new WebAppPerformanceCollector() : (IPerformanceCollector) new StandardPerformanceCollector()); this.timeProvider = this.timeProvider ?? new Clock(); this.timings = timings ?? QuickPulseTimings.Default; this.InitializeServiceClient(configuration); this.stateManager = new QuickPulseCollectionStateManager( this.serviceClient, this.timeProvider, this.timings, this.OnStartCollection, this.OnStopCollection, this.OnSubmitSamples, this.OnReturnFailedSamples); this.CreateStateThread(); this.isInitialized = true; } } } }
/// <summary> /// Initialize method is called after all configuration properties have been loaded from the configuration. /// </summary> /// <param name="configuration">TelemetryConfiguration passed to the module.</param> public void Initialize(TelemetryConfiguration configuration) { if (!this.isInitialized) { lock (this.lockObject) { if (!this.isInitialized) { QuickPulseEventSource.Log.ModuleIsBeingInitializedEvent( string.Format( CultureInfo.InvariantCulture, "QuickPulseServiceEndpoint: '{0}', DisableFullTelemetryItems: '{1}'", this.QuickPulseServiceEndpoint, this.DisableFullTelemetryItems)); QuickPulseEventSource.Log.TroubleshootingMessageEvent("Validating configuration..."); this.ValidateConfiguration(configuration); this.config = configuration; QuickPulseEventSource.Log.TroubleshootingMessageEvent("Initializing members..."); this.collectionTimeSlotManager = this.collectionTimeSlotManager ?? new QuickPulseCollectionTimeSlotManager(); this.dataAccumulatorManager = this.dataAccumulatorManager ?? new QuickPulseDataAccumulatorManager(); this.performanceCollector = this.performanceCollector ?? (PerformanceCounterUtility.IsWebAppRunningInAzure() ? (IPerformanceCollector)new WebAppPerformanceCollector() : (IPerformanceCollector)new StandardPerformanceCollector()); this.timeProvider = this.timeProvider ?? new Clock(); this.timings = timings ?? QuickPulseTimings.Default; this.InitializeServiceClient(configuration); this.stateManager = new QuickPulseCollectionStateManager( this.serviceClient, this.timeProvider, this.timings, this.OnStartCollection, this.OnStopCollection, this.OnSubmitSamples, this.OnReturnFailedSamples); this.CreateStateThread(); this.isInitialized = true; } } } }