refactor: rename tracing span attribute "system" to "system_instructions"
Align with the OpenTelemetry GenAI semantic convention gen_ai.system_instructions for system prompts. The old "system" attribute name was unrelated to gen_ai.system (which is for provider name).
This commit is contained in:
1
changelog/3449.changed.md
Normal file
1
changelog/3449.changed.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
- Renamed tracing span attribute `system` to `system_instructions` to align with the OpenTelemetry GenAI semantic conventions.
|
||||||
@@ -193,7 +193,7 @@ def add_llm_span_attributes(
|
|||||||
tools: Optional[str] = None,
|
tools: Optional[str] = None,
|
||||||
tool_count: Optional[int] = None,
|
tool_count: Optional[int] = None,
|
||||||
tool_choice: Optional[str] = None,
|
tool_choice: Optional[str] = None,
|
||||||
system: Optional[str] = None,
|
system_instructions: Optional[str] = None,
|
||||||
parameters: Optional[Dict[str, Any]] = None,
|
parameters: Optional[Dict[str, Any]] = None,
|
||||||
extra_parameters: Optional[Dict[str, Any]] = None,
|
extra_parameters: Optional[Dict[str, Any]] = None,
|
||||||
ttfb: Optional[float] = None,
|
ttfb: Optional[float] = None,
|
||||||
@@ -211,7 +211,7 @@ def add_llm_span_attributes(
|
|||||||
tools: JSON-serialized tools configuration.
|
tools: JSON-serialized tools configuration.
|
||||||
tool_count: Number of tools available.
|
tool_count: Number of tools available.
|
||||||
tool_choice: Tool selection configuration.
|
tool_choice: Tool selection configuration.
|
||||||
system: System message.
|
system_instructions: System instructions.
|
||||||
parameters: Service parameters.
|
parameters: Service parameters.
|
||||||
extra_parameters: Additional parameters.
|
extra_parameters: Additional parameters.
|
||||||
ttfb: Time to first byte in seconds.
|
ttfb: Time to first byte in seconds.
|
||||||
@@ -240,8 +240,8 @@ def add_llm_span_attributes(
|
|||||||
if tool_choice:
|
if tool_choice:
|
||||||
span.set_attribute("tool_choice", tool_choice)
|
span.set_attribute("tool_choice", tool_choice)
|
||||||
|
|
||||||
if system:
|
if system_instructions:
|
||||||
span.set_attribute("system", system)
|
span.set_attribute("system_instructions", system_instructions)
|
||||||
|
|
||||||
if ttfb is not None:
|
if ttfb is not None:
|
||||||
span.set_attribute("metrics.ttfb", ttfb)
|
span.set_attribute("metrics.ttfb", ttfb)
|
||||||
|
|||||||
@@ -538,7 +538,7 @@ def traced_llm(func: Optional[Callable] = None, *, name: Optional[str] = None) -
|
|||||||
if hasattr(self, "_settings"):
|
if hasattr(self, "_settings"):
|
||||||
for key, value in self._settings.given_fields().items():
|
for key, value in self._settings.given_fields().items():
|
||||||
# system_instruction is already captured as the
|
# system_instruction is already captured as the
|
||||||
# "system" span attribute above.
|
# "system_instructions" span attribute above.
|
||||||
if key == "system_instruction":
|
if key == "system_instruction":
|
||||||
continue
|
continue
|
||||||
if isinstance(value, (int, float, bool, str)):
|
if isinstance(value, (int, float, bool, str)):
|
||||||
@@ -561,7 +561,7 @@ def traced_llm(func: Optional[Callable] = None, *, name: Optional[str] = None) -
|
|||||||
attribute_kwargs["tools"] = serialized_tools
|
attribute_kwargs["tools"] = serialized_tools
|
||||||
attribute_kwargs["tool_count"] = tool_count
|
attribute_kwargs["tool_count"] = tool_count
|
||||||
if system_message:
|
if system_message:
|
||||||
attribute_kwargs["system"] = system_message
|
attribute_kwargs["system_instructions"] = system_message
|
||||||
|
|
||||||
# Add all gathered attributes to the span
|
# Add all gathered attributes to the span
|
||||||
add_llm_span_attributes(span=current_span, **attribute_kwargs)
|
add_llm_span_attributes(span=current_span, **attribute_kwargs)
|
||||||
|
|||||||
Reference in New Issue
Block a user