-
Notifications
You must be signed in to change notification settings - Fork 165
[Azure Functions] Fix span parenting in ASP.NET Core integration #7628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
lucaspimentel
merged 42 commits into
master
from
lpimentel/APMSVLS-58-azfunc-host-parenting
Apr 23, 2026
Merged
Changes from all commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
f6f4572
add temporary investigation files
lucaspimentel cfaaca7
Fix Azure Functions span parenting via HttpContext.Items
lucaspimentel d144590
refactoring
lucaspimentel 63839cb
update test snapshots
lucaspimentel c700ea4
only apply this fix to azure functions using extension v4
lucaspimentel c632a1a
refactor AspNetCoreDiagObserver initialization
lucaspimentel 6a12825
check if logging is enabled
lucaspimentel 95fb93c
use new HttpContextActiveScopeKey constant
lucaspimentel a5a5ac6
delete temporary investigation files
lucaspimentel 7d855fc
update test snapshots
lucaspimentel 2df5aa0
fix span count in test
lucaspimentel 9103661
remove unused `using` directives
lucaspimentel 658fbe8
use a const string, reorder fields
lucaspimentel 8d2c388
make CreateScope() private
lucaspimentel e62eea2
small clean up / refactor
lucaspimentel 8a55153
more small clean up / refactor
lucaspimentel af95bf7
small refactor
lucaspimentel 45b9849
fix tests
lucaspimentel 95bb694
clean up test code
lucaspimentel 7a99829
re-order const members
lucaspimentel 23f9cd9
clarify comment
lucaspimentel 241d59c
clean up test code
lucaspimentel b583c08
fix parent context priority in isolated worker
lucaspimentel b552197
Fix duplicate span creation in Azure Functions ASP.NET Core mode
lucaspimentel 2f833f6
rename parameter
lucaspimentel 8663bea
Reorder Azure Functions observer skip logic
lucaspimentel e886f0d
Use duck typing for HttpContext in GetAspNetCoreScope
lucaspimentel 3685e45
update expected span counts
lucaspimentel 085be20
fix bad merge
lucaspimentel d32aa62
Update Azure Functions snapshots for new _dd.svc_src tag
lucaspimentel 18ada3a
fix merge conflict
lucaspimentel 773b239
Add comment explaining stale gRPC headers in HTTP proxying mode
lucaspimentel 17707c6
Don't return borrowed ASP.NET Core scope from calltarget state
lucaspimentel 276f842
Change scope retrieval error log from Debug to Error
lucaspimentel a1e54af
Mark Items dictionary values as nullable in duck types
lucaspimentel f99d843
Document source of HttpRequestContext key
lucaspimentel 7b1e57b
Add explicit null checks in ASP.NET Core scope retrieval
lucaspimentel eaa9b88
Set status 500 on aspnet_core.request when isolated worker function t…
lucaspimentel f5672db
Fix CS8613 nullability mismatch in MockFunctionContext.Items
lucaspimentel 40769d0
Update snapshots for aspnet_core.request on exception
lucaspimentel 3af124a
fallback to gRPC headers
lucaspimentel 7b4da9c
Gate gRPC fallback on aspNetCoreScope, not a fake Items key
lucaspimentel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
241 changes: 199 additions & 42 deletions
241
...src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Azure/Functions/AzureFunctionsCommon.cs
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...tadog.Trace/ClrProfiler/AutoInstrumentation/Azure/Functions/Isolated/IHttpContextItems.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| // <copyright file="IHttpContextItems.cs" company="Datadog"> | ||
| // Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. | ||
| // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. | ||
| // </copyright> | ||
|
|
||
| #if !NETFRAMEWORK | ||
| #nullable enable | ||
|
|
||
| using System.Collections.Generic; | ||
|
|
||
| namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Azure.Functions; | ||
|
|
||
| /// <summary> | ||
| /// Duck type for Microsoft.AspNetCore.Http.HttpContext, | ||
| /// used to avoid a hard assembly reference to Microsoft.AspNetCore.Http.Abstractions | ||
| /// which may not be available in non-ASP.NET Core Azure Functions workers. | ||
| /// </summary> | ||
| internal interface IHttpContextItems | ||
| { | ||
| IDictionary<object, object?> Items { get; } | ||
| } | ||
|
|
||
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👍