public PortalDiagnosticsSenderTest() { var configuration = new TelemetryConfiguration(Guid.NewGuid().ToString(), new StubTelemetryChannel { OnSend = item => this.sendItems.Add(item) }); this.nonThrottlingPortalSender = new PortalDiagnosticsSender( configuration, this.dontThrottleManager); this.throttlingPortalSender = new PortalDiagnosticsSender( configuration, this.throttleAllManager); }
public PortalDiagnosticsSenderTest() { var configuration = new TelemetryConfiguration { TelemetryChannel = new StubTelemetryChannel { OnSend = item => this.sendItems.Add(item) }, InstrumentationKey = Guid.NewGuid().ToString() }; this.nonThrottlingPortalSender = new PortalDiagnosticsSender( configuration, this.dontThrottleManager); this.throttlingPortalSender = new PortalDiagnosticsSender( configuration, this.throttleAllManager); }
public void SendNotFailIfChannelNotInitialized() { var configuration = new TelemetryConfiguration(); var portalSenderWithDefaultCOnfiguration = new PortalDiagnosticsSender( configuration, this.dontThrottleManager); var evt = new TraceEvent { MetaData = new EventMetaData { EventId = 10, Keywords = 0x20, Level = EventLevel.Warning, MessageFormat = "Something failed" }, Payload = null }; portalSenderWithDefaultCOnfiguration.Send(evt); }
/// <summary> /// Initializes this telemetry module. /// </summary> /// <param name="configuration">Telemetry configuration to use for this telemetry module.</param> public void Initialize(TelemetryConfiguration configuration) { if (configuration == null) { throw new ArgumentNullException("configuration"); } // Temporary fix to make sure that we initialize module once. // It should be removed when configuration reading logic is moved to Web SDK. if (!this.isInitialized) { lock (this.lockObject) { if (!this.isInitialized) { var queueSender = this.Senders.OfType <PortalDiagnosticsQueueSender>().First(); queueSender.IsDisabled = true; this.Senders.Remove(queueSender); PortalDiagnosticsSender portalSender = new PortalDiagnosticsSender( configuration, new DiagnoisticsEventThrottlingManager <DiagnoisticsEventThrottling>( new DiagnoisticsEventThrottling(DiagnoisticsEventThrottlingDefaults.DefaultThrottleAfterCount), this.throttlingScheduler, DiagnoisticsEventThrottlingDefaults.DefaultThrottlingRecycleIntervalInMinutes)); portalSender.DiagnosticsInstrumentationKey = this.DiagnosticsInstrumentationKey; this.Senders.Add(portalSender); foreach (TraceEvent traceEvent in queueSender.EventData) { portalSender.Send(traceEvent); } this.isInitialized = true; } } } }
public void Initialize(TelemetryConfiguration configuration) { if (configuration == null) { throw new ArgumentNullException("configuration"); } // Temporary fix to make sure that we initialize module once. // It should be removed when configuration reading logic is moved to Web SDK. if (!this.isInitialized) { lock (this.lockObject) { if (!this.isInitialized) { var queueSender = this.Senders.OfType<PortalDiagnosticsQueueSender>().First(); this.Senders.Remove(queueSender); PortalDiagnosticsSender portalSender = new PortalDiagnosticsSender( configuration, new DiagnoisticsEventThrottlingManager<DiagnoisticsEventThrottling>( new DiagnoisticsEventThrottling(DiagnoisticsEventThrottlingDefaults.DefaultThrottleAfterCount), this.throttlingScheduler, DiagnoisticsEventThrottlingDefaults.DefaultThrottlingRecycleIntervalInMinutes)); portalSender.DiagnosticsInstrumentationKey = this.DiagnosticsInstrumentationKey; this.Senders.Add(portalSender); foreach (TraceEvent traceEvent in queueSender.EventData) { portalSender.Send(traceEvent); } this.isInitialized = true; } } } }