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
1 change: 1 addition & 0 deletions MIGRATION_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Looking to upgrade from Sentry SDK 2.x to 3.x? Here's a comprehensive list of wh

Span ops are now a smaller, framework-neutral set.

- The OpenAI integration now emits `gen_ai.chat` instead of `gen_ai.responses`.
- The Cohere integration now emits `gen_ai.chat` instead of `ai.chat_completions.create.cohere`, and `gen_ai.embeddings` instead of `ai.embeddings.create.cohere`.
- The Django integration now emits `view.render` instead of `view.response.render`, `view` instead of `view.authenticate`, and `function` instead of `event.django`.
- The Django, Starlette, Starlite, and Litestar integrations now emit `middleware` instead of `middleware.django`, `middleware.starlette`, `middleware.starlette.receive`, `middleware.starlette.send`, `middleware.starlite`, `middleware.starlite.receive`, `middleware.starlite.send`, `middleware.litestar`, `middleware.litestar.receive`, and `middleware.litestar.send`.
Expand Down
4 changes: 2 additions & 2 deletions sentry_sdk/integrations/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -1321,7 +1321,7 @@ def _new_sync_responses_create(
span = sentry_sdk.start_span(
name=f"responses {model}",
attributes={
"sentry.op": consts.OP.GEN_AI_RESPONSES,
"sentry.op": consts.OP.GEN_AI_CHAT,
"sentry.origin": OpenAIIntegration.origin,
SPANDATA.GEN_AI_PROVIDER_NAME: "openai",
SPANDATA.GEN_AI_RESPONSE_STREAMING: is_streaming_response,
Expand Down Expand Up @@ -1389,7 +1389,7 @@ async def _new_async_responses_create(
span = sentry_sdk.start_span(
name=f"responses {model}",
attributes={
"sentry.op": consts.OP.GEN_AI_RESPONSES,
"sentry.op": consts.OP.GEN_AI_CHAT,
"sentry.origin": OpenAIIntegration.origin,
SPANDATA.GEN_AI_PROVIDER_NAME: "openai",
SPANDATA.GEN_AI_RESPONSE_STREAMING: is_streaming_response,
Expand Down
28 changes: 13 additions & 15 deletions tests/integrations/openai/test_openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -2850,7 +2850,7 @@ def test_ai_client_span_responses_api_no_sensitive_data(
"gen_ai.usage.output_tokens": 10,
SPANDATA.GEN_AI_USAGE_REASONING_OUTPUT_TOKENS: 8,
"gen_ai.usage.total_tokens": 30,
"sentry.op": "gen_ai.responses",
"sentry.op": OP.GEN_AI_CHAT,
"sentry.origin": "auto.ai.openai",
}

Expand Down Expand Up @@ -3134,7 +3134,7 @@ def test_ai_client_span_responses_api(
"gen_ai.request.messages": safe_serialize(expected_request_messages),
"gen_ai.request.model": "gpt-4o",
"gen_ai.response.text": "the model response",
"sentry.op": "gen_ai.responses",
"sentry.op": OP.GEN_AI_CHAT,
"sentry.origin": "auto.ai.openai",
}

Expand Down Expand Up @@ -3265,7 +3265,7 @@ def test_error_in_responses_api(
# make sure the span where the error occurred is captured
sentry_sdk.flush()
spans = [item.payload for item in items if item.type == "span"]
assert spans[0]["attributes"]["sentry.op"] == "gen_ai.responses"
assert spans[0]["attributes"]["sentry.op"] == OP.GEN_AI_CHAT

(error_event,) = (item.payload for item in items if item.type == "event")

Expand Down Expand Up @@ -3476,7 +3476,7 @@ async def test_ai_client_span_responses_async_api(
SPANDATA.GEN_AI_USAGE_REASONING_OUTPUT_TOKENS: 8,
"gen_ai.usage.total_tokens": 30,
"gen_ai.response.text": "the model response",
"sentry.op": "gen_ai.responses",
"sentry.op": OP.GEN_AI_CHAT,
"sentry.origin": "auto.ai.openai",
}

Expand Down Expand Up @@ -3684,9 +3684,7 @@ async def test_ai_client_span_streaming_responses_async_api(
sentry_sdk.flush()
spans = [item.payload for item in items]
spans = [
span
for span in spans
if span["attributes"].get("sentry.op") == OP.GEN_AI_RESPONSES
span for span in spans if span["attributes"].get("sentry.op") == OP.GEN_AI_CHAT
]

assert len(spans) == 1
Expand All @@ -3710,7 +3708,7 @@ async def test_ai_client_span_streaming_responses_async_api(
"gen_ai.request.model": "gpt-4o",
"gen_ai.response.text": "hello world",
"sentry.environment": "production",
"sentry.op": "gen_ai.responses",
"sentry.op": OP.GEN_AI_CHAT,
"sentry.origin": "auto.ai.openai",
}

Expand Down Expand Up @@ -3757,7 +3755,7 @@ async def test_error_in_responses_async_api(
# make sure the span where the error occurred is captured
sentry_sdk.flush()
spans = [item.payload for item in items if item.type == "span"]
assert spans[0]["attributes"]["sentry.op"] == "gen_ai.responses"
assert spans[0]["attributes"]["sentry.op"] == OP.GEN_AI_CHAT

(error_event,) = (item.payload for item in items if item.type == "event")

Expand Down Expand Up @@ -3892,7 +3890,7 @@ def test_streaming_responses_api(

sentry_sdk.flush()
(span,) = (item.payload for item in items)
assert span["attributes"]["sentry.op"] == "gen_ai.responses"
assert span["attributes"]["sentry.op"] == OP.GEN_AI_CHAT
assert span["attributes"][SPANDATA.GEN_AI_PROVIDER_NAME] == "openai"
assert span["attributes"][SPANDATA.GEN_AI_REQUEST_MAX_TOKENS] == 100
assert span["attributes"][SPANDATA.GEN_AI_REQUEST_TEMPERATURE] == 0.7
Expand Down Expand Up @@ -3960,7 +3958,7 @@ def test_streaming_responses_api_no_sensitive_data(

sentry_sdk.flush()
(span,) = (item.payload for item in items)
assert span["attributes"]["sentry.op"] == "gen_ai.responses"
assert span["attributes"]["sentry.op"] == OP.GEN_AI_CHAT
assert span["attributes"][SPANDATA.GEN_AI_PROVIDER_NAME] == "openai"
assert span["attributes"][SPANDATA.GEN_AI_REQUEST_MAX_TOKENS] == 100
assert span["attributes"][SPANDATA.GEN_AI_REQUEST_TEMPERATURE] == 0.7
Expand Down Expand Up @@ -4028,7 +4026,7 @@ async def test_streaming_responses_api_async(

sentry_sdk.flush()
(span,) = (item.payload for item in items)
assert span["attributes"]["sentry.op"] == "gen_ai.responses"
assert span["attributes"]["sentry.op"] == OP.GEN_AI_CHAT
assert span["attributes"][SPANDATA.GEN_AI_PROVIDER_NAME] == "openai"
assert span["attributes"][SPANDATA.GEN_AI_REQUEST_MAX_TOKENS] == 100
assert span["attributes"][SPANDATA.GEN_AI_REQUEST_TEMPERATURE] == 0.7
Expand Down Expand Up @@ -4096,7 +4094,7 @@ async def test_streaming_responses_api_async_no_sensitive_data(

sentry_sdk.flush()
(span,) = (item.payload for item in items)
assert span["attributes"]["sentry.op"] == "gen_ai.responses"
assert span["attributes"]["sentry.op"] == OP.GEN_AI_CHAT
assert span["attributes"][SPANDATA.GEN_AI_PROVIDER_NAME] == "openai"
assert span["attributes"][SPANDATA.GEN_AI_REQUEST_MAX_TOKENS] == 100
assert span["attributes"][SPANDATA.GEN_AI_REQUEST_TEMPERATURE] == 0.7
Expand Down Expand Up @@ -4441,7 +4439,7 @@ def test_streaming_responses_api_ttft(

sentry_sdk.flush()
span = next(item.payload for item in items)
assert span["attributes"]["sentry.op"] == "gen_ai.responses"
assert span["attributes"]["sentry.op"] == OP.GEN_AI_CHAT

# Verify TTFT is captured
assert SPANDATA.GEN_AI_RESPONSE_TIME_TO_FIRST_CHUNK in span["attributes"]
Expand Down Expand Up @@ -4492,7 +4490,7 @@ async def test_streaming_responses_api_ttft_async(

sentry_sdk.flush()
span = next(item.payload for item in items)
assert span["attributes"]["sentry.op"] == "gen_ai.responses"
assert span["attributes"]["sentry.op"] == OP.GEN_AI_CHAT

# Verify TTFT is captured
assert SPANDATA.GEN_AI_RESPONSE_TIME_TO_FIRST_CHUNK in span["attributes"]
Expand Down
Loading