You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2026/03/15 23:52:12 UTC

(skywalking-java) branch main updated: Fix the logic that was failing to record TTFR (#798)

This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-java.git


The following commit(s) were added to refs/heads/main by this push:
     new 2f1d9e94d6 Fix the logic that was failing to record TTFR (#798)
2f1d9e94d6 is described below

commit 2f1d9e94d6d1ac22d92f4e9c6905901fe646ffdf
Author: peachisai <25...@qq.com>
AuthorDate: Mon Mar 16 07:52:05 2026 +0800

    Fix the logic that was failing to record TTFR (#798)
---
 .../apm/plugin/spring/ai/v1/ChatModelStreamInterceptor.java           | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-ai-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/ai/v1/ChatModelStreamInterceptor.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-ai-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/ai/v1/ChatModelStreamInterceptor.java
index 9abb852187..e0c11c32ec 100644
--- a/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-ai-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/ai/v1/ChatModelStreamInterceptor.java
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-ai-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/ai/v1/ChatModelStreamInterceptor.java
@@ -63,6 +63,8 @@ public class ChatModelStreamInterceptor implements InstanceMethodsAroundIntercep
             return;
         }
 
+        ContextManager.getRuntimeContext().put(Constants.SPRING_AI_STREAM_START_TIME, System.currentTimeMillis());
+
         ChatOptions chatOptions = prompt.getOptions();
         if (chatOptions == null) {
             return;
@@ -72,8 +74,6 @@ public class ChatModelStreamInterceptor implements InstanceMethodsAroundIntercep
         Tags.GEN_AI_TEMPERATURE.set(span, String.valueOf(chatOptions.getTemperature()));
         Tags.GEN_AI_TOP_K.set(span, String.valueOf(chatOptions.getTopK()));
         Tags.GEN_AI_TOP_P.set(span, String.valueOf(chatOptions.getTopP()));
-
-        ContextManager.getRuntimeContext().put(Constants.SPRING_AI_STREAM_START_TIME, System.currentTimeMillis());
     }
 
     @Override