Skip to content

Fix Serilog direct log submission failing when writing unknown custom properties#8010

Merged
bouwkast merged 2 commits intomasterfrom
steven/serilog-no-log-fix
Jan 5, 2026
Merged

Fix Serilog direct log submission failing when writing unknown custom properties#8010
bouwkast merged 2 commits intomasterfrom
steven/serilog-no-log-fix

Conversation

@bouwkast
Copy link
Collaborator

@bouwkast bouwkast commented Dec 23, 2025

Summary of changes

This fixes a JsonWriterException that we were hitting when attempting to serialize custom properties in Serilog log messages when we had Direct Log Submission enabled. This would then result in direct log submission to stop working.

Reason for change

When writing a custom property in Serilog we only write the JSON when Debug logging is enabled, when it isn't enabled we actually end up putting the writer into an invalid state, we then hit the following exception:

2025-12-23 16:04:16.209 -05:00 [ERR] An error occured sending logs to Datadog Datadog.Trace.Vendors.Newtonsoft.Json.JsonWriterException: Token PropertyName in state Property would result in an invalid JSON object. Path ''.
   at Datadog.Trace.Vendors.Newtonsoft.Json.JsonWriter.AutoComplete(JsonToken tokenBeingWritten) in C:\Users\steven.bouwkamp\source\repos\dd-trace-dotnet2\tracer\src\Datadog.Trace\Vendors\Newtonsoft.Json\JsonWriter.cs:line 880
   at Datadog.Trace.Vendors.Newtonsoft.Json.JsonWriter.InternalWritePropertyName(String name) in C:\Users\steven.bouwkamp\source\repos\dd-trace-dotnet2\tracer\src\Datadog.Trace\Vendors\Newtonsoft.Json\JsonWriter.cs:line 1760
   at Datadog.Trace.Vendors.Newtonsoft.Json.JsonTextWriter.WritePropertyName(String name, Boolean escape) in C:\Users\steven.bouwkamp\source\repos\dd-trace-dotnet2\tracer\src\Datadog.Trace\Vendors\Newtonsoft.Json\JsonTextWriter.cs:line 291
   at Datadog.Trace.Logging.DirectSubmission.Formatting.LogFormatter.FormatLog[T](StringBuilder builder, T& state, DateTime timestamp, String message, Nullable`1 eventId, String logLevel, Exception exception, FormatDelegate`1 renderPropertiesDelegate) in C:\Users\steven.bouwkamp\source\repos\dd-trace-dotnet2\tracer\src\Datadog.Trace\Logging\DirectSubmission\Formatting\LogFormatter.cs:line 335
   at Datadog.Trace.ClrProfiler.AutoInstrumentation.Logging.Serilog.DirectSubmission.Formatting.SerilogLogFormatter.FormatLogEvent(LogFormatter logFormatter, StringBuilder sb, ILogEvent logEvent) in C:\Users\steven.bouwkamp\source\repos\dd-trace-dotnet2\tracer\src\Datadog.Trace\ClrProfiler\AutoInstrumentation\Logging\Serilog\DirectSubmission\Formatting\SerilogLogFormatter.cs:line 26
   at Datadog.Trace.ClrProfiler.AutoInstrumentation.Logging.Serilog.DirectSubmission.SerilogDirectSubmissionLogEvent.Format(StringBuilder sb, LogFormatter formatter) in C:\Users\steven.bouwkamp\source\repos\dd-trace-dotnet2\tracer\src\Datadog.Trace\ClrProfiler\AutoInstrumentation\Logging\Serilog\DirectSubmission\SerilogDirectSubmissionLogEvent.cs:line 25
   at Datadog.Trace.Logging.DirectSubmission.Sink.DirectSubmissionLogSink.EmitBatch(Queue`1 events) in C:\Users\steven.bouwkamp\source\repos\dd-trace-dotnet2\tracer\src\Datadog.Trace\Logging\DirectSubmission\Sink\DirectSubmissionLogSink.cs:line 103
 { MachineName: ".", Process: "[100360 dotnet]", AppDomain: "[1 LogsInjection.Serilog]", AssemblyLoadContext: "\"\" Datadog.Trace.ClrProfiler.Managed.Loader.ManagedProfilerAssemblyLoadContext #1", TracerVersion: "3.35.0.0" }

From what I can tell this causes direct log submission to stop working.

I've seen this in Error Tracking and it may be related to a customer escalation regarding issues with Serilog direct log submission to seemingly stop working.

Implementation details

Test coverage

I've reproduced this, but it is strange, I guess Serilog doesn't actually support this? I don't understand completely what was going on, but if I added a custom property and enriched all logs with it but did not have direct log submission enabled there would be no logs found in the tests but they did make it to the file. 😕

Other details

I only toggled this custom property on when direct log submission is enabled due to the above Test Coverage note.

not writing the log causes the writer to get into an invalid state
This seems to break Serilog? But we handle it
differently, but previously this was causing direct log submission
to die.
@dd-trace-dotnet-ci-bot
Copy link

Execution-Time Benchmarks Report ⏱️

Execution-time results for samples comparing This PR (8010) and master.

✅ No regressions detected - check the details below

Full Metrics Comparison

FakeDbCommand

Metric Master (Mean ± 95% CI) Current (Mean ± 95% CI) Change Status
.NET Framework 4.8 - Baseline
duration68.24 ± (68.23 - 68.42) ms68.44 ± (68.49 - 68.72) ms+0.3%✅⬆️
.NET Framework 4.8 - Bailout
duration71.98 ± (71.93 - 72.16) ms72.14 ± (72.17 - 72.43) ms+0.2%✅⬆️
.NET Framework 4.8 - CallTarget+Inlining+NGEN
duration1004.14 ± (1010.66 - 1020.72) ms1003.64 ± (1006.63 - 1014.49) ms-0.1%
.NET Core 3.1 - Baseline
process.internal_duration_ms22.02 ± (21.98 - 22.06) ms21.89 ± (21.86 - 21.92) ms-0.6%
process.time_to_main_ms78.78 ± (78.61 - 78.95) ms78.40 ± (78.27 - 78.54) ms-0.5%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.91 ± (10.90 - 10.91) MB10.89 ± (10.88 - 10.89) MB-0.2%
runtime.dotnet.threads.count12 ± (12 - 12)12 ± (12 - 12)+0.0%
.NET Core 3.1 - Bailout
process.internal_duration_ms21.93 ± (21.91 - 21.96) ms21.81 ± (21.78 - 21.83) ms-0.6%
process.time_to_main_ms79.86 ± (79.78 - 79.95) ms79.76 ± (79.65 - 79.86) ms-0.1%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.94 ± (10.94 - 10.95) MB10.92 ± (10.91 - 10.92) MB-0.2%
runtime.dotnet.threads.count13 ± (13 - 13)13 ± (13 - 13)+0.0%
.NET Core 3.1 - CallTarget+Inlining+NGEN
process.internal_duration_ms210.36 ± (208.88 - 211.85) ms211.39 ± (209.36 - 213.43) ms+0.5%✅⬆️
process.time_to_main_ms471.25 ± (470.64 - 471.87) ms471.46 ± (470.89 - 472.04) ms+0.0%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed48.09 ± (48.07 - 48.12) MB48.14 ± (48.11 - 48.16) MB+0.1%✅⬆️
runtime.dotnet.threads.count28 ± (28 - 28)28 ± (28 - 28)+0.0%
.NET 6 - Baseline
process.internal_duration_ms20.79 ± (20.77 - 20.82) ms20.64 ± (20.62 - 20.67) ms-0.7%
process.time_to_main_ms68.40 ± (68.26 - 68.54) ms67.94 ± (67.81 - 68.07) ms-0.7%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.59 ± (10.58 - 10.59) MB10.62 ± (10.61 - 10.62) MB+0.3%✅⬆️
runtime.dotnet.threads.count10 ± (10 - 10)10 ± (10 - 10)+0.0%
.NET 6 - Bailout
process.internal_duration_ms20.72 ± (20.70 - 20.75) ms20.60 ± (20.58 - 20.62) ms-0.6%
process.time_to_main_ms69.16 ± (69.10 - 69.23) ms68.89 ± (68.82 - 68.95) ms-0.4%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.71 ± (10.71 - 10.72) MB10.67 ± (10.66 - 10.67) MB-0.4%
runtime.dotnet.threads.count11 ± (11 - 11)11 ± (11 - 11)+0.0%
.NET 6 - CallTarget+Inlining+NGEN
process.internal_duration_ms200.41 ± (199.51 - 201.32) ms200.52 ± (199.38 - 201.67) ms+0.1%✅⬆️
process.time_to_main_ms440.66 ± (439.87 - 441.44) ms439.46 ± (438.84 - 440.08) ms-0.3%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed48.45 ± (48.40 - 48.50) MB48.41 ± (48.35 - 48.47) MB-0.1%
runtime.dotnet.threads.count28 ± (28 - 28)28 ± (28 - 28)+0.0%✅⬆️
.NET 8 - Baseline
process.internal_duration_ms18.82 ± (18.79 - 18.85) ms18.81 ± (18.79 - 18.84) ms-0.0%
process.time_to_main_ms67.21 ± (67.10 - 67.31) ms67.19 ± (67.06 - 67.32) ms-0.0%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed7.65 ± (7.65 - 7.66) MB7.66 ± (7.66 - 7.66) MB+0.1%✅⬆️
runtime.dotnet.threads.count10 ± (10 - 10)10 ± (10 - 10)+0.0%
.NET 8 - Bailout
process.internal_duration_ms18.70 ± (18.68 - 18.73) ms18.87 ± (18.84 - 18.89) ms+0.9%✅⬆️
process.time_to_main_ms68.06 ± (68.01 - 68.11) ms68.46 ± (68.38 - 68.53) ms+0.6%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed7.72 ± (7.71 - 7.73) MB7.73 ± (7.71 - 7.74) MB+0.1%✅⬆️
runtime.dotnet.threads.count11 ± (11 - 11)11 ± (11 - 11)+0.0%
.NET 8 - CallTarget+Inlining+NGEN
process.internal_duration_ms179.05 ± (178.19 - 179.90) ms178.52 ± (177.58 - 179.46) ms-0.3%
process.time_to_main_ms422.60 ± (422.13 - 423.07) ms423.26 ± (422.70 - 423.83) ms+0.2%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed36.31 ± (36.28 - 36.34) MB36.31 ± (36.28 - 36.34) MB-0.0%
runtime.dotnet.threads.count27 ± (27 - 27)27 ± (27 - 27)-0.0%

HttpMessageHandler

Metric Master (Mean ± 95% CI) Current (Mean ± 95% CI) Change Status
.NET Framework 4.8 - Baseline
duration193.39 ± (193.35 - 194.00) ms193.29 ± (193.18 - 193.99) ms-0.1%
.NET Framework 4.8 - Bailout
duration196.97 ± (196.95 - 197.77) ms197.11 ± (196.90 - 197.49) ms+0.1%✅⬆️
.NET Framework 4.8 - CallTarget+Inlining+NGEN
duration1111.82 ± (1115.44 - 1124.23) ms1107.42 ± (1110.23 - 1118.10) ms-0.4%
.NET Core 3.1 - Baseline
process.internal_duration_ms189.44 ± (189.00 - 189.88) ms188.81 ± (188.40 - 189.21) ms-0.3%
process.time_to_main_ms80.86 ± (80.65 - 81.08) ms80.78 ± (80.56 - 81.01) ms-0.1%
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed16.08 ± (16.06 - 16.11) MB16.12 ± (16.09 - 16.14) MB+0.2%✅⬆️
runtime.dotnet.threads.count20 ± (20 - 20)20 ± (20 - 20)-0.1%
.NET Core 3.1 - Bailout
process.internal_duration_ms187.26 ± (187.02 - 187.50) ms188.53 ± (188.07 - 189.00) ms+0.7%✅⬆️
process.time_to_main_ms82.11 ± (81.95 - 82.27) ms82.13 ± (81.92 - 82.33) ms+0.0%✅⬆️
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed16.17 ± (16.14 - 16.19) MB16.14 ± (16.11 - 16.17) MB-0.2%
runtime.dotnet.threads.count21 ± (21 - 21)21 ± (21 - 21)-0.2%
.NET Core 3.1 - CallTarget+Inlining+NGEN
process.internal_duration_ms398.17 ± (395.26 - 401.08) ms393.27 ± (390.81 - 395.72) ms-1.2%
process.time_to_main_ms474.49 ± (473.87 - 475.11) ms475.56 ± (474.87 - 476.24) ms+0.2%✅⬆️
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed58.08 ± (57.93 - 58.24) MB58.54 ± (58.37 - 58.71) MB+0.8%✅⬆️
runtime.dotnet.threads.count29 ± (29 - 29)29 ± (29 - 30)+0.1%✅⬆️
.NET 6 - Baseline
process.internal_duration_ms192.09 ± (191.70 - 192.47) ms192.12 ± (191.73 - 192.50) ms+0.0%✅⬆️
process.time_to_main_ms69.83 ± (69.64 - 70.01) ms70.10 ± (69.95 - 70.25) ms+0.4%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed16.20 ± (16.08 - 16.32) MB16.13 ± (15.99 - 16.27) MB-0.4%
runtime.dotnet.threads.count19 ± (18 - 19)19 ± (19 - 19)+0.9%✅⬆️
.NET 6 - Bailout
process.internal_duration_ms191.49 ± (191.16 - 191.82) ms190.78 ± (190.55 - 191.02) ms-0.4%
process.time_to_main_ms70.81 ± (70.70 - 70.92) ms70.78 ± (70.69 - 70.88) ms-0.0%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed16.27 ± (16.16 - 16.39) MB16.24 ± (16.11 - 16.37) MB-0.2%
runtime.dotnet.threads.count19 ± (19 - 20)20 ± (19 - 20)+1.7%✅⬆️
.NET 6 - CallTarget+Inlining+NGEN
process.internal_duration_ms411.39 ± (408.89 - 413.89) ms407.59 ± (405.31 - 409.87) ms-0.9%
process.time_to_main_ms445.57 ± (444.98 - 446.16) ms443.62 ± (443.11 - 444.13) ms-0.4%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed59.30 ± (59.19 - 59.42) MB58.86 ± (58.71 - 59.00) MB-0.8%
runtime.dotnet.threads.count30 ± (29 - 30)30 ± (29 - 30)+0.0%✅⬆️
.NET 8 - Baseline
process.internal_duration_ms190.85 ± (190.48 - 191.21) ms189.77 ± (189.49 - 190.05) ms-0.6%
process.time_to_main_ms69.52 ± (69.35 - 69.70) ms69.48 ± (69.32 - 69.64) ms-0.1%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed11.73 ± (11.70 - 11.76) MB11.76 ± (11.73 - 11.79) MB+0.2%✅⬆️
runtime.dotnet.threads.count18 ± (18 - 18)18 ± (18 - 18)-0.2%
.NET 8 - Bailout
process.internal_duration_ms189.72 ± (189.46 - 189.97) ms189.17 ± (188.90 - 189.44) ms-0.3%
process.time_to_main_ms70.35 ± (70.26 - 70.44) ms70.54 ± (70.44 - 70.65) ms+0.3%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed11.86 ± (11.83 - 11.89) MB11.82 ± (11.79 - 11.84) MB-0.4%
runtime.dotnet.threads.count19 ± (19 - 19)19 ± (19 - 19)-0.3%
.NET 8 - CallTarget+Inlining+NGEN
process.internal_duration_ms365.97 ± (364.58 - 367.35) ms366.23 ± (364.57 - 367.89) ms+0.1%✅⬆️
process.time_to_main_ms427.54 ± (426.84 - 428.25) ms427.73 ± (427.22 - 428.24) ms+0.0%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed47.98 ± (47.95 - 48.01) MB47.94 ± (47.90 - 47.97) MB-0.1%
runtime.dotnet.threads.count29 ± (29 - 29)29 ± (29 - 29)-0.1%
Comparison explanation

Execution-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:

  • Welch test with statistical test for significance of 5%
  • Only results indicating a difference greater than 5% and 5 ms are considered.

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 charts
FakeDbCommand (.NET Framework 4.8)
gantt
    title Execution time (ms) FakeDbCommand (.NET Framework 4.8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8010) - mean (69ms)  : 67, 70
    master - mean (68ms)  : 67, 70

    section Bailout
    This PR (8010) - mean (72ms)  : 71, 74
    master - mean (72ms)  : 71, 73

    section CallTarget+Inlining+NGEN
    This PR (8010) - mean (1,011ms)  : 954, 1067
    master - mean (1,016ms)  : 942, 1090

Loading
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 (8010) - mean (106ms)  : 102, 109
    master - mean (106ms)  : 104, 108

    section Bailout
    This PR (8010) - mean (107ms)  : 105, 108
    master - mean (107ms)  : 106, 108

    section CallTarget+Inlining+NGEN
    This PR (8010) - mean (710ms)  : 673, 747
    master - mean (710ms)  : 683, 736

Loading
FakeDbCommand (.NET 6)
gantt
    title Execution time (ms) FakeDbCommand (.NET 6)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8010) - mean (93ms)  : 91, 95
    master - mean (94ms)  : 92, 96

    section Bailout
    This PR (8010) - mean (94ms)  : 93, 96
    master - mean (95ms)  : 93, 96

    section CallTarget+Inlining+NGEN
    This PR (8010) - mean (668ms)  : 647, 689
    master - mean (668ms)  : 635, 701

Loading
FakeDbCommand (.NET 8)
gantt
    title Execution time (ms) FakeDbCommand (.NET 8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8010) - mean (92ms)  : 89, 95
    master - mean (92ms)  : 90, 94

    section Bailout
    This PR (8010) - mean (93ms)  : 92, 95
    master - mean (93ms)  : 91, 94

    section CallTarget+Inlining+NGEN
    This PR (8010) - mean (628ms)  : 614, 642
    master - mean (629ms)  : 614, 644

Loading
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 (8010) - mean (194ms)  : 190, 197
    master - mean (194ms)  : 190, 197

    section Bailout
    This PR (8010) - mean (197ms)  : 194, 200
    master - mean (197ms)  : 193, 201

    section CallTarget+Inlining+NGEN
    This PR (8010) - mean (1,114ms)  : 1058, 1170
    master - mean (1,120ms)  : 1054, 1186

Loading
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 (8010) - mean (278ms)  : 270, 286
    master - mean (279ms)  : 270, 288

    section Bailout
    This PR (8010) - mean (279ms)  : 272, 287
    master - mean (277ms)  : 274, 281

    section CallTarget+Inlining+NGEN
    This PR (8010) - mean (905ms)  : 868, 942
    master - mean (905ms)  : 854, 955

Loading
HttpMessageHandler (.NET 6)
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8010) - mean (270ms)  : 266, 275
    master - mean (271ms)  : 266, 275

    section Bailout
    This PR (8010) - mean (270ms)  : 266, 273
    master - mean (270ms)  : 266, 274

    section CallTarget+Inlining+NGEN
    This PR (8010) - mean (886ms)  : 845, 927
    master - mean (891ms)  : 840, 942

Loading
HttpMessageHandler (.NET 8)
gantt
    title Execution time (ms) HttpMessageHandler (.NET 8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8010) - mean (269ms)  : 265, 273
    master - mean (270ms)  : 265, 274

    section Bailout
    This PR (8010) - mean (269ms)  : 265, 273
    master - mean (270ms)  : 266, 273

    section CallTarget+Inlining+NGEN
    This PR (8010) - mean (825ms)  : 802, 847
    master - mean (824ms)  : 802, 846

Loading

@datadog-official
Copy link

datadog-official bot commented Dec 23, 2025

⚠️ Tests

Fix all issues with Cursor

⚠️ Warnings

❄️ 1 New flaky test detected

RunTest from Datadog.Trace.Security.IntegrationTests.Rcm.AspNetCore5AsmDataSecurityEnabledBlockingUser (Datadog) (Fix with Cursor)
Couldn't verify the application is ready to receive requests.

ℹ️ Info

🧪 All tests passed

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 2e6e977 | Docs | Datadog PR Page | Was this helpful? Give us feedback!

@pr-commenter
Copy link

pr-commenter bot commented Dec 23, 2025

Benchmarks

Benchmark execution time: 2025-12-23 23:25:04

Comparing candidate commit 2e6e977 in PR branch steven/serilog-no-log-fix with baseline commit b5d6c80 in branch master.

Found 14 performance improvements and 2 performance regressions! Performance is the same for 155 metrics, 15 unstable metrics.

scenario:Benchmarks.Trace.ActivityBenchmark.StartStopWithChild net6.0

  • 🟩 execution_time [-115.454ms; -111.346ms] or [-59.420%; -57.305%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleMoreComplexBody net6.0

  • 🟩 execution_time [-17.282ms; -11.491ms] or [-8.216%; -5.463%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorMoreComplexBody net6.0

  • 🟩 execution_time [-76.948ms; -72.665ms] or [-39.137%; -36.958%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorSimpleBody netcoreapp3.1

  • 🟥 execution_time [+13.156ms; +18.957ms] or [+6.710%; +9.669%]

scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmark netcoreapp3.1

  • 🟩 execution_time [-60.221µs; -27.197µs] or [-12.185%; -5.503%]
  • 🟩 throughput [+107.102op/s; +223.301op/s] or [+5.207%; +10.857%]

scenario:Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces netcoreapp3.1

  • 🟩 execution_time [-25.578ms; -15.660ms] or [-16.212%; -9.926%]
  • 🟩 throughput [+171.903op/s; +279.033op/s] or [+12.108%; +19.653%]

scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice net6.0

  • 🟩 execution_time [-86.574µs; -77.680µs] or [-5.863%; -5.260%]
  • 🟩 throughput [+37.643op/s; +42.156op/s] or [+5.559%; +6.225%]

scenario:Benchmarks.Trace.DbCommandBenchmark.ExecuteNonQuery netcoreapp3.1

  • 🟩 throughput [+21313.435op/s; +29821.679op/s] or [+5.443%; +7.616%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearch netcoreapp3.1

  • 🟩 throughput [+34777.882op/s; +47229.979op/s] or [+7.746%; +10.519%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearchAsync netcoreapp3.1

  • 🟩 throughput [+24815.744op/s; +34237.824op/s] or [+5.973%; +8.241%]

scenario:Benchmarks.Trace.SpanBenchmark.StartFinishScope net6.0

  • 🟥 execution_time [+13.908ms; +17.994ms] or [+6.921%; +8.955%]

scenario:Benchmarks.Trace.SpanBenchmark.StartFinishScope netcoreapp3.1

  • 🟩 execution_time [-17.065ms; -11.016ms] or [-8.086%; -5.219%]

scenario:Benchmarks.Trace.SpanBenchmark.StartFinishTwoScopes net6.0

  • 🟩 execution_time [-19.176ms; -13.851ms] or [-8.927%; -6.448%]

Copy link
Member

@andrewlock andrewlock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I wonder if we could/should handle this.

Also, I believe the OTLP log formatter similarly copies a bunch of this code, we probably need to fix it there too?

_value = value;
}

public override void Render(TextWriter output, string format = null, IFormatProvider formatProvider = null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm actually wondering if we should be able to handle this 🤔 e.g. why couldn't we duck type LogEventPropertyValue, write to StringBuilder (using a StringWriter as the TextWriter), and then write that as a simple string in our SerilogLogFormatter? 🤔

Not necessarily required for the fix, because we don't do that today, but should be possible and not too hard?

Interesting that serilog file writing doesn't handle that though

@bouwkast bouwkast merged commit b1b0738 into master Jan 5, 2026
154 checks passed
@bouwkast bouwkast deleted the steven/serilog-no-log-fix branch January 5, 2026 15:53
@github-actions github-actions bot added this to the vNext-v3 milestone Jan 5, 2026
andrewlock added a commit that referenced this pull request Jan 8, 2026
#8034)

## Summary of changes

Handle the case where a customer is using a custom
`LogEventPropertyValue` implementation and direct log submission

## Reason for change

#8010 handled a case where we were generating invalid JSON by dropping
the offending value. This PR adds support for serializing the value as a
string instead.

## Implementation details

Ducktyped `LogEventPropertyValue` and called its `Render` method with a
cached `StringBuilder` to get the value, then use the same mechanisms

## Test coverage

Should be covered by the tests added in #8010

## Other details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants