Offloaded more work to Task
Removed all unnecesary code if opted out of telemetry. Shanged sample rate to 1 for testing purposes. CI to just regular Test Changed hash helper function to handle a list<string> to optimize unneceary duplicate sha256 creation Reduced new memory allocations
This commit is contained in:
parent
4b905ae2bd
commit
ba13586b1c
1 changed files with 35 additions and 0 deletions
|
@ -58,6 +58,41 @@ namespace Microsoft.DotNet.Cli
|
|||
return;
|
||||
}
|
||||
|
||||
_isCollectingTelemetry = true;
|
||||
try
|
||||
{
|
||||
//initialize in task to offload to parallel thread
|
||||
_trackEventTask = Task.Factory.StartNew(() => InitializeTelemetry());
|
||||
}
|
||||
catch(Exception)
|
||||
{
|
||||
Debug.Fail("Exception during telemetry task initialization");
|
||||
}
|
||||
}
|
||||
|
||||
public void TrackEvent(string eventName, IList<string> properties, IDictionary<string, double> measurements)
|
||||
{
|
||||
if (!_isCollectingTelemetry)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_trackEventTask = _trackEventTask.ContinueWith(
|
||||
() => TrackEventTask(eventName,
|
||||
properties,
|
||||
measurements)
|
||||
);
|
||||
}
|
||||
catch(Exception)
|
||||
{
|
||||
Debug.Fail("Exception during telemetry task continuation");
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeTelemetry()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (PerfTrace.Current.CaptureTiming())
|
||||
|
|
Loading…
Reference in a new issue