Skip to content

Commit 899d7e6

Browse files
committed
cleaning up
1 parent ee61c27 commit 899d7e6

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

docs/adrs/006-logging-strategy.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,13 @@ The approach emphasizes descriptive, human-readable logs with structured request
3838
Logs should read naturally and provide enough context for a developer to understand what happened without consulting the code.
3939
While descriptiveness is a priority, follow the `metric=value` pattern where practical to include additional details with extensibility in mind.
4040
Check out the example below.
41+
4142
```[reqId=e3eaa45c] OpenAI request completed successfully with duration=1628ms, size=1,2KB.```
4243

43-
* **Correlate related logs.**
44+
* **Correlate logs.**
4445
Include a request identifier (e.g., `reqId`) in per-request logs to assist with correlation and debugging.
4546

46-
* **Exception logging security.**
47+
* **Exception logging.**
4748
When logging exceptions, use standard logging methods (e.g., `log.error("Operation failed", exception)`) rather than serializing exception objects.
4849
Exception objects may contain custom fields with sensitive data that could be exposed through JSON serialization or custom `toString()` implementations.
4950

@@ -61,14 +62,14 @@ The approach emphasizes descriptive, human-readable logs with structured request
6162
Use the WARNING level only for actionable or genuinely concerning conditions.
6263
Do not use it as a placeholder or for expected transient states.
6364

64-
* **Explicit request lifecycle logging.**
65+
* **Explicit request logging.**
6566
Always log at **request start** to provide immediate visibility that an operation has begun.
6667
This helps users understand that their request is being processed even before a result is available.
6768
Do not rely solely on response-time logging — requests may fail, hang, or take long durations.
6869
This approach also avoids the need for stack-trace investigation when surface error responses are ambiguous.
6970

7071
* **Performance-aware logging.**
71-
If a log statement requires computation or inference to generate information, guard it with a log-level check (e.g., `if (log.isDebugEnabled())`) or other available context to avoid unnecessary overhead when that level is disabled.
72+
If a log statement requires computation or inference to generate information, guard it with a log-level check (e.g., `if (log.isDebugEnabled())`) or other available context to avoid unnecessary overhead.
7273

7374
---
7475

@@ -81,15 +82,14 @@ The approach emphasizes descriptive, human-readable logs with structured request
8182
Set MDC values deliberately and close to their scope of relevance.
8283
Per-request MDC context must be cleared when the response completes.
8384
Avoid setting per-request values in long-lived objects that outlive the request lifecycle, as this can result in corrupted or incomplete log context.
84-
Setting per-request context outside of blocks or objects that are not invoked per-request can lead to incomplete MDC states which will corrupt logs produced.
8585

8686
* **Granular clearing only.**
8787
Never clear the entire MDC context.
8888
Instead, remove entries key-by-key to preserve unrelated context items that may remain valid for longer periods.
8989

9090
* **Centralized MDC management.**
9191
Avoid using magic strings for MDC keys or values.
92-
Define them in a dedicated structure or utility (e.g., `MdcKeys` class) to ensure discoverability and prevent errors during refactoring.
92+
Define them in a dedicated structure or utility (e.g., `RequestlogContext` class) to ensure discoverability and prevent errors during refactoring.
9393

9494
* **Responsibility and ownership.**
9595
The component or class that sets MDC context values is also responsible for clearing them.

0 commit comments

Comments
 (0)