diff --git a/MIGRATION_GUIDE.md b/MIGRATION_GUIDE.md index 494b0578a5..a6d468c0c4 100644 --- a/MIGRATION_GUIDE.md +++ b/MIGRATION_GUIDE.md @@ -37,6 +37,12 @@ Looking to upgrade from Sentry SDK 2.x to 3.x? Here's a comprehensive list of wh - We now don't suppress chained exceptions in the ASGI and asyncio integrations by default. The related `suppress_asgi_chained_exceptions` experimental option was removed. - In the AWS Lambda and GCP integrations, the text of the message of the warning the SDK optionally emits if a function is about to time out has changed. +#### Span operation consolidation + +Span ops are now a smaller, framework-neutral set. + +- 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`. + #### Django - The Django integration now creates spans for cache operations by default. Pass `DjangoIntegration(cache_spans=False)` to `sentry_sdk.init()` to turn them off. diff --git a/sentry_sdk/integrations/cohere.py b/sentry_sdk/integrations/cohere.py index 941487ab9c..b352937509 100644 --- a/sentry_sdk/integrations/cohere.py +++ b/sentry_sdk/integrations/cohere.py @@ -179,7 +179,7 @@ def new_chat(*args: "Any", **kwargs: "Any") -> "Any": span = sentry_sdk.start_span( name="cohere.client.Chat", attributes={ - "sentry.op": consts.OP.COHERE_CHAT_COMPLETIONS_CREATE, + "sentry.op": consts.OP.GEN_AI_CHAT, "sentry.origin": CohereIntegration.origin, }, ) @@ -266,7 +266,7 @@ def new_embed(*args: "Any", **kwargs: "Any") -> "Any": with sentry_sdk.start_span( name="Cohere Embedding Creation", attributes={ - "sentry.op": consts.OP.COHERE_EMBEDDINGS_CREATE, + "sentry.op": consts.OP.GEN_AI_EMBEDDINGS, "sentry.origin": CohereIntegration.origin, }, ) as span: diff --git a/tests/integrations/cohere/test_cohere.py b/tests/integrations/cohere/test_cohere.py index b483fff24c..f4ff3dbd5a 100644 --- a/tests/integrations/cohere/test_cohere.py +++ b/tests/integrations/cohere/test_cohere.py @@ -7,7 +7,7 @@ from httpx import Client as HTTPXClient import sentry_sdk -from sentry_sdk.consts import SPANDATA +from sentry_sdk.consts import OP, SPANDATA from sentry_sdk.integrations.cohere import CohereIntegration @@ -55,7 +55,7 @@ def test_nonstreaming_chat( assert len(items) == 1 span = items[0].payload - assert span["attributes"]["sentry.op"] == "ai.chat_completions.create.cohere" + assert span["attributes"]["sentry.op"] == OP.GEN_AI_CHAT assert span["attributes"][SPANDATA.AI_MODEL_ID] == "some-model" assert ( @@ -117,7 +117,7 @@ def test_nonstreaming_chat_no_sensitive_data( assert len(items) == 1 span = items[0].payload - assert span["attributes"]["sentry.op"] == "ai.chat_completions.create.cohere" + assert span["attributes"]["sentry.op"] == OP.GEN_AI_CHAT assert span["attributes"][SPANDATA.AI_MODEL_ID] == "some-model" assert SPANDATA.AI_INPUT_MESSAGES not in span["attributes"] @@ -187,7 +187,7 @@ def test_streaming_chat( assert len(items) == 1 span = items[0].payload - assert span["attributes"]["sentry.op"] == "ai.chat_completions.create.cohere" + assert span["attributes"]["sentry.op"] == OP.GEN_AI_CHAT assert span["attributes"][SPANDATA.AI_MODEL_ID] == "some-model" assert ( @@ -264,7 +264,7 @@ def test_streaming_chat_no_sensitive_data( assert len(items) == 1 span = items[0].payload - assert span["attributes"]["sentry.op"] == "ai.chat_completions.create.cohere" + assert span["attributes"]["sentry.op"] == OP.GEN_AI_CHAT assert span["attributes"][SPANDATA.AI_MODEL_ID] == "some-model" assert SPANDATA.AI_INPUT_MESSAGES not in span["attributes"] @@ -317,7 +317,7 @@ def test_embed( assert len(items) == 1 span = items[0].payload - assert span["attributes"]["sentry.op"] == "ai.embeddings.create.cohere" + assert span["attributes"]["sentry.op"] == OP.GEN_AI_EMBEDDINGS assert "hello" in span["attributes"][SPANDATA.AI_INPUT_MESSAGES] assert span["attributes"]["gen_ai.usage.input_tokens"] == 10 @@ -366,7 +366,7 @@ def test_embed_no_sensitive_data( assert len(items) == 1 span = items[0].payload - assert span["attributes"]["sentry.op"] == "ai.embeddings.create.cohere" + assert span["attributes"]["sentry.op"] == OP.GEN_AI_EMBEDDINGS assert SPANDATA.AI_INPUT_MESSAGES not in span["attributes"] assert span["attributes"]["gen_ai.usage.input_tokens"] == 10