diff --git a/sentry_sdk/consts.py b/sentry_sdk/consts.py index e6d44e0fc4..dd8b2ef775 100644 --- a/sentry_sdk/consts.py +++ b/sentry_sdk/consts.py @@ -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. @@ -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" """ diff --git a/sentry_sdk/integrations/mcp.py b/sentry_sdk/integrations/mcp.py index 21ec49b0e4..69c75f3a5b 100644 --- a/sentry_sdk/integrations/mcp.py +++ b/sentry_sdk/integrations/mcp.py @@ -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, diff --git a/tests/integrations/fastmcp/test_fastmcp.py b/tests/integrations/fastmcp/test_fastmcp.py index 46c8088ba5..edf101a330 100644 --- a/tests/integrations/fastmcp/test_fastmcp.py +++ b/tests/integrations/fastmcp/test_fastmcp.py @@ -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"] @@ -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"] diff --git a/tests/integrations/mcp/test_mcp.py b/tests/integrations/mcp/test_mcp.py index 41010a4317..038227a6d3 100644 --- a/tests/integrations/mcp/test_mcp.py +++ b/tests/integrations/mcp/test_mcp.py @@ -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" @@ -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"