Skip to content
Merged
Show file tree
Hide file tree
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 @@ -78,7 +78,7 @@ protected TraceAnnotationsTests(string sampleAppName, bool enableTelemetry, ITes
[SkippableFact]
public async Task SubmitTraces()
{
const int expectedSpanCount = 50;
const int expectedSpanCount = 51;
var ddTraceMethodsString = string.Empty;

foreach (var type in TestTypes)
Expand All @@ -98,7 +98,11 @@ public async Task SubmitTraces()
{
var spans = await agent.WaitForSpansAsync(expectedSpanCount);

var orderedSpans = spans.OrderBy(s => s.Start).ToList();
// Exclude the http span
var orderedSpans = spans
.Where(s => !s.Tags.ContainsKey("http-client-handler-type"))
.OrderBy(s => s.Start)
.ToList();
var rootSpan = orderedSpans.First();
var remainingSpans = orderedSpans.Skip(1).ToList();

Expand Down Expand Up @@ -181,12 +185,10 @@ static Dictionary<string, double> ApmNumericTagsScrubber(MockSpan target, Dictio
[Trait("RunOnWindows", "True")]
public async Task IntegrationDisabled()
{
#if NET6_0
Skip.If(true, "Starting failing after https://github.com/DataDog/dd-trace-dotnet/pull/7287");
#endif
// Don't bother with telemetry in version mismatch scenarios because older versions may only support V1 telemetry
// which we no longer support in our mock telemetry agent
// FIXME: Could be fixed with an upgrade to the NuGet package (after .NET 8?)
EnvironmentHelper.DebugModeEnabled = true;
MockTelemetryAgent telemetry = _enableTelemetry ? this.ConfigureTelemetry() : null;
SetEnvironmentVariable("DD_TRACE_METHODS", string.Empty);
SetEnvironmentVariable("DD_TRACE_ANNOTATIONS_ENABLED", "false");
Expand All @@ -195,7 +197,8 @@ public async Task IntegrationDisabled()
using var process = await RunSampleAndWaitForExit(agent);
var spans = agent.Spans;

Assert.Empty(spans);
// Only the http client spans should be there
spans.Should().OnlyContain(s => s.Tags.ContainsKey("http-client-handler-type"));
if (telemetry != null)
{
await telemetry.AssertIntegrationAsync(IntegrationId.TraceAnnotations, enabled: false, autoEnabled: false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ public static async Task RunTestsAsync()
HttpRequestMessage message = new HttpRequestMessage();
message.Method = HttpMethod.Get;

// trigger a "standard" instrumented integration to ensure that integration telemetry is always sent,
// even when trace annotations are disabled
message.RequestUri = new Uri("http://www.google.com");
var httpClient = new HttpClient();
using var response = await httpClient.SendAsync(message);

Choose a reason for hiding this comment

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

[P1] Remove external HTTP dependency or swallow failures

The sample now performs a real HttpClient.SendAsync call to http://www.google.com but any network failure will throw an exception and abort the sample process. Many CI environments block outbound traffic or resolve slowly, so this introduces a new source of test failures and long timeouts despite the comment that the request success doesn’t matter. Consider wrapping the call in a try/catch (and ignoring failures) or using a local stubbed handler so instrumentation telemetry is triggered without relying on external connectivity.

Useful? React with 👍 / 👎.


// Delay
await Task.Delay(500);

Expand Down
Loading