@@ -832,13 +832,13 @@ def _sample_rand_range(parent_sampled, sample_rate):
832832
833833
834834def _get_span_name (template , name , kwargs = None ):
835- # type: (Union[str, "SpanTemplate "], str, Optional[dict[str, Any]]) -> str
835+ # type: (Union[str, "SPANTEMPLATE "], str, Optional[dict[str, Any]]) -> str
836836 """
837837 Get the name of the span based on the template and the name.
838838 """
839839 span_name = name
840840
841- if template == SpanTemplate .AI_CHAT :
841+ if template == SPANTEMPLATE .AI_CHAT :
842842 model = None
843843 if kwargs and "model" in kwargs and isinstance (kwargs ["model" ], str ):
844844 model = kwargs ["model" ]
@@ -849,42 +849,42 @@ def _get_span_name(template, name, kwargs=None):
849849
850850 span_name = f"chat { model } " if model else "chat"
851851
852- elif template == SpanTemplate .AI_AGENT :
852+ elif template == SPANTEMPLATE .AI_AGENT :
853853 span_name = f"invoke_agent { name } "
854854
855- elif template == SpanTemplate .AI_TOOL :
855+ elif template == SPANTEMPLATE .AI_TOOL :
856856 span_name = f"execute_tool { name } "
857857
858858 return span_name
859859
860860
861861def _get_span_op (template ):
862- # type: (Union[str, "SpanTemplate "]) -> str
862+ # type: (Union[str, "SPANTEMPLATE "]) -> str
863863 """
864864 Get the operation of the span based on the template.
865865 """
866866 op = OP .FUNCTION
867867
868- if template == SpanTemplate .AI_CHAT :
868+ if template == SPANTEMPLATE .AI_CHAT :
869869 op = OP .GEN_AI_CHAT
870870
871- elif template == SpanTemplate .AI_AGENT :
871+ elif template == SPANTEMPLATE .AI_AGENT :
872872 op = OP .GEN_AI_INVOKE_AGENT
873873
874- elif template == SpanTemplate .AI_TOOL :
874+ elif template == SPANTEMPLATE .AI_TOOL :
875875 op = OP .GEN_AI_EXECUTE_TOOL
876876
877877 return op
878878
879879
880880def _get_input_attributes (template , send_pii , args , kwargs ):
881- # type: (Union[str, "SpanTemplate "], bool, tuple[Any, ...], dict[str, Any]) -> dict[str, Any]
881+ # type: (Union[str, "SPANTEMPLATE "], bool, tuple[Any, ...], dict[str, Any]) -> dict[str, Any]
882882 """
883883 Get input attributes for the given span template.
884884 """
885885 attributes = {} # type: dict[str, Any]
886886
887- if template in [SpanTemplate .AI_AGENT , SpanTemplate .AI_TOOL , SpanTemplate .AI_CHAT ]:
887+ if template in [SPANTEMPLATE .AI_AGENT , SPANTEMPLATE .AI_TOOL , SPANTEMPLATE .AI_CHAT ]:
888888 for key , value in list (kwargs .items ()):
889889 if key == "model" and isinstance (value , str ):
890890 attributes [SPANDATA .GEN_AI_REQUEST_MODEL ] = value
@@ -923,7 +923,7 @@ def _get_input_attributes(template, send_pii, args, kwargs):
923923 attributes [SPANDATA .GEN_AI_REQUEST_MESSAGES ]
924924 )
925925
926- if template == SpanTemplate .AI_TOOL :
926+ if template == SPANTEMPLATE .AI_TOOL :
927927 if send_pii :
928928 attributes [SPANDATA .GEN_AI_TOOL_INPUT ] = safe_repr (
929929 {"args" : args , "kwargs" : kwargs }
@@ -956,13 +956,13 @@ def _get_usage_attributes(usage):
956956
957957
958958def _get_output_attributes (template , send_pii , result ):
959- # type: (Union[str, "SpanTemplate "], bool, Any) -> dict[str, Any]
959+ # type: (Union[str, "SPANTEMPLATE "], bool, Any) -> dict[str, Any]
960960 """
961961 Get output attributes for the given span template.
962962 """
963963 attributes = {} # type: dict[str, Any]
964964
965- if template in [SpanTemplate .AI_AGENT , SpanTemplate .AI_TOOL , SpanTemplate .AI_CHAT ]:
965+ if template in [SPANTEMPLATE .AI_AGENT , SPANTEMPLATE .AI_TOOL , SPANTEMPLATE .AI_CHAT ]:
966966 attributes .update (_get_usage_attributes (result ))
967967 if hasattr (result , "usage" ):
968968 attributes .update (_get_usage_attributes (result .usage ))
@@ -975,15 +975,15 @@ def _get_output_attributes(template, send_pii, result):
975975 elif hasattr (result , "model_name" ) and isinstance (result .model_name , str ):
976976 attributes [SPANDATA .GEN_AI_RESPONSE_MODEL ] = result .model_name
977977
978- if template == SpanTemplate .AI_TOOL :
978+ if template == SPANTEMPLATE .AI_TOOL :
979979 if send_pii :
980980 attributes [SPANDATA .GEN_AI_TOOL_OUTPUT ] = safe_repr (result )
981981
982982 return attributes
983983
984984
985985def _set_input_attributes (span , template , send_pii , name , f , args , kwargs ):
986- # type: (Span, Union[str, "SpanTemplate "], bool, str, Any, tuple[Any, ...], dict[str, Any]) -> None
986+ # type: (Span, Union[str, "SPANTEMPLATE "], bool, str, Any, tuple[Any, ...], dict[str, Any]) -> None
987987 """
988988 Set span input attributes based on the given span template.
989989
@@ -996,16 +996,16 @@ def _set_input_attributes(span, template, send_pii, name, f, args, kwargs):
996996 """
997997 attributes = {} # type: dict[str, Any]
998998
999- if template == SpanTemplate .AI_AGENT :
999+ if template == SPANTEMPLATE .AI_AGENT :
10001000 attributes = {
10011001 SPANDATA .GEN_AI_OPERATION_NAME : "invoke_agent" ,
10021002 SPANDATA .GEN_AI_AGENT_NAME : name ,
10031003 }
1004- elif template == SpanTemplate .AI_CHAT :
1004+ elif template == SPANTEMPLATE .AI_CHAT :
10051005 attributes = {
10061006 SPANDATA .GEN_AI_OPERATION_NAME : "chat" ,
10071007 }
1008- elif template == SpanTemplate .AI_TOOL :
1008+ elif template == SPANTEMPLATE .AI_TOOL :
10091009 attributes = {
10101010 SPANDATA .GEN_AI_OPERATION_NAME : "execute_tool" ,
10111011 SPANDATA .GEN_AI_TOOL_NAME : name ,
@@ -1020,7 +1020,7 @@ def _set_input_attributes(span, template, send_pii, name, f, args, kwargs):
10201020
10211021
10221022def _set_output_attributes (span , template , send_pii , result ):
1023- # type: (Span, Union[str, "SpanTemplate "], bool, Any) -> None
1023+ # type: (Span, Union[str, "SPANTEMPLATE "], bool, Any) -> None
10241024 """
10251025 Set span output attributes based on the given span template.
10261026
@@ -1031,15 +1031,15 @@ def _set_output_attributes(span, template, send_pii, result):
10311031 """
10321032 attributes = {} # type: dict[str, Any]
10331033
1034- if template == SpanTemplate .AI_AGENT and isinstance (result , str ):
1034+ if template == SPANTEMPLATE .AI_AGENT and isinstance (result , str ):
10351035 attributes [SPANDATA .GEN_AI_TOOL_OUTPUT ] = result
10361036
10371037 attributes .update (_get_output_attributes (template , send_pii , result ))
10381038 span .set_data (attributes )
10391039
10401040
10411041def create_span_decorator (template , op = None , name = None , attributes = None ):
1042- # type: (Union[str, "SpanTemplate "], Optional[str], Optional[str], Optional[dict[str, Any]]) -> Any
1042+ # type: (Union[str, "SPANTEMPLATE "], Optional[str], Optional[str], Optional[dict[str, Any]]) -> Any
10431043 """
10441044 Create a span decorator that can wrap both sync and async functions.
10451045
@@ -1146,7 +1146,7 @@ def sync_wrapper(*args, **kwargs):
11461146
11471147
11481148# Circular imports
1149- from sentry_sdk .consts import SpanTemplate
1149+ from sentry_sdk .consts import SPANTEMPLATE
11501150from sentry_sdk .tracing import (
11511151 BAGGAGE_HEADER_NAME ,
11521152 LOW_QUALITY_TRANSACTION_SOURCES ,
0 commit comments