Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions sentry_sdk/tracing_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@

from types import FrameType

_MAPPING = {
SPANTEMPLATE.AI_CHAT: OP.GEN_AI_CHAT,
SPANTEMPLATE.AI_AGENT: OP.GEN_AI_INVOKE_AGENT,
SPANTEMPLATE.AI_TOOL: OP.GEN_AI_EXECUTE_TOOL,
}


SENTRY_TRACE_REGEX = re.compile(
"^[ \t]*" # whitespace
Expand Down Expand Up @@ -527,7 +533,9 @@ def _fill_sample_rand(self):
)
return

self.dynamic_sampling_context["sample_rand"] = f"{sample_rand:.6f}" # noqa: E231
self.dynamic_sampling_context["sample_rand"] = (
f"{sample_rand:.6f}" # noqa: E231
)

def _sample_rand(self):
# type: () -> Optional[str]
Expand Down Expand Up @@ -999,12 +1007,7 @@ def _get_span_op(template):
"""
Get the operation of the span based on the template.
"""
mapping = {
SPANTEMPLATE.AI_CHAT: OP.GEN_AI_CHAT,
SPANTEMPLATE.AI_AGENT: OP.GEN_AI_INVOKE_AGENT,
SPANTEMPLATE.AI_TOOL: OP.GEN_AI_EXECUTE_TOOL,
} # type: dict[Union[str, SPANTEMPLATE], Union[str, OP]]
op = mapping.get(template, OP.FUNCTION)
op = _MAPPING.get(template, OP.FUNCTION)

return str(op)

Expand Down