Skip to content

Commit 01661ae

Browse files
committed
Review suggestion
1 parent 2f61d28 commit 01661ae

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

core/src/main/java/com/sap/ai/sdk/core/common/ClientResponseHandler.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,17 +174,17 @@ private static String getErrorMessage(
174174
}
175175

176176
private static void logResponseSuccess(final @Nonnull ClassicHttpResponse response) {
177-
val latency =
177+
val duration =
178178
Optional.ofNullable(response.getFirstHeader("x-upstream-service-time"))
179179
.map(h -> h.getValue() + "ms")
180180
.orElseGet(() -> "unknown");
181181
val entityLength = response.getEntity().getContentLength();
182182
val sizeInfo = entityLength >= 0 ? String.format("%.1fKB", entityLength / 1024.0) : "unknown";
183183
log.debug(
184-
"[reqId={}] {} request completed successfully with latency={}, size={}.",
184+
"[reqId={}] {} request completed successfully with duration={}, size={}.",
185185
MDC.get("reqId"),
186186
MDC.get("service"),
187-
latency,
187+
duration,
188188
sizeInfo);
189189
}
190190
}

foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ private <T> T executeRequest(
455455
try {
456456
final var client = ApacheHttpClient5Accessor.getHttpClient(destination);
457457
MDC.put("destination", ((HttpDestination) destination).getUri().toASCIIString());
458-
MDC.put("mode", "streaming");
458+
MDC.put("mode", "synchronous");
459459
logRequestStart();
460460
return client.execute(
461461
request, new ClientResponseHandler<>(responseType, OpenAiError.class, FACTORY));
@@ -487,7 +487,7 @@ private <D extends StreamedDelta> Stream<D> streamRequest(
487487
private static void logRequestStart() {
488488
val reqId = UUID.randomUUID().toString().substring(0, 8);
489489
MDC.put("reqId", reqId);
490-
MDC.put("service", "Orchestration");
490+
MDC.put("service", "OpenAI");
491491
log.debug(
492492
"[reqId={}] Starting OpenAI {} request to {}, destination={}",
493493
reqId,
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<configuration>
3+
<springProfile name="!cloud">
4+
<include resource="org/springframework/boot/logging/logback/base.xml"/>
5+
<root level="INFO"/>
6+
<logger name="org.springframework.web" level="INFO"/>
7+
<logger name="org.apache.hc.client5.http.wire" level="DEBUG"/>
8+
<logger name="org.apache.http.wire" level="DEBUG"/>
9+
<logger name="com.sap.ai.sdk" level="DEBUG"/>
10+
</springProfile>
11+
12+
<springProfile name="cloud">
13+
<appender name="STDOUT-JSON" class="ch.qos.logback.core.ConsoleAppender">
14+
<encoder class="com.sap.hcp.cf.logback.encoder.JsonEncoder"/>
15+
</appender>
16+
<root level="INFO">
17+
<appender-ref ref="STDOUT-JSON"/>
18+
</root>
19+
</springProfile>
20+
</configuration>

0 commit comments

Comments
 (0)