Skip to content

Commit

Permalink
Fix merge issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ToddGrun committed Jan 20, 2024
1 parent 58983c8 commit c53eed4
Showing 1 changed file with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ namespace Microsoft.CodeAnalysis.Telemetry
/// </summary>
internal sealed class TimedTelemetryLogBlock : IDisposable
{
#pragma warning disable IDE0052 // Remove unread private members - Not used in debug builds
private readonly KeyValueLogMessage _logMessage;
private readonly int _minThresholdMs;
#pragma warning disable IDE0052 // Remove unread private members - Not used in debug builds
private readonly ITelemetryLog _telemetryLog;
#pragma warning restore IDE0052 // Remove unread private members
private readonly SharedStopwatch _stopwatch;
#pragma warning restore IDE0052 // Remove unread private members

public TimedTelemetryLogBlock(KeyValueLogMessage logMessage, int minThresholdMs, ITelemetryLog telemetryLog)
{
Expand All @@ -32,6 +32,11 @@ public TimedTelemetryLogBlock(KeyValueLogMessage logMessage, int minThresholdMs,

public void Dispose()
{
// Don't add elapsed information in debug bits or while under debugger.
#if !DEBUG
if (Debugger.IsAttached)
return;

var elapsed = (int)_stopwatch.Elapsed.TotalMilliseconds;
if (elapsed >= _minThresholdMs)
{
Expand All @@ -42,15 +47,9 @@ public void Dispose()
m.AddRange(_logMessage.Properties);
});

#if !DEBUG
// Don't skew telemetry results by logging in debug bits or under debugger.
if (!Debugger.IsAttached)
_telemetryLog.Log(logMessage);
#endif
logMessage.Free();
_telemetryLog.Log(logMessage);
}

_logMessage.Free();
#endif
}
}
}

0 comments on commit c53eed4

Please sign in to comment.