Skip to content

OpenAI integration update #4612

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 29, 2025
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
6 changes: 3 additions & 3 deletions sentry_sdk/ai/monitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def sync_wrapped(*args, **kwargs):
for k, v in kwargs.pop("sentry_data", {}).items():
span.set_data(k, v)
if curr_pipeline:
span.set_data(SPANDATA.AI_PIPELINE_NAME, curr_pipeline)
span.set_data(SPANDATA.GEN_AI_PIPELINE_NAME, curr_pipeline)
return f(*args, **kwargs)
else:
_ai_pipeline_name.set(description)
Expand Down Expand Up @@ -69,7 +69,7 @@ async def async_wrapped(*args, **kwargs):
for k, v in kwargs.pop("sentry_data", {}).items():
span.set_data(k, v)
if curr_pipeline:
span.set_data(SPANDATA.AI_PIPELINE_NAME, curr_pipeline)
span.set_data(SPANDATA.GEN_AI_PIPELINE_NAME, curr_pipeline)
return await f(*args, **kwargs)
else:
_ai_pipeline_name.set(description)
Expand Down Expand Up @@ -108,7 +108,7 @@ def record_token_usage(
# TODO: move pipeline name elsewhere
ai_pipeline_name = get_ai_pipeline_name()
if ai_pipeline_name:
span.set_data(SPANDATA.AI_PIPELINE_NAME, ai_pipeline_name)
span.set_data(SPANDATA.GEN_AI_PIPELINE_NAME, ai_pipeline_name)

if input_tokens is not None:
span.set_data(SPANDATA.GEN_AI_USAGE_INPUT_TOKENS, input_tokens)
Expand Down
26 changes: 23 additions & 3 deletions sentry_sdk/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ class SPANDATA:
AI_PIPELINE_NAME = "ai.pipeline.name"
"""
Name of the AI pipeline or chain being executed.
DEPRECATED: Use GEN_AI_PIPELINE_NAME instead.
Example: "qa-pipeline"
"""

Expand Down Expand Up @@ -229,6 +230,7 @@ class SPANDATA:
AI_STREAMING = "ai.streaming"
"""
Whether or not the AI model call's response was streamed back asynchronously
DEPRECATED: Use GEN_AI_RESPONSE_STREAMING instead.
Example: true
"""

Expand Down Expand Up @@ -372,6 +374,24 @@ class SPANDATA:
Example: "chat"
"""

GEN_AI_PIPELINE_NAME = "gen_ai.pipeline.name"
"""
Name of the AI pipeline or chain being executed.
Example: "qa-pipeline"
"""

GEN_AI_RESPONSE_MODEL = "gen_ai.response.model"
"""
Exact model identifier used to generate the response
Example: gpt-4o-mini-2024-07-18
"""

GEN_AI_RESPONSE_STREAMING = "gen_ai.response.streaming"
"""
Whether or not the AI model call's response was streamed back asynchronously
Example: true
"""

GEN_AI_RESPONSE_TEXT = "gen_ai.response.text"
"""
The model's response text messages.
Expand Down Expand Up @@ -411,7 +431,7 @@ class SPANDATA:
GEN_AI_REQUEST_MODEL = "gen_ai.request.model"
"""
The model identifier being used for the request.
Example: "gpt-4-turbo-preview"
Example: "gpt-4-turbo"
"""

GEN_AI_REQUEST_PRESENCE_PENALTY = "gen_ai.request.presence_penalty"
Expand Down Expand Up @@ -649,9 +669,11 @@ class OP:
FUNCTION_AWS = "function.aws"
FUNCTION_GCP = "function.gcp"
GEN_AI_CHAT = "gen_ai.chat"
GEN_AI_EMBEDDINGS = "gen_ai.embeddings"
GEN_AI_EXECUTE_TOOL = "gen_ai.execute_tool"
GEN_AI_HANDOFF = "gen_ai.handoff"
GEN_AI_INVOKE_AGENT = "gen_ai.invoke_agent"
GEN_AI_RESPONSES = "gen_ai.responses"
GRAPHQL_EXECUTE = "graphql.execute"
GRAPHQL_MUTATION = "graphql.mutation"
GRAPHQL_PARSE = "graphql.parse"
Expand All @@ -674,8 +696,6 @@ class OP:
MIDDLEWARE_STARLITE = "middleware.starlite"
MIDDLEWARE_STARLITE_RECEIVE = "middleware.starlite.receive"
MIDDLEWARE_STARLITE_SEND = "middleware.starlite.send"
OPENAI_CHAT_COMPLETIONS_CREATE = "ai.chat_completions.create.openai"
OPENAI_EMBEDDINGS_CREATE = "ai.embeddings.create.openai"
HUGGINGFACE_HUB_CHAT_COMPLETIONS_CREATE = (
"ai.chat_completions.create.huggingface_hub"
)
Expand Down
Loading
Loading