-
Type:
Task
-
Resolution: Unresolved
-
Priority:
Critical - P2
-
None
-
Affects Version/s: None
-
Component/s: Logging, Performance
-
None
-
None
-
Dotnet Drivers
-
None
-
None
-
None
-
None
-
None
-
None
Command and reply documents are serialized to extended JSON in full before being truncated to MaxDocumentSize, so enabling command logging costs a complete traversal of every document no matter how little of it ends up in the log. Measured on net10.0 with the default 1000-character limit, rendering a 6 MB insert command takes about 24 ms instead of about 0.01 ms; at 30 MB it is about 114 ms.
Truncation should stop serializing once the limit is reached. The logging specification permits this: it requires only that the output be the first N units of the extended JSON representation, not that the document be fully encoded first. Output must stay byte-identical to what full-serialize-then-truncate produces today.
Affected paths: StructuredLogTemplateProviders.DocumentToString (command, reply and server-heartbeat reply), StructuredLogTemplateProvidersCommand.FormatCommandException (the server reply embedded in command-failed messages), and MongoTelemetry.SetQueryText (the OpenTelemetry db.query.text tag).
Split out of CSHARP-4932, which tracks the investigation and the parent spec issue DRIVERS-2804.