Skip to content

Commit ac0df43

Browse files
authored
Fix the tag key of ttfr to align with otlp semantic (#799)
1 parent 2f1d9e9 commit ac0df43

File tree

3 files changed

+5
-5
lines changed
  • apm-sniffer
    • apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/tag
    • apm-sdk-plugin/spring-plugins/spring-ai-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/ai/v1
  • test/plugin/scenarios/spring-ai-1.x-scenario/config

3 files changed

+5
-5
lines changed

apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/tag/Tags.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,17 +238,17 @@ public static final class HTTP {
238238
/**
239239
* GEN_AI_STREAM_TTFR represents the time to first response (TTFR) for streaming operations.
240240
*/
241-
public static final StringTag GEN_AI_STREAM_TTFR = new StringTag(40, "gen_ai.stream.ttfr");
241+
public static final StringTag GEN_AI_SERVER_TIME_TO_FIRST_TOKEN = new StringTag(40, "gen_ai.server.time_to_first_token");
242242

243243
/**
244244
* GEN_AI_INPUT_MESSAGES represents the chat history provided to the model as an input.
245245
*/
246-
public static final StringTag GEN_AI_INPUT_MESSAGES = new StringTag(44, "gen_ai.input.messages");
246+
public static final StringTag GEN_AI_INPUT_MESSAGES = new StringTag(41, "gen_ai.input.messages");
247247

248248
/**
249249
* GEN_AI_OUTPUT_MESSAGES represents the messages returned by the model where each message represents a specific model response (choice, candidate).
250250
*/
251-
public static final StringTag GEN_AI_OUTPUT_MESSAGES = new StringTag(45, "gen_ai.output.messages");
251+
public static final StringTag GEN_AI_OUTPUT_MESSAGES = new StringTag(42, "gen_ai.output.messages");
252252

253253
/**
254254
* Creates a {@code StringTag} with the given key and cache it, if it's created before, simply return it without

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ private void recordTtfrIfFirstToken(AbstractSpan span, Generation generation, St
150150
return;
151151
}
152152
if (state.firstResponseReceived.compareAndSet(false, true)) {
153-
Tags.GEN_AI_STREAM_TTFR.set(span, String.valueOf(System.currentTimeMillis() - state.startTime));
153+
Tags.GEN_AI_SERVER_TIME_TO_FIRST_TOKEN.set(span, String.valueOf(System.currentTimeMillis() - state.startTime));
154154
}
155155
}
156156

test/plugin/scenarios/spring-ai-1.x-scenario/config/expectedData.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ segmentItems:
116116
- { key: gen_ai.request.temperature, value: '0.7' }
117117
- { key: gen_ai.request.top_k, value: null }
118118
- { key: gen_ai.request.top_p, value: '0.9' }
119-
- { key: gen_ai.stream.ttfr, value: not null }
119+
- { key: gen_ai.server.time_to_first_token, value: not null }
120120
- { key: gen_ai.response.id, value: 'chatcmpl-fc1b64d3' }
121121
- { key: gen_ai.response.model, value: gpt-4.1-2025-04-14 }
122122
- { key: gen_ai.response.finish_reasons, value: STOP }

0 commit comments

Comments
 (0)