Skip to content

Commit a3a2818

Browse files
committed
chore(telemetry): updated opt-in attributes to internal
1 parent c250c4a commit a3a2818

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/strands/telemetry/tracer.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ def __init__(self) -> None:
9494

9595
# Read OTEL_SEMCONV_STABILITY_OPT_IN environment variable
9696
opt_in_values = self._parse_semconv_opt_in()
97-
self._use_latest_genai_conventions = "gen_ai_latest_experimental" in opt_in_values
97+
## To-do: should not set below attributes directly, use env var instead
98+
self.use_latest_genai_conventions = "gen_ai_latest_experimental" in opt_in_values
9899
self._include_tool_definitions = "gen_ai_tool_definitions" in opt_in_values
99100

100101
def _parse_semconv_opt_in(self) -> set[str]:
@@ -330,7 +331,7 @@ def end_model_invoke_span(
330331
# Add optional attributes if they have values
331332
self._add_optional_usage_and_metrics_attributes(attributes, usage, metrics)
332333

333-
if self._use_latest_genai_conventions:
334+
if self.use_latest_genai_conventions:
334335
self._add_event(
335336
span,
336337
"gen_ai.client.inference.operation.details",
@@ -380,7 +381,7 @@ def start_tool_call_span(self, tool: ToolUse, parent_span: Optional[Span] = None
380381
span_name = f"execute_tool {tool['name']}"
381382
span = self._start_span(span_name, parent_span, attributes=attributes, span_kind=trace_api.SpanKind.INTERNAL)
382383

383-
if self._use_latest_genai_conventions:
384+
if self.use_latest_genai_conventions:
384385
self._add_event(
385386
span,
386387
"gen_ai.client.inference.operation.details",
@@ -436,7 +437,7 @@ def end_tool_call_span(
436437
}
437438
)
438439

439-
if self._use_latest_genai_conventions:
440+
if self.use_latest_genai_conventions:
440441
self._add_event(
441442
span,
442443
"gen_ai.client.inference.operation.details",
@@ -527,7 +528,7 @@ def end_event_loop_cycle_span(
527528
if tool_result_message:
528529
event_attributes["tool.result"] = serialize(tool_result_message["content"])
529530

530-
if self._use_latest_genai_conventions:
531+
if self.use_latest_genai_conventions:
531532
self._add_event(
532533
span,
533534
"gen_ai.client.inference.operation.details",
@@ -621,7 +622,7 @@ def end_agent_span(
621622
attributes: Dict[str, AttributeValue] = {}
622623

623624
if response:
624-
if self._use_latest_genai_conventions:
625+
if self.use_latest_genai_conventions:
625626
self._add_event(
626627
span,
627628
"gen_ai.client.inference.operation.details",
@@ -688,7 +689,7 @@ def start_multiagent_span(
688689

689690
span = self._start_span(operation, attributes=attributes, span_kind=trace_api.SpanKind.CLIENT)
690691

691-
if self._use_latest_genai_conventions:
692+
if self.use_latest_genai_conventions:
692693
parts: list[dict[str, Any]] = []
693694
if isinstance(task, list):
694695
parts = self._map_content_blocks_to_otel_parts(task)
@@ -715,7 +716,7 @@ def end_swarm_span(
715716
) -> None:
716717
"""End a swarm span with results."""
717718
if result:
718-
if self._use_latest_genai_conventions:
719+
if self.use_latest_genai_conventions:
719720
self._add_event(
720721
span,
721722
"gen_ai.client.inference.operation.details",
@@ -750,7 +751,7 @@ def _get_common_attributes(
750751
A dictionary of attributes following the appropriate GenAI conventions.
751752
"""
752753
common_attributes = {"gen_ai.operation.name": operation_name}
753-
if self._use_latest_genai_conventions:
754+
if self.use_latest_genai_conventions:
754755
common_attributes.update(
755756
{
756757
"gen_ai.provider.name": "strands-agents",
@@ -771,7 +772,7 @@ def _add_event_messages(self, span: Span, messages: Messages) -> None:
771772
span: The span to which events will be added.
772773
messages: List of messages being sent to the agent.
773774
"""
774-
if self._use_latest_genai_conventions:
775+
if self.use_latest_genai_conventions:
775776
input_messages: list = []
776777
for message in messages:
777778
input_messages.append(

0 commit comments

Comments
 (0)