[OTLP Logs] Fix ArgumentOutOfRangeException serializing large log batches (pooled buffers) - #8862
[OTLP Logs] Fix ArgumentOutOfRangeException serializing large log batches (pooled buffers)#8862NachoEchevarria wants to merge 13 commits into
Conversation
BenchmarksBenchmark execution time: 2026-07-30 14:33:27 Comparing candidate commit 438411b in PR branch Found 1 performance improvements and 2 performance regressions! Performance is the same for 69 metrics, 0 unstable metrics, 62 known flaky benchmarks, 64 flaky benchmarks without significant changes.
|
Execution-Time Benchmarks Report ⏱️Execution-time results for samples comparing This PR (8862) 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 (8862) - mean (74ms) : 70, 78
master - mean (73ms) : 69, 77
section Bailout
This PR (8862) - mean (79ms) : 75, 83
master - mean (76ms) : 74, 78
section CallTarget+Inlining+NGEN
This PR (8862) - mean (1,091ms) : 1046, 1136
master - mean (1,092ms) : 1039, 1146
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 (8862) - mean (115ms) : 109, 122
master - mean (112ms) : 106, 118
section Bailout
This PR (8862) - mean (113ms) : 108, 117
master - mean (112ms) : 109, 114
section CallTarget+Inlining+NGEN
This PR (8862) - mean (786ms) : 768, 805
master - mean (787ms) : 765, 809
FakeDbCommand (.NET 6)gantt
title Execution time (ms) FakeDbCommand (.NET 6)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8862) - mean (103ms) : 97, 109
master - mean (98ms) : 95, 100
section Bailout
This PR (8862) - mean (100ms) : 95, 105
master - mean (102ms) : 96, 109
section CallTarget+Inlining+NGEN
This PR (8862) - mean (947ms) : 903, 991
master - mean (948ms) : 913, 984
FakeDbCommand (.NET 8)gantt
title Execution time (ms) FakeDbCommand (.NET 8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8862) - mean (97ms) : 94, 100
master - mean (97ms) : 92, 102
section Bailout
This PR (8862) - mean (102ms) : 96, 107
master - mean (97ms) : 95, 99
section CallTarget+Inlining+NGEN
This PR (8862) - mean (825ms) : 787, 864
master - mean (823ms) : 781, 866
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 (8862) - mean (208ms) : 203, 214
master - mean (201ms) : 196, 205
section Bailout
This PR (8862) - mean (212ms) : 209, 216
master - mean (204ms) : 201, 208
section CallTarget+Inlining+NGEN
This PR (8862) - mean (1,248ms) : 1203, 1293
master - mean (1,206ms) : 1171, 1240
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 (8862) - mean (301ms) : 295, 306
master - mean (287ms) : 280, 294
section Bailout
This PR (8862) - mean (301ms) : 297, 305
master - mean (288ms) : 285, 292
section CallTarget+Inlining+NGEN
This PR (8862) - mean (996ms) : 983, 1010
master - mean (965ms) : 944, 985
HttpMessageHandler (.NET 6)gantt
title Execution time (ms) HttpMessageHandler (.NET 6)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8862) - mean (294ms) : 289, 299
master - mean (281ms) : 276, 287
section Bailout
This PR (8862) - mean (294ms) : 291, 298
master - mean (281ms) : 275, 287
section CallTarget+Inlining+NGEN
This PR (8862) - mean (1,197ms) : 1162, 1232
master - mean (1,164ms) : 1118, 1210
HttpMessageHandler (.NET 8)gantt
title Execution time (ms) HttpMessageHandler (.NET 8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8862) - mean (294ms) : 288, 300
master - mean (279ms) : 272, 285
section Bailout
This PR (8862) - mean (294ms) : 290, 299
master - mean (279ms) : 274, 284
section CallTarget+Inlining+NGEN
This PR (8862) - mean (1,071ms) : 1019, 1122
master - mean (1,042ms) : 1002, 1081
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return writePosition; | ||
| } | ||
|
|
||
| private static string GetAttributeValue(object? value) |
There was a problem hiding this comment.
Gah, this is annoying 😅 Ah well
There was a problem hiding this comment.
It's a valid point but I agree it's annoying 😅
Co-authored-by: Andrew Lock <andrew.lock@datadoghq.com>
Co-authored-by: Andrew Lock <andrew.lock@datadoghq.com>
Co-authored-by: Andrew Lock <andrew.lock@datadoghq.com>
Summary of changes
Fix an
ArgumentOutOfRangeExceptionwhen serializing OTLP log batches that exceed 64 KB, and serialize into a pooled, growable buffer bounded at 3 MB.Seen here.
This is an alternative version with pooled buffers of this PR
Reason for change
OtlpLogsSerializerwrote into a fixed 64 KB buffer with no bounds checking or resizing. Once a batch's serialized size crossed 64 KB, the next write threwArgumentOutOfRangeException(surfacing inWriteLogRecorddue to inlining), the batch failed to send, and it was dropped.This is rare in practice — error tracking shows very few occurrences — but when it does happen it's a hard failure that silently drops the batch, so it's worth guarding against.
Implementation details
Test coverage
Other details