Skip to content

Commit 7ed3e35

Browse files
chore: Replace deprecated gen_ai.responses op with gen_ai.chat (#7963)
1 parent fe39dbb commit 7ed3e35

3 files changed

Lines changed: 16 additions & 17 deletions

File tree

‎MIGRATION_GUIDE.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Looking to upgrade from Sentry SDK 2.x to 3.x? Here's a comprehensive list of wh
4141

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

44+
- The OpenAI integration now emits `gen_ai.chat` instead of `gen_ai.responses`.
4445
- 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`.
4546
- The Django integration now emits `view.render` instead of `view.response.render`, `view` instead of `view.authenticate`, and `function` instead of `event.django`.
4647
- 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`.

‎sentry_sdk/integrations/openai.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,7 @@ def _new_sync_responses_create(
13211321
span = sentry_sdk.start_span(
13221322
name=f"responses {model}",
13231323
attributes={
1324-
"sentry.op": consts.OP.GEN_AI_RESPONSES,
1324+
"sentry.op": consts.OP.GEN_AI_CHAT,
13251325
"sentry.origin": OpenAIIntegration.origin,
13261326
SPANDATA.GEN_AI_PROVIDER_NAME: "openai",
13271327
SPANDATA.GEN_AI_RESPONSE_STREAMING: is_streaming_response,
@@ -1389,7 +1389,7 @@ async def _new_async_responses_create(
13891389
span = sentry_sdk.start_span(
13901390
name=f"responses {model}",
13911391
attributes={
1392-
"sentry.op": consts.OP.GEN_AI_RESPONSES,
1392+
"sentry.op": consts.OP.GEN_AI_CHAT,
13931393
"sentry.origin": OpenAIIntegration.origin,
13941394
SPANDATA.GEN_AI_PROVIDER_NAME: "openai",
13951395
SPANDATA.GEN_AI_RESPONSE_STREAMING: is_streaming_response,

‎tests/integrations/openai/test_openai.py‎

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2850,7 +2850,7 @@ def test_ai_client_span_responses_api_no_sensitive_data(
28502850
"gen_ai.usage.output_tokens": 10,
28512851
SPANDATA.GEN_AI_USAGE_REASONING_OUTPUT_TOKENS: 8,
28522852
"gen_ai.usage.total_tokens": 30,
2853-
"sentry.op": "gen_ai.responses",
2853+
"sentry.op": OP.GEN_AI_CHAT,
28542854
"sentry.origin": "auto.ai.openai",
28552855
}
28562856

@@ -3134,7 +3134,7 @@ def test_ai_client_span_responses_api(
31343134
"gen_ai.request.messages": safe_serialize(expected_request_messages),
31353135
"gen_ai.request.model": "gpt-4o",
31363136
"gen_ai.response.text": "the model response",
3137-
"sentry.op": "gen_ai.responses",
3137+
"sentry.op": OP.GEN_AI_CHAT,
31383138
"sentry.origin": "auto.ai.openai",
31393139
}
31403140

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

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

@@ -3476,7 +3476,7 @@ async def test_ai_client_span_responses_async_api(
34763476
SPANDATA.GEN_AI_USAGE_REASONING_OUTPUT_TOKENS: 8,
34773477
"gen_ai.usage.total_tokens": 30,
34783478
"gen_ai.response.text": "the model response",
3479-
"sentry.op": "gen_ai.responses",
3479+
"sentry.op": OP.GEN_AI_CHAT,
34803480
"sentry.origin": "auto.ai.openai",
34813481
}
34823482

@@ -3684,9 +3684,7 @@ async def test_ai_client_span_streaming_responses_async_api(
36843684
sentry_sdk.flush()
36853685
spans = [item.payload for item in items]
36863686
spans = [
3687-
span
3688-
for span in spans
3689-
if span["attributes"].get("sentry.op") == OP.GEN_AI_RESPONSES
3687+
span for span in spans if span["attributes"].get("sentry.op") == OP.GEN_AI_CHAT
36903688
]
36913689

36923690
assert len(spans) == 1
@@ -3710,7 +3708,7 @@ async def test_ai_client_span_streaming_responses_async_api(
37103708
"gen_ai.request.model": "gpt-4o",
37113709
"gen_ai.response.text": "hello world",
37123710
"sentry.environment": "production",
3713-
"sentry.op": "gen_ai.responses",
3711+
"sentry.op": OP.GEN_AI_CHAT,
37143712
"sentry.origin": "auto.ai.openai",
37153713
}
37163714

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

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

@@ -3892,7 +3890,7 @@ def test_streaming_responses_api(
38923890

38933891
sentry_sdk.flush()
38943892
(span,) = (item.payload for item in items)
3895-
assert span["attributes"]["sentry.op"] == "gen_ai.responses"
3893+
assert span["attributes"]["sentry.op"] == OP.GEN_AI_CHAT
38963894
assert span["attributes"][SPANDATA.GEN_AI_PROVIDER_NAME] == "openai"
38973895
assert span["attributes"][SPANDATA.GEN_AI_REQUEST_MAX_TOKENS] == 100
38983896
assert span["attributes"][SPANDATA.GEN_AI_REQUEST_TEMPERATURE] == 0.7
@@ -3960,7 +3958,7 @@ def test_streaming_responses_api_no_sensitive_data(
39603958

39613959
sentry_sdk.flush()
39623960
(span,) = (item.payload for item in items)
3963-
assert span["attributes"]["sentry.op"] == "gen_ai.responses"
3961+
assert span["attributes"]["sentry.op"] == OP.GEN_AI_CHAT
39643962
assert span["attributes"][SPANDATA.GEN_AI_PROVIDER_NAME] == "openai"
39653963
assert span["attributes"][SPANDATA.GEN_AI_REQUEST_MAX_TOKENS] == 100
39663964
assert span["attributes"][SPANDATA.GEN_AI_REQUEST_TEMPERATURE] == 0.7
@@ -4028,7 +4026,7 @@ async def test_streaming_responses_api_async(
40284026

40294027
sentry_sdk.flush()
40304028
(span,) = (item.payload for item in items)
4031-
assert span["attributes"]["sentry.op"] == "gen_ai.responses"
4029+
assert span["attributes"]["sentry.op"] == OP.GEN_AI_CHAT
40324030
assert span["attributes"][SPANDATA.GEN_AI_PROVIDER_NAME] == "openai"
40334031
assert span["attributes"][SPANDATA.GEN_AI_REQUEST_MAX_TOKENS] == 100
40344032
assert span["attributes"][SPANDATA.GEN_AI_REQUEST_TEMPERATURE] == 0.7
@@ -4096,7 +4094,7 @@ async def test_streaming_responses_api_async_no_sensitive_data(
40964094

40974095
sentry_sdk.flush()
40984096
(span,) = (item.payload for item in items)
4099-
assert span["attributes"]["sentry.op"] == "gen_ai.responses"
4097+
assert span["attributes"]["sentry.op"] == OP.GEN_AI_CHAT
41004098
assert span["attributes"][SPANDATA.GEN_AI_PROVIDER_NAME] == "openai"
41014099
assert span["attributes"][SPANDATA.GEN_AI_REQUEST_MAX_TOKENS] == 100
41024100
assert span["attributes"][SPANDATA.GEN_AI_REQUEST_TEMPERATURE] == 0.7
@@ -4441,7 +4439,7 @@ def test_streaming_responses_api_ttft(
44414439

44424440
sentry_sdk.flush()
44434441
span = next(item.payload for item in items)
4444-
assert span["attributes"]["sentry.op"] == "gen_ai.responses"
4442+
assert span["attributes"]["sentry.op"] == OP.GEN_AI_CHAT
44454443

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

44934491
sentry_sdk.flush()
44944492
span = next(item.payload for item in items)
4495-
assert span["attributes"]["sentry.op"] == "gen_ai.responses"
4493+
assert span["attributes"]["sentry.op"] == OP.GEN_AI_CHAT
44964494

44974495
# Verify TTFT is captured
44984496
assert SPANDATA.GEN_AI_RESPONSE_TIME_TO_FIRST_CHUNK in span["attributes"]

0 commit comments

Comments
 (0)