Fix InvalidOperationException in Baggage handling in Azure Functions#7810
Merged
andrewlock merged 1 commit intomasterfrom Nov 14, 2025
Merged
Fix InvalidOperationException in Baggage handling in Azure Functions#7810andrewlock merged 1 commit intomasterfrom
InvalidOperationException in Baggage handling in Azure Functions#7810andrewlock merged 1 commit intomasterfrom
Conversation
pablomartinezbernardo
approved these changes
Nov 13, 2025
Execution-Time Benchmarks Report ⏱️Execution-time results for samples comparing This PR (7810) and master. ✅ No regressions detected - check the details below Full Metrics ComparisonFakeDbCommand
HttpMessageHandler
Comparison explanationExecution-time benchmarks measure the whole time it takes to execute a program, and are intended to measure the one-off costs. Cases where the execution time results for the PR are worse than latest master results are highlighted in **red**. The following thresholds were used for comparing the execution times:
Note that these results are based on a single point-in-time result for each branch. For full results, see the dashboard. Graphs show the p99 interval based on the mean and StdDev of the test run, as well as the mean value of the run (shown as a diamond below the graph). Duration chartsFakeDbCommand (.NET Framework 4.8)gantt
title Execution time (ms) FakeDbCommand (.NET Framework 4.8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (7810) - mean (77ms) : 69, 85
master - mean (76ms) : 71, 81
section Bailout
This PR (7810) - mean (83ms) : 75, 92
master - mean (79ms) : 76, 82
section CallTarget+Inlining+NGEN
This PR (7810) - mean (1,108ms) : 1035, 1181
master - mean (1,124ms) : 1044, 1203
FakeDbCommand (.NET Core 3.1)gantt
title Execution time (ms) FakeDbCommand (.NET Core 3.1)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (7810) - mean (118ms) : 109, 126
master - mean (117ms) : 110, 123
section Bailout
This PR (7810) - mean (119ms) : 113, 125
master - mean (119ms) : 112, 127
section CallTarget+Inlining+NGEN
This PR (7810) - mean (796ms) : 751, 841
master - mean (801ms) : 754, 847
FakeDbCommand (.NET 6)gantt
title Execution time (ms) FakeDbCommand (.NET 6)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (7810) - mean (105ms) : 100, 111
master - mean (104ms) : 98, 110
section Bailout
This PR (7810) - mean (107ms) : 99, 115
master - mean (105ms) : 100, 111
section CallTarget+Inlining+NGEN
This PR (7810) - mean (749ms) : 708, 791
master - mean (750ms) : 717, 783
FakeDbCommand (.NET 8)gantt
title Execution time (ms) FakeDbCommand (.NET 8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (7810) - mean (104ms) : 96, 112
master - mean (104ms) : 96, 111
section Bailout
This PR (7810) - mean (105ms) : 98, 112
master - mean (103ms) : 98, 108
section CallTarget+Inlining+NGEN
This PR (7810) - mean (709ms) : 676, 741
master - mean (716ms) : 688, 744
HttpMessageHandler (.NET Framework 4.8)gantt
title Execution time (ms) HttpMessageHandler (.NET Framework 4.8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (7810) - mean (198ms) : 189, 207
master - mean (193ms) : 189, 196
section Bailout
This PR (7810) - mean (198ms) : 194, 202
master - mean (195ms) : 193, 197
section CallTarget+Inlining+NGEN
This PR (7810) - mean (1,168ms) : 1110, 1226
master - mean (1,166ms) : 1106, 1227
HttpMessageHandler (.NET Core 3.1)gantt
title Execution time (ms) HttpMessageHandler (.NET Core 3.1)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (7810) - mean (277ms) : 271, 283
master - mean (277ms) : 271, 282
section Bailout
This PR (7810) - mean (279ms) : 273, 286
master - mean (277ms) : 271, 283
section CallTarget+Inlining+NGEN
This PR (7810) - mean (948ms) : 904, 993
master - mean (942ms) : 895, 988
HttpMessageHandler (.NET 6)gantt
title Execution time (ms) HttpMessageHandler (.NET 6)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (7810) - mean (269ms) : 265, 274
master - mean (270ms) : 264, 276
section Bailout
This PR (7810) - mean (270ms) : 267, 273
master - mean (269ms) : 264, 274
section CallTarget+Inlining+NGEN
This PR (7810) - mean (931ms) : 878, 984
master - mean (930ms) : 877, 983
HttpMessageHandler (.NET 8)gantt
title Execution time (ms) HttpMessageHandler (.NET 8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (7810) - mean (269ms) : 263, 275
master - mean (268ms) : 263, 272
section Bailout
This PR (7810) - mean (268ms) : 265, 271
master - mean (268ms) : 264, 272
section CallTarget+Inlining+NGEN
This PR (7810) - mean (852ms) : 824, 881
master - mean (855ms) : 829, 880
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
lucaspimentel
approved these changes
Nov 13, 2025
pablomartinezbernardo
added a commit
that referenced
this pull request
Nov 18, 2025
## Summary of changes Respect baggage in Azure messaging instrumentations. Related to #7810 ## Reason for change Baggage was not being extracted from headers ## Implementation details ## Test coverage Unit test `AzureFunctionsCommon.ExtractPropagatedContextFromMessaging` with baggage merging. `CreateIsolatedFunctionScope` would have been more complex to test. ## Other details <!-- Fixes #{issue} --> <!--⚠️ Note: Where possible, please obtain 2 approvals prior to merging. Unless CODEOWNERS specifies otherwise, for external teams it is typically best to have one review from a team member, and one review from apm-dotnet. Trivial changes do not require 2 reviews. MergeQueue is NOT enabled in this repository. If you have write access to the repo, the PR has 1-2 approvals (see above), and all of the required checks have passed, you can use the Squash and Merge button to merge the PR. If you don't have write access, or you need help, reach out in the #apm-dotnet channel in Slack. -->
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary of changes
Fixes
InvalidOperationExceptionin baggage handlingReason for change
#7620 added support for event hubs to Azure Functions, but we've subsequently seen errors related to baggage:
We can reproduce this if you pass the same baggage instance to itself in
MergeInto, so we guard against that here.Implementation details
Check that you're not merging into yourself
Test coverage
Added a unit test, confirmed it repros, then fixed it