Skip to content

Commit e670c1c

Browse files
andrewlockbouwkast
andauthored
Filter our exit span from Azure Functions tests (#7391)
## Summary of changes Filter out the "exit" span from Azure Functions tests ## Reason for change The presence of the span is flaky, so filter it out to resolve issues. ## Implementation details Our current approach to killing the azure functions sample is a bit hacky, and can sometimes result in us creating a span. This can be reproduced locally in particular. To avoid issues and flakiness around it, just filter out the span. ## Test coverage Covered by existing ## Other details Discovered as part of #7170 --------- Co-authored-by: Steven Bouwkamp <[email protected]>
1 parent 2b385fb commit e670c1c

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AzureFunctionsTests.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,12 @@ public async Task SubmitsTraces()
149149
{
150150
const int expectedSpanCount = 21;
151151
var spans = await agent.WaitForSpansAsync(expectedSpanCount);
152+
var filteredSpans = spans.Where(s => !s.Resource.Equals("Timer ExitApp", StringComparison.OrdinalIgnoreCase)).ToImmutableList();
152153

153154
using var s = new AssertionScope();
154-
spans.Count.Should().Be(expectedSpanCount);
155+
filteredSpans.Count.Should().Be(expectedSpanCount);
155156

156-
await AssertInProcessSpans(spans);
157+
await AssertInProcessSpans(filteredSpans);
157158
}
158159
}
159160
}
@@ -216,10 +217,10 @@ public async Task SubmitsTraces()
216217
{
217218
const int expectedSpanCount = 21;
218219
var spans = await agent.WaitForSpansAsync(expectedSpanCount);
219-
220+
var filteredSpans = spans.Where(s => !s.Resource.Equals("Timer ExitApp", StringComparison.OrdinalIgnoreCase)).ToImmutableList();
220221
using var s = new AssertionScope();
221222

222-
await AssertIsolatedSpans(spans, $"{nameof(AzureFunctionsTests)}.Isolated.V4.Sdk1");
223+
await AssertIsolatedSpans(filteredSpans, $"{nameof(AzureFunctionsTests)}.Isolated.V4.Sdk1");
223224
}
224225
}
225226
}
@@ -282,12 +283,13 @@ public async Task SubmitsTraces()
282283
{
283284
const int expectedSpanCount = 21;
284285
var spans = await agent.WaitForSpansAsync(expectedSpanCount);
286+
var filteredSpans = spans.Where(s => !s.Resource.Equals("Timer ExitApp", StringComparison.OrdinalIgnoreCase)).ToImmutableList();
285287

286288
using var s = new AssertionScope();
287289

288-
await AssertIsolatedSpans(spans);
290+
await AssertIsolatedSpans(filteredSpans);
289291

290-
spans.Count.Should().Be(expectedSpanCount);
292+
filteredSpans.Count.Should().Be(expectedSpanCount);
291293
}
292294
}
293295
}

tracer/test/test-applications/azure-functions/Samples.AzureFunctions.V4Isolated.AspNetCore/Samples.AzureFunctions.V4Isolated.AspNetCore.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.2.0" />
1212
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="2.0.0" />
1313
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Timer" Version="4.3.1" />
14-
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="2.0.0" />
14+
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="2.0.4" />
1515
</ItemGroup>
16+
1617
<!-- Just reducing duplication, we can evolve these separate if we need to later (Program.cs is different here)-->
1718
<ItemGroup>
1819
<Compile Include="..\Samples.AzureFunctions.V4Isolated\AllTriggers.cs" Link="%(RecursiveDir)%(Filename)%(Extension)" />

0 commit comments

Comments
 (0)