Fix exception in Kafka on .NET Framework#8366
Conversation
BenchmarksBenchmark execution time: 2026-03-27 19:55:43 Comparing candidate commit dcc705d in PR branch Found 4 performance improvements and 16 performance regressions! Performance is the same for 250 metrics, 18 unstable metrics.
|
| { | ||
| // Restore the original synchronization context. | ||
| SynchronizationContext.SetSynchronizationContext(originalContext); | ||
| } |
There was a problem hiding this comment.
this is literally
please use the extension method.
There was a problem hiding this comment.
Unfortunately it wasn't quite possible 😅 #7702 (comment)
There was a problem hiding this comment.
I don't think these changes were necessary if the IDuckType fix in 7278249 is good enough
tonyredondo
left a comment
There was a problem hiding this comment.
Why aren't we fixing IDuckTypeTask instead?
@tonyredondo Thanks, I modified IDuckTypeTask to |
Well this is now failing the xunit instrumentation tests 😭 |
This reverts commit 7278249. This broke the xunit / MS Test tests and I don't see a clean way to enable both Kafka and them
Execution-Time Benchmarks Report ⏱️Execution-time results for samples comparing This PR (8366) 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 (8366) - mean (72ms) : 69, 76
master - mean (73ms) : 70, 76
section Bailout
This PR (8366) - mean (76ms) : 75, 77
master - mean (76ms) : 75, 78
section CallTarget+Inlining+NGEN
This PR (8366) - mean (1,080ms) : 1021, 1138
master - mean (1,080ms) : 1032, 1129
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 (8366) - mean (112ms) : 109, 116
master - mean (113ms) : 109, 118
section Bailout
This PR (8366) - mean (114ms) : 112, 117
master - mean (113ms) : 110, 117
section CallTarget+Inlining+NGEN
This PR (8366) - mean (796ms) : 778, 815
master - mean (800ms) : 782, 817
FakeDbCommand (.NET 6)gantt
title Execution time (ms) FakeDbCommand (.NET 6)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8366) - mean (100ms) : 97, 103
master - mean (99ms) : 96, 103
section Bailout
This PR (8366) - mean (101ms) : 98, 103
master - mean (100ms) : 97, 103
section CallTarget+Inlining+NGEN
This PR (8366) - mean (787ms) : 769, 806
master - mean (784ms) : 765, 802
FakeDbCommand (.NET 8)gantt
title Execution time (ms) FakeDbCommand (.NET 8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8366) - mean (99ms) : 95, 102
master - mean (99ms) : 96, 101
section Bailout
This PR (8366) - mean (100ms) : 97, 103
master - mean (99ms) : 97, 101
section CallTarget+Inlining+NGEN
This PR (8366) - mean (696ms) : 671, 720
master - mean (692ms) : 668, 715
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 (8366) - mean (223ms) : 211, 234
master - mean (216ms) : 208, 223
section Bailout
This PR (8366) - mean (226ms) : 214, 239
master - mean (221ms) : 213, 229
section CallTarget+Inlining+NGEN
This PR (8366) - mean (1,273ms) : 1219, 1328
master - mean (1,251ms) : 1208, 1294
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 (8366) - mean (321ms) : 305, 337
master - mean (312ms) : 298, 326
section Bailout
This PR (8366) - mean (320ms) : 300, 340
master - mean (313ms) : 301, 324
section CallTarget+Inlining+NGEN
This PR (8366) - mean (1,037ms) : 1010, 1063
master - mean (1,033ms) : 1004, 1062
HttpMessageHandler (.NET 6)gantt
title Execution time (ms) HttpMessageHandler (.NET 6)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8366) - mean (315ms) : 295, 334
master - mean (309ms) : 291, 326
section Bailout
This PR (8366) - mean (315ms) : 293, 338
master - mean (309ms) : 295, 323
section CallTarget+Inlining+NGEN
This PR (8366) - mean (1,087ms) : 984, 1189
master - mean (1,068ms) : 1020, 1116
HttpMessageHandler (.NET 8)gantt
title Execution time (ms) HttpMessageHandler (.NET 8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8366) - mean (306ms) : 291, 321
master - mean (312ms) : 293, 330
section Bailout
This PR (8366) - mean (312ms) : 290, 334
master - mean (312ms) : 292, 332
section CallTarget+Inlining+NGEN
This PR (8366) - mean (1,039ms) : 976, 1103
master - mean (1,034ms) : 955, 1114
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Not supported in .NET Framework
|
Re-requesting reviews as the change has changed |
but... :why:? That seems like there's a bug in the xunit instrumentation tests then though 😟 In general, t would definitely be preferable to be able to check if the task has completed successfully synchronously, as that avoids the whole dangerousness of sync-over-async entirely, though I think in practical terms it's very unlikely to be the path that's taken here... but we probably want it to be an option in the future :/ |
OK, I know why - it's because that type is used to DuckType both So it looks like:
So the main problem here is essentially that we're mixing our duck types, trying to use the same duck type for multiple targets etc. My feelings are:
|
Yep, that is the issue that we can't do both Task/ValueTask in the same DuckType so I'll merge this and then follow up with that |
Summary of changes
Ran Kafka locally as I was attempting to port it to Testcontainers and was actually get exceptions / errors on it, this resolves them (or at least it seems to resolve them). Also noticed them in Error Tracking, but only a single instance, but I'm not 100% sure if it was the same, Error Tracking is linked in the linked Jira Ticket.
Reason for change
Previously this was using
IsCompletedSuccessfullyand then doing a cast and enumeration of all properties and was failing with the following error asIsCompletedSuccessfullyisn't available on .NET Framework:Implementation details
Remove
IsCompletedSuccessfullyfromIDuckTypeTaskas it isn't there on .NET Framework, attempted initially to go with TaskStatus but this caused failures for xUnit/MS Test integration tests as those appear to be using ValueTask, which doesn't have it.Removing
IsCompletedSuccessfullyrequired some more changes toKafkaHelperTest coverage
Applied the fix, re-ran didn't see again, however, the Error Tracking one may be a different bug as it appears that it is on .NET 9.0 😕
Edit: yes appears to be a different error that came up during development that was addressed
Other details
Fixes https://datadoghq.atlassian.net/browse/APMLP-1146