File tree Expand file tree Collapse file tree 1 file changed +1
-15
lines changed
Expand file tree Collapse file tree 1 file changed +1
-15
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,6 @@ public sealed class ApplicationInsightsTarget : TargetWithLayout
2727 {
2828 private TelemetryClient telemetryClient ;
2929 private TelemetryConfiguration telemetryConfiguration ;
30- private DateTime lastLogEventTime ;
3130 private NLog . Layouts . Layout connectionStringLayout = string . Empty ;
3231
3332 /// <summary>
@@ -150,8 +149,6 @@ protected override void Write(LogEventInfo logEvent)
150149 throw new ArgumentNullException ( nameof ( logEvent ) ) ;
151150 }
152151
153- this . lastLogEventTime = DateTime . UtcNow ;
154-
155152 if ( logEvent . Exception != null )
156153 {
157154 // TODO: Uncomment once ExceptionTelemetry is tested and verified.
@@ -181,18 +178,7 @@ protected override void FlushAsync(AsyncContinuation asyncContinuation)
181178
182179 try
183180 {
184- this . TelemetryClient . Flush ( ) ;
185- if ( DateTime . UtcNow . AddSeconds ( - 30 ) > this . lastLogEventTime )
186- {
187- // Nothing has been written, so nothing to wait for
188- asyncContinuation ( null ) ;
189- }
190- else
191- {
192- // Documentation says it is important to wait after flush, else nothing will happen
193- // https://docs.microsoft.com/azure/application-insights/app-insights-api-custom-events-metrics#flushing-data
194- System . Threading . Tasks . Task . Delay ( TimeSpan . FromMilliseconds ( 500 ) ) . ContinueWith ( ( task ) => asyncContinuation ( null ) ) ;
195- }
181+ this . telemetryClient . FlushAsync ( System . Threading . CancellationToken . None ) . ContinueWith ( t => asyncContinuation ( t . Exception ) ) ;
196182 }
197183 catch ( Exception ex )
198184 {
You can’t perform that action at this time.
0 commit comments