Skip to content
Merged
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions sentry_sdk/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,12 @@ class SPANDATA:
Example: "qa-pipeline"
"""

GEN_AI_PROMPT_NAME = "gen_ai.prompt.name"
"""
The name of the prompt that uniquely identifies it.
Example: "summarize_text"
"""

GEN_AI_RESPONSE_FINISH_REASONS = "gen_ai.response.finish_reasons"
"""
The reason why the model stopped generating.
Expand Down Expand Up @@ -1095,6 +1101,9 @@ class SPANDATA:

MCP_PROMPT_NAME = "mcp.prompt.name"
"""
.. deprecated::
This attribute is deprecated. Use GEN_AI_PROMPT_NAME instead.

The name of the MCP prompt being retrieved.
Example: "code_review"
"""
Expand Down
2 changes: 1 addition & 1 deletion sentry_sdk/integrations/mcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ async def _instrument_prompt_get(
_set_span_input_data(
span,
handler_name,
SPANDATA.MCP_PROMPT_NAME,
SPANDATA.GEN_AI_PROMPT_NAME,
"prompts/get",
arguments,
request_id,
Expand Down
4 changes: 2 additions & 2 deletions tests/integrations/fastmcp/test_fastmcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ def code_help_prompt(language: str):
span = prompt_spans[0]
assert span["attributes"]["sentry.origin"] == "auto.ai.mcp"
assert span["name"] == "prompts/get code_help_prompt"
assert span["attributes"][SPANDATA.MCP_PROMPT_NAME] == "code_help_prompt"
assert span["attributes"][SPANDATA.GEN_AI_PROMPT_NAME] == "code_help_prompt"

assert SPANDATA.MCP_PROMPT_RESULT_MESSAGE_CONTENT in span["attributes"]

Expand Down Expand Up @@ -763,7 +763,7 @@ def code_help_prompt(language: str):
span = prompt_spans[0]
assert span["attributes"]["sentry.origin"] == "auto.ai.mcp"
assert span["name"] == "prompts/get code_help_prompt"
assert span["attributes"][SPANDATA.MCP_PROMPT_NAME] == "code_help_prompt"
assert span["attributes"][SPANDATA.GEN_AI_PROMPT_NAME] == "code_help_prompt"

assert SPANDATA.MCP_PROMPT_RESULT_MESSAGE_CONTENT not in span["attributes"]

Expand Down
4 changes: 2 additions & 2 deletions tests/integrations/mcp/test_mcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ async def test_prompt(ctx, params):
assert data["sentry.origin"] == "auto.ai.mcp"

# Check span data
assert data[SPANDATA.MCP_PROMPT_NAME] == "code_help"
assert data[SPANDATA.GEN_AI_PROMPT_NAME] == "code_help"
assert data[SPANDATA.MCP_METHOD_NAME] == "prompts/get"
assert data[SPANDATA.MCP_TRANSPORT] == "stdio"
assert data[SPANDATA.MCP_REQUEST_ID] == "req-prompt"
Expand Down Expand Up @@ -776,7 +776,7 @@ async def test_prompt(ctx, params):
assert data["sentry.origin"] == "auto.ai.mcp"

# Check span data
assert data[SPANDATA.MCP_PROMPT_NAME] == "code_help"
assert data[SPANDATA.GEN_AI_PROMPT_NAME] == "code_help"
assert data[SPANDATA.MCP_METHOD_NAME] == "prompts/get"
assert data[SPANDATA.MCP_TRANSPORT] == "stdio"
assert data[SPANDATA.MCP_REQUEST_ID] == "req-prompt"
Expand Down
Loading