Refactor GraphQL error response building and add pre-emptive truncation#8647
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7444a8bcae
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Execution-Time Benchmarks Report ⏱️Execution-time results for samples comparing This PR (8647) 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 (8647) - mean (72ms) : 70, 75
master - mean (74ms) : 70, 77
section Bailout
This PR (8647) - mean (78ms) : 75, 81
master - mean (78ms) : 76, 80
section CallTarget+Inlining+NGEN
This PR (8647) - mean (1,094ms) : 1054, 1134
master - mean (1,092ms) : 1049, 1136
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 (8647) - mean (115ms) : 110, 120
master - mean (114ms) : 109, 118
section Bailout
This PR (8647) - mean (117ms) : 114, 120
master - mean (115ms) : 111, 118
section CallTarget+Inlining+NGEN
This PR (8647) - mean (795ms) : 776, 814
master - mean (794ms) : 766, 823
FakeDbCommand (.NET 6)gantt
title Execution time (ms) FakeDbCommand (.NET 6)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8647) - mean (102ms) : 98, 106
master - mean (101ms) : 97, 104
section Bailout
This PR (8647) - mean (105ms) : 100, 109
master - mean (106ms) : 101, 110
section CallTarget+Inlining+NGEN
This PR (8647) - mean (952ms) : 902, 1003
master - mean (957ms) : 916, 997
FakeDbCommand (.NET 8)gantt
title Execution time (ms) FakeDbCommand (.NET 8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8647) - mean (101ms) : 98, 103
master - mean (99ms) : 96, 102
section Bailout
This PR (8647) - mean (102ms) : 99, 105
master - mean (100ms) : 98, 101
section CallTarget+Inlining+NGEN
This PR (8647) - mean (824ms) : 783, 865
master - mean (821ms) : 784, 857
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 (8647) - mean (201ms) : 195, 207
master - mean (199ms) : 193, 206
section Bailout
This PR (8647) - mean (204ms) : 200, 208
master - mean (203ms) : 196, 210
section CallTarget+Inlining+NGEN
This PR (8647) - mean (1,204ms) : 1154, 1253
master - mean (1,199ms) : 1159, 1239
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 (8647) - mean (288ms) : 282, 295
master - mean (288ms) : 283, 294
section Bailout
This PR (8647) - mean (288ms) : 284, 293
master - mean (288ms) : 283, 293
section CallTarget+Inlining+NGEN
This PR (8647) - mean (963ms) : 943, 983
master - mean (966ms) : 948, 983
HttpMessageHandler (.NET 6)gantt
title Execution time (ms) HttpMessageHandler (.NET 6)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8647) - mean (281ms) : 274, 288
master - mean (282ms) : 277, 287
section Bailout
This PR (8647) - mean (282ms) : 273, 291
master - mean (281ms) : 277, 285
section CallTarget+Inlining+NGEN
This PR (8647) - mean (1,166ms) : 1131, 1202
master - mean (1,160ms) : 1127, 1192
HttpMessageHandler (.NET 8)gantt
title Execution time (ms) HttpMessageHandler (.NET 8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8647) - mean (281ms) : 274, 287
master - mean (280ms) : 273, 286
section Bailout
This PR (8647) - mean (282ms) : 277, 287
master - mean (279ms) : 274, 284
section CallTarget+Inlining+NGEN
This PR (8647) - mean (1,044ms) : 1005, 1083
master - mean (1,043ms) : 995, 1090
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
BenchmarksBenchmark execution time: 2026-06-30 10:02:30 Comparing candidate commit 07bd802 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 72 metrics, 0 unstable metrics, 59 known flaky benchmarks, 67 flaky benchmarks without significant changes.
|
7444a8b to
ee8e624
Compare
Snapshots difference summaryThe following differences have been observed in committed snapshots. It is meant to help the reviewer. |
4fb23ce to
8efad41
Compare
This comment has been minimized.
This comment has been minimized.
8efad41 to
07bd802
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 07bd802541
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
|
|
||
| // pre-truncate if we got too large | ||
| var result = builder.ToString(startIndex: 0, length: TruncatorTagsProcessor.MaxMetaValLen); |
There was a problem hiding this comment.
Preserve the truncation marker on oversized errors
For long ASCII GraphQL errors, this slices error.stack down to MaxMetaValLen before the normal tag processor sees it. Since TruncatorTagsProcessor only appends ... when the value still exceeds that limit, these oversized GraphQL errors are silently cut mid-message without the truncation marker used for other span metadata, making diagnostics misleading. Append the ellipsis here or leave the value over the limit for the tag processor to handle.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Meh. I'm not really sure the ellipsis appending is actually the correct approach tbh
Summary of changes
StringBuilderconstinstead of parameter to reduce allocations on concatReason for change
Technically the building of the error tag could become very large. This PR bails out of building the error response if it gets too large. The bail out is not super strict, as this is on a hot path, we just stop adding errors etc if the value exceeds the truncation threshold (25k chars, so pretty unlikely).
While I was in there, I noticed a bunch of places we were not using constants where we could have been, and places where we were using interpolation, which allocates a string, before adding the result to a
StringBuilder, so cleaned that up at the same time.Implementation details
Taba constant on the common base, so we don't have to pass it to functions as a variable, meaning we have compile-time constants added to the builder.Test coverage
Add a couple of simple checks for the basic truncation.
https://datadoghq.atlassian.net/browse/APMSP-3519