Repository navigation
Record gen_ai.request.max_tokens, frequency_penalty and presence_penalty in the spring-ai-1.x plugin - #853
Merged
Conversation
…lty in the spring-ai-1.x plugin The OpenTelemetry GenAI semantic conventions list gen_ai.request.max_tokens, gen_ai.request.frequency_penalty and gen_ai.request.presence_penalty as recommended attributes of the client inference span. The ChatOptions of a Spring AI request carries all three, but the plugin recorded only the model name and the sampling settings (temperature, top_k, top_p). Tags gets GEN_AI_REQUEST_MAX_TOKENS, GEN_AI_REQUEST_FREQUENCY_PENALTY and GEN_AI_REQUEST_PRESENCE_PENALTY, and both ChatModelCallInterceptor and ChatModelStreamInterceptor set them after GEN_AI_TOP_P. The three are optional in ChatOptions, so each is guarded by a null check: an option the caller left unset leaves no tag on the span, instead of writing the string null as the value. gen_ai.request.stop_sequences is left out. 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.
peachisai
approved these changes
Dec 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The OpenTelemetry GenAI semantic conventions list
gen_ai.request.max_tokens,gen_ai.request.frequency_penaltyandgen_ai.request.presence_penaltyas recommended attributes of the client inference span. TheChatOptionsof a Spring AI request carries all three, but the plugin recorded only the model name and the sampling settings (temperature,top_k,top_p).TagsgetsGEN_AI_REQUEST_MAX_TOKENS,GEN_AI_REQUEST_FREQUENCY_PENALTYandGEN_AI_REQUEST_PRESENCE_PENALTY, and bothChatModelCallInterceptorandChatModelStreamInterceptorset them afterGEN_AI_TOP_P. The three are optional inChatOptions, so each is guarded by a null check: an option the caller left unset leaves no tag on the span, instead of writing the stringnullas the value.The
spring-ai-1.x-scenariosetsfrequency-penaltyandpresence-penaltyso that the values differ from the defaults, and asserts the three tags on the two call spans and on the stream span.gen_ai.request.stop_sequencesis left out. 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.Verified with
bash test/plugin/run.sh spring-ai-1.x-scenario:spring-ai-1.x-scenario-1.0.1andspring-ai-1.x-scenario-1.1.1both passed.