Skip to content

Commit 2529d10

Browse files
committed
Cleanup
1 parent c1405a2 commit 2529d10

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

sentry_sdk/tracing_utils.py

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ def _sample_rand_range(parent_sampled, sample_rate):
944944

945945

946946
def _get_span_name(template, name, kwargs=None):
947-
# type: (Union[str, "SPANTEMPLATE"], str, Optional[dict[str, Any]]) -> str
947+
# type: (Union[str, SPANTEMPLATE], str, Optional[dict[str, Any]]) -> str
948948
"""
949949
Get the name of the span based on the template and the name.
950950
"""
@@ -970,26 +970,22 @@ def _get_span_name(template, name, kwargs=None):
970970

971971

972972
def _get_span_op(template):
973-
# type: (Union[str, "SPANTEMPLATE"]) -> str
973+
# type: (Union[str, SPANTEMPLATE]) -> str
974974
"""
975975
Get the operation of the span based on the template.
976976
"""
977-
op = OP.FUNCTION
978-
979-
if template == SPANTEMPLATE.AI_CHAT:
980-
op = OP.GEN_AI_CHAT
981-
982-
elif template == SPANTEMPLATE.AI_AGENT:
983-
op = OP.GEN_AI_INVOKE_AGENT
984-
985-
elif template == SPANTEMPLATE.AI_TOOL:
986-
op = OP.GEN_AI_EXECUTE_TOOL
977+
mapping = {
978+
SPANTEMPLATE.AI_CHAT: OP.GEN_AI_CHAT,
979+
SPANTEMPLATE.AI_AGENT: OP.GEN_AI_INVOKE_AGENT,
980+
SPANTEMPLATE.AI_TOOL: OP.GEN_AI_EXECUTE_TOOL,
981+
} # type: dict[Union[str, SPANTEMPLATE], Union[str, OP]]
982+
op = mapping.get(template, OP.FUNCTION)
987983

988-
return op
984+
return str(op)
989985

990986

991987
def _get_input_attributes(template, send_pii, args, kwargs):
992-
# type: (Union[str, "SPANTEMPLATE"], bool, tuple[Any, ...], dict[str, Any]) -> dict[str, Any]
988+
# type: (Union[str, SPANTEMPLATE], bool, tuple[Any, ...], dict[str, Any]) -> dict[str, Any]
993989
"""
994990
Get input attributes for the given span template.
995991
"""
@@ -1088,7 +1084,7 @@ def _set_from_keys(attribute, keys):
10881084

10891085

10901086
def _get_output_attributes(template, send_pii, result):
1091-
# type: (Union[str, "SPANTEMPLATE"], bool, Any) -> dict[str, Any]
1087+
# type: (Union[str, SPANTEMPLATE], bool, Any) -> dict[str, Any]
10921088
"""
10931089
Get output attributes for the given span template.
10941090
"""
@@ -1141,7 +1137,7 @@ def _get_output_attributes(template, send_pii, result):
11411137

11421138

11431139
def _set_input_attributes(span, template, send_pii, name, f, args, kwargs):
1144-
# type: (Span, Union[str, "SPANTEMPLATE"], bool, str, Any, tuple[Any, ...], dict[str, Any]) -> None
1140+
# type: (Span, Union[str, SPANTEMPLATE], bool, str, Any, tuple[Any, ...], dict[str, Any]) -> None
11451141
"""
11461142
Set span input attributes based on the given span template.
11471143
@@ -1178,7 +1174,7 @@ def _set_input_attributes(span, template, send_pii, name, f, args, kwargs):
11781174

11791175

11801176
def _set_output_attributes(span, template, send_pii, result):
1181-
# type: (Span, Union[str, "SPANTEMPLATE"], bool, Any) -> None
1177+
# type: (Span, Union[str, SPANTEMPLATE], bool, Any) -> None
11821178
"""
11831179
Set span output attributes based on the given span template.
11841180

0 commit comments

Comments
 (0)