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
- adding . at the end
- reqId explanation
- 'size' renaming in log for clarity
- MDc examplee
- "object creation" with example instead of vague computaiton
- remove mention of "placeholder" warnings
Copy file name to clipboardExpand all lines: docs/adrs/006-logging-strategy.md
+57-7Lines changed: 57 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,10 +38,12 @@ This approach mandates descriptive, human-readable logs with structured request
38
38
Logs must be clear enough for a developer to understand what happened without checking the code.
39
39
Use the `metric=value` pattern to include structured details with extensibility in mind.
40
40
41
-
```[reqId=e3eaa45c] OpenAI request completed successfully with duration=1628ms, size=1,2KB.```
41
+
```[reqId=e3eaa45c] OpenAI request completed successfully with duration=1628ms, responseSize=1.2KB.```
42
42
43
43
***Correlate logs.**
44
44
Include a request identifier (e.g., `reqId`) in per-request logs to assist with correlation and debugging.
45
+
In this SDK, a "request" represents a single AI service operation (e.g., one chat completion call, one embedding generation).
46
+
The `reqId` is generated for each AI service call and is distinct from any HTTP request tracking in user's application framework.
45
47
46
48
***Exception logging.**
47
49
When logging exceptions, use standard logging methods (e.g., `log.error("Operation failed", exception)`) rather than serializing exception objects.
@@ -59,16 +61,42 @@ This approach mandates descriptive, human-readable logs with structured request
59
61
60
62
***Avoid unnecessary warnings.**
61
63
Use the WARN level only for actionable or genuinely concerning conditions.
62
-
Do not use it as a placeholder or for expected transient states.
64
+
Expected transient states (retries, fallbacks, cache misses) should not generate a warning.
63
65
64
66
***Explicit request logging.**
65
67
Always log at **request start** to provide immediate visibility that an operation has begun.
66
68
This helps users understand that their request is being processed even before a result is available.
67
69
Do not rely solely on response-time logging — requests may fail, hang, or take long durations.
68
70
This approach also avoids the need for stack-trace investigation when surface error responses are ambiguous.
69
71
72
+
```[reqId=e3eaa45c] Starting OpenAI synchronous request to /v1/chat/completions, destination=<some-uri>.```
73
+
70
74
***Performance-aware logging.**
71
-
If a log statement requires expensive computation, guard it with a log-level check (e.g., `if (log.isDebugEnabled())`) to prevent performance degradation.
75
+
If a log statement requires any object creation, guard it with a log-level check to prevent performance degradation.
Copy file name to clipboardExpand all lines: foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiChatCompletionResponse.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -116,7 +116,7 @@ public List<OpenAiToolMessage> executeTools() {
0 commit comments