Skip to content
Merged
12 changes: 10 additions & 2 deletions tracer/test/Datadog.Trace.TestHelpers/CustomTestFramework.cs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,15 @@ protected override async Task<RunSummary> RunTestCaseAsync(IXunitTestCase testCa
}

_diagnosticMessageSink.OnMessage(new DiagnosticMessage($"RETRYING: {test} ({attemptsRemaining} attempts remaining, {retryReason})"));
var testFullName = $"{TestMethod.TestClass.Class.Name}.{testCase.DisplayName}";
var testFullName = (testCase.DisplayName.StartsWith(TestMethod.TestClass.Class.Name) ?
testCase.DisplayName :
$"{TestMethod.TestClass.Class.Name}.{testCase.DisplayName}").Trim();

if (testFullName.Length > 200)
Copy link
Collaborator

Choose a reason for hiding this comment

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

For readability in the future can we just extract 200 to some variable to note that it is the maximum name length? var maxTestNameLength = 200

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good idea! Done!

{
testFullName = testFullName.Substring(0, 200);
}

await SendMetric(_diagnosticMessageSink, "dd_trace_dotnet.ci.tests.retries", testFullName, retryReason);
}
}
Expand Down Expand Up @@ -349,7 +357,7 @@ async Task SendMetric(IMessageSink outputHelper, string metricName, string testF
var tags = $$"""
"os.platform:{{SanitizeTagValue(FrameworkDescription.Instance.OSPlatform)}}",
"os.architecture:{{SanitizeTagValue(EnvironmentTools.GetPlatform())}}",
"target.framework:{{SanitizeTagValue(FrameworkDescription.Instance.ProductVersion)}}",
"target.framework:{FrameworkDescription.Instance.ProductVersion}",
"test.name:{{SanitizeTagValue(testFullName)}}",
"git.branch:{{SanitizeTagValue(Environment.GetEnvironmentVariable("DD_LOGGER_BUILD_SOURCEBRANCH"))}}",
"flaky_retry_reason: {{SanitizeTagValue(reason)}}"
Expand Down
Loading