Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using Datadog.Trace.Configuration;
using Datadog.Trace.TestHelpers;
Expand Down Expand Up @@ -798,7 +799,18 @@ private void AssertNativeLoaderLogContainsString(string logDir, string requiredL
private void AssertHasExpectedTelemetry(string echoLogFileName, ProcessResult processResult, string pointsJson, string injectResult, string injectResultReason, string injectResultClass)
{
using var s = new AssertionScope();
File.Exists(echoLogFileName).Should().BeTrue();

// Wait for the telemetry echo file to be written (with timeout)
// The telemetry forwarder may write the file asynchronously after process exit
var fileWaitTimeout = TimeSpan.FromSeconds(10);
var fileWaitStart = DateTime.UtcNow;
while (!File.Exists(echoLogFileName) && (DateTime.UtcNow - fileWaitStart) < fileWaitTimeout)
{
Thread.Sleep(100);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given this is going to sleep for up to 10s, should we make this an async Task.Delay instead? 🤔

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, that would mitigate the delay. Done!

}

File.Exists(echoLogFileName).Should().BeTrue($"Telemetry echo file should exist at {echoLogFileName} within {fileWaitTimeout.TotalSeconds} seconds");

var echoLogContent = File.ReadAllText(echoLogFileName);
s.AddReportable(echoLogFileName, echoLogContent);

Expand Down
Loading