Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ Release Notes.
9.9.0
------------------

* Record `gen_ai.request.max_tokens`, `gen_ai.request.frequency_penalty` and `gen_ai.request.presence_penalty` on the
spans of the `spring-ai-1.x` plugin. The `ChatOptions` of a request carries all three, and the OpenTelemetry GenAI
semantic conventions list them as recommended span attributes, but the plugin recorded only the model name and the
sampling settings. `gen_ai.request.stop_sequences` is left out because the conventions type it as a string array while
a span tag holds one string, so the format of the join needs a decision first.

* Fix the gRPC server plugin leaking the trace context on an executor thread when `close` runs after
`onCancel`. Both paths async-finish the same entry span, and the second `asyncFinish` threw before
`stopSpan` (apache/skywalking#14268).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,21 @@ public static final class HTTP {
*/
public static final StringTag GEN_AI_RETRIEVAL_QUERY_TEXT = new StringTag(45, "gen_ai.retrieval.query.text");

/**
* GEN_AI_REQUEST_MAX_TOKENS represents the maximum number of tokens the model generates for a request.
*/
public static final StringTag GEN_AI_REQUEST_MAX_TOKENS = new StringTag(46, "gen_ai.request.max_tokens");

/**
* GEN_AI_REQUEST_FREQUENCY_PENALTY represents the frequency penalty setting for the GenAI request.
*/
public static final StringTag GEN_AI_REQUEST_FREQUENCY_PENALTY = new StringTag(47, "gen_ai.request.frequency_penalty");

/**
* GEN_AI_REQUEST_PRESENCE_PENALTY represents the presence penalty setting for the GenAI request.
*/
public static final StringTag GEN_AI_REQUEST_PRESENCE_PENALTY = new StringTag(48, "gen_ai.request.presence_penalty");

/**
* Creates a {@code StringTag} with the given key and cache it, if it's created before, simply return it without
* creating a new one.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allAr
if (chatOptions.getTopP() != null) {
Tags.GEN_AI_TOP_P.set(span, String.valueOf(chatOptions.getTopP()));
}
if (chatOptions.getMaxTokens() != null) {
Tags.GEN_AI_REQUEST_MAX_TOKENS.set(span, String.valueOf(chatOptions.getMaxTokens()));
}
if (chatOptions.getFrequencyPenalty() != null) {
Tags.GEN_AI_REQUEST_FREQUENCY_PENALTY.set(span, String.valueOf(chatOptions.getFrequencyPenalty()));
}
if (chatOptions.getPresencePenalty() != null) {
Tags.GEN_AI_REQUEST_PRESENCE_PENALTY.set(span, String.valueOf(chatOptions.getPresencePenalty()));
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allAr
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()));

if (chatOptions.getMaxTokens() != null) {
Tags.GEN_AI_REQUEST_MAX_TOKENS.set(span, String.valueOf(chatOptions.getMaxTokens()));
}
if (chatOptions.getFrequencyPenalty() != null) {
Tags.GEN_AI_REQUEST_FREQUENCY_PENALTY.set(span, String.valueOf(chatOptions.getFrequencyPenalty()));
}
if (chatOptions.getPresencePenalty() != null) {
Tags.GEN_AI_REQUEST_PRESENCE_PENALTY.set(span, String.valueOf(chatOptions.getPresencePenalty()));
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ segmentItems:
- { key: gen_ai.request.model, value: gpt-4.1-2025-04-14 }
- { key: gen_ai.request.temperature, value: '0.7' }
- { key: gen_ai.request.top_p, value: '0.9' }
- { key: gen_ai.request.max_tokens, value: '1000' }
- { key: gen_ai.request.frequency_penalty, value: '0.5' }
- { key: gen_ai.request.presence_penalty, value: '0.3' }
- { key: gen_ai.response.id, value: 'chatcmpl-CyJXJt7gxwDgz' }
- { key: gen_ai.response.model, value: gpt-4.1-2025-04-14 }
- { key: gen_ai.usage.input_tokens, value: '52' }
Expand All @@ -116,6 +119,9 @@ segmentItems:
- { key: gen_ai.request.temperature, value: '0.7' }
- { key: gen_ai.request.top_k, value: null }
- { key: gen_ai.request.top_p, value: '0.9' }
- { key: gen_ai.request.max_tokens, value: '1000' }
- { key: gen_ai.request.frequency_penalty, value: '0.5' }
- { key: gen_ai.request.presence_penalty, value: '0.3' }
- { key: gen_ai.response.time_to_first_chunk, value: not null }
- { key: gen_ai.response.id, value: 'chatcmpl-fc1b64d3' }
- { key: gen_ai.response.model, value: gpt-4.1-2025-04-14 }
Expand Down Expand Up @@ -176,6 +182,9 @@ segmentItems:
- { key: gen_ai.request.model, value: gpt-4.1-2025-04-14 }
- { key: gen_ai.request.temperature, value: '0.7' }
- { key: gen_ai.request.top_p, value: '0.9' }
- { key: gen_ai.request.max_tokens, value: '1000' }
- { key: gen_ai.request.frequency_penalty, value: '0.5' }
- { key: gen_ai.request.presence_penalty, value: '0.3' }
- { key: gen_ai.response.id, value: chatcmpl-DknJunZ3tgcSkKiv }
- { key: gen_ai.response.model, value: gpt-4.1-2025-04-14 }
- { key: gen_ai.usage.input_tokens, value: '72' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ spring:
model: gpt-4.1-2025-04-14
temperature: 0.7
max-tokens: 1000
frequency-penalty: 0.5
presence-penalty: 0.3
top-p: 0.9
embedding:
options:
Expand Down
Loading