@@ -158,6 +158,52 @@ def _maybe_set_span_output_messages(
158158 )
159159
160160
161+ def _maybe_set_additional_span_attributes (
162+ span : Span , invocation : LLMInvocation
163+ ) -> None :
164+ if "top_p" in invocation .attributes :
165+ span .set_attribute (
166+ GenAI .GEN_AI_REQUEST_TOP_P ,
167+ invocation .attributes ["top_p" ],
168+ )
169+
170+ if "frequency_penalty" in invocation .attributes :
171+ span .set_attribute (
172+ GenAI .GEN_AI_REQUEST_FREQUENCY_PENALTY ,
173+ invocation .attributes ["frequency_penalty" ],
174+ )
175+
176+ if "presence_penalty" in invocation .attributes :
177+ span .set_attribute (
178+ GenAI .GEN_AI_REQUEST_PRESENCE_PENALTY ,
179+ invocation .attributes ["presence_penalty" ],
180+ )
181+
182+ if "stop" in invocation .attributes :
183+ span .set_attribute (
184+ GenAI .GEN_AI_REQUEST_STOP_SEQUENCES ,
185+ invocation .attributes ["stop" ],
186+ )
187+
188+ if "seed" in invocation .attributes :
189+ span .set_attribute (
190+ GenAI .GEN_AI_REQUEST_SEED ,
191+ invocation .attributes ["seed" ],
192+ )
193+
194+ if "temperature" in invocation .attributes :
195+ span .set_attribute (
196+ GenAI .GEN_AI_REQUEST_TEMPERATURE ,
197+ invocation .attributes ["temperature" ],
198+ )
199+
200+ if "max_completion_tokens" in invocation .attributes :
201+ span .set_attribute (
202+ GenAI .GEN_AI_REQUEST_MAX_TOKENS ,
203+ invocation .attributes ["max_completion_tokens" ],
204+ )
205+
206+
161207class BaseTelemetryGenerator :
162208 """
163209 Abstract base for emitters mapping GenAI types -> OpenTelemetry.
@@ -270,6 +316,7 @@ def _apply_common_span_attributes(
270316 prompt_tokens ,
271317 completion_tokens ,
272318 )
319+ _maybe_set_additional_span_attributes (span , invocation )
273320 genai_attributes = _get_genai_attributes (
274321 request_model ,
275322 response_model ,
0 commit comments