/// <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..."); ValidateConfiguration(configuration); this.config = configuration; QuickPulseEventSource.Log.TroubleshootingMessageEvent("Initializing members..."); this.collectionTimeSlotManager = this.collectionTimeSlotManager ?? new QuickPulseCollectionTimeSlotManager(); this.performanceCollector = this.performanceCollector ?? PerformanceCounterUtility.GetPerformanceCollector(); this.timeProvider = this.timeProvider ?? new Clock(); this.topCpuCollector = this.topCpuCollector ?? new QuickPulseTopCpuCollector(this.timeProvider, new QuickPulseProcessProvider(PerfLib.GetPerfLib())); this.timings = this.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.OnUpdatedServiceEndpoint); this.CreateStateThread(); this.IsInitialized = true; } } } }
void IQuickPulseTelemetryProcessor.StartCollection(IQuickPulseDataAccumulatorManager accumulatorManager, Uri serviceEndpoint, TelemetryConfiguration configuration) { if (this.isCollecting) { throw new InvalidOperationException("Can't start collection while it is already running."); } this.dataAccumulatorManager = accumulatorManager; this.serviceEndpoint = serviceEndpoint; this.config = configuration; this.isCollecting = 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; }
/// <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( this.QuickPulseServiceEndpoint, this.DisableFullTelemetryItems, this.DisableTopCpuProcesses); 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.topCpuCollector = this.topCpuCollector ?? new QuickPulseTopCpuCollector(this.timeProvider, new QuickPulseProcessProvider(PerfLib.GetPerfLib())); 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 ?? new PerformanceCollector(); 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; } } } }
void IQuickPulseTelemetryProcessor.StopCollection() { this.dataAccumulatorManager = null; this.isCollecting = false; }
/// <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; } } } }