You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Internal] Spec: Remove CosmosDiagnostics.Verbosity property per review feedback
Address Fabian's review comment: drop the mutable Verbosity property from
CosmosDiagnostics to avoid thread-safety issues. Callers use the explicit
ToString(DiagnosticsVerbosity) / ToJsonString(DiagnosticsVerbosity) overloads
instead. Parameterless ToString() always returns Detailed (backward compat).
Changes:
- Remove Verbosity get/set property from CosmosDiagnostics API surface
- Update CosmosClientOptions doc to clarify it is a config value, not auto-flowed
- Simplify precedence order from 4 levels to 3
- Remove ResponseMessage.cs from modified files list (no verbosity propagation needed)
- Update WI-1 and WI-3 scope/acceptance criteria
- Replace ToString_UsesSummary_WhenVerbosityPropertySet test with
ToString_Parameterless_AlwaysDetailed test
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The parameterless `ToString()` continues to return full detailed output (backward compatible). New overloads accept an explicit `DiagnosticsVerbosity` parameter — no mutable state is stored on the diagnostics object, avoiding thread-safety concerns.
2.`CosmosClientOptions.DiagnosticsVerbosity` (set in code, or populated from `AZURE_COSMOS_DIAGNOSTICS_VERBOSITY` environment variable)
122
+
3. Default: `DiagnosticsVerbosity.Detailed`
123
+
124
+
> **Note:** The parameterless `ToString()` always returns `Detailed` output for backward compatibility. To use `Summary` mode, callers must explicitly pass `DiagnosticsVerbosity.Summary` to the overload.
127
125
128
126
## 4. Summary Mode JSON Format
129
127
@@ -273,12 +271,11 @@ Both `StoreResponseStatistics` (direct mode) and `HttpResponseStatistics` (gatew
273
271
| File | Change |
274
272
|------|--------|
275
273
|`CosmosClientOptions.cs`| Add `DiagnosticsVerbosity` and `MaxDiagnosticsSummarySizeBytes` properties with validation |
276
-
|`CosmosDiagnostics.cs`| Add `Verbosity` property, `ToString(DiagnosticsVerbosity)` and `ToJsonString(DiagnosticsVerbosity)` overloads |
277
-
|`CosmosTraceDiagnostics.cs`|Wire `Verbosity` into `ToString()`/`ToJsonString()`to branch between detailed and summary serialization; implement new overloads|
274
+
|`CosmosDiagnostics.cs`| Add `ToString(DiagnosticsVerbosity)` and `ToJsonString(DiagnosticsVerbosity)` abstract overloads |
275
+
|`CosmosTraceDiagnostics.cs`|Implement `ToString(DiagnosticsVerbosity)`and`ToJsonString(DiagnosticsVerbosity)`overloads; delegate to `DiagnosticsSummaryWriter` when verbosity is `Summary`|
278
276
|`TraceWriter.TraceJsonWriter.cs`| Add summary serialization path that delegates to `DiagnosticsSummaryWriter` when verbosity is `Summary`|
279
277
|`SummaryDiagnostics.cs`| Extend `CollectSummaryFromTraceTree()` to support region-grouped collection with ordering |
280
278
|`ClientSideRequestStatisticsTraceDatum.cs`| Ensure `StoreResponseStatistics` and `HttpResponseStatistics` lists are accessible for summary computation |
281
-
|`ResponseMessage.cs` (or wherever diagnostics are attached to response) | Propagate effective verbosity from `CosmosClientOptions` to `CosmosDiagnostics.Verbosity`|
282
279
283
280
### 6.3 Contract/Baseline Updates
284
281
@@ -289,16 +286,16 @@ Both `StoreResponseStatistics` (direct mode) and `HttpResponseStatistics` (gatew
**Scope:** Create the enum, add properties to `CosmosClientOptions`, add `ToString(DiagnosticsVerbosity)` / `ToJsonString(DiagnosticsVerbosity)` overloads to `CosmosDiagnostics`, add environment variable support, wire verbosity from `CosmosClientOptions` through to `CosmosDiagnostics.Verbosity`.
293
-
**Acceptance:**Verbosity flows from client options → diagnostics object. `ToString(verbosity)` overloads compile and delegate correctly. No behavioral change yet.
289
+
**Scope:** Create the enum, add `DiagnosticsVerbosity` and `MaxDiagnosticsSummarySizeBytes`properties to `CosmosClientOptions`, add `ToString(DiagnosticsVerbosity)` / `ToJsonString(DiagnosticsVerbosity)`abstract overloads to `CosmosDiagnostics`, add environment variable support.
290
+
**Acceptance:**`ToString(verbosity)` overloads compile and delegate correctly. Parameterless `ToString()` is unchanged (always `Detailed`). No behavioral change yet.
294
291
295
292
### WI-2: Summary Computation Engine
296
293
**Scope:** Implement `DiagnosticsSummaryWriter` — the core logic that walks the trace tree, collects stats, groups by region, computes first/last/aggregated groups, and produces the summary JSON structure.
297
294
**Acceptance:** Given an `ITrace` tree, produces the correct summary JSON. Unit-testable in isolation.
298
295
299
296
### WI-3: Summary Serialization Integration
300
-
**Scope:**Modify`CosmosTraceDiagnostics.ToString()` and `TraceWriter.TraceJsonWriter` to branch on verbosity. When `Summary`, delegate to `DiagnosticsSummaryWriter`. Implement size enforcement and truncated output fallback.
301
-
**Acceptance:**`ToString()` returns compact summary JSON when verbosity is `Summary`, full trace when `Detailed`.
297
+
**Scope:**Implement`CosmosTraceDiagnostics.ToString(DiagnosticsVerbosity)` and `ToJsonString(DiagnosticsVerbosity)`. When `Summary`, delegate to `DiagnosticsSummaryWriter`. Implement size enforcement and truncated output fallback. Parameterless `ToString()` remains unchanged.
298
+
**Acceptance:**`ToString(DiagnosticsVerbosity.Summary)` returns compact summary JSON. `ToString()` (parameterless) continues to return full `Detailed` trace.
302
299
303
300
### WI-4: Contract Updates & Public API Validation
304
301
**Scope:** Update `ContractEnforcementTests` baselines for new public API surface. Ensure the new enum and properties appear in contracts.
@@ -335,9 +332,9 @@ Both `StoreResponseStatistics` (direct mode) and `HttpResponseStatistics` (gatew
0 commit comments