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
3 changes: 2 additions & 1 deletion test-openai/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from openai import OpenAI

import sentry_sdk
import sentry_sdk.traces
from sentry_sdk.ai.monitoring import ai_track
from sentry_sdk.integrations.openai import OpenAIIntegration
from sentry_sdk.integrations.stdlib import StdlibIntegration
Expand Down Expand Up @@ -33,7 +34,7 @@

@ai_track("My sync OpenAI workflow")
def my_workflow(client):
with sentry_sdk.start_transaction(name="openai-sync"):
with sentry_sdk.traces.start_span(name="openai-sync"):
# Responses API with tools
response = client.responses.create(
model="gpt-4o-mini",
Expand Down
3 changes: 2 additions & 1 deletion test-openai/main_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from openai import AsyncOpenAI

import sentry_sdk
import sentry_sdk.traces
from sentry_sdk.ai.monitoring import ai_track
from sentry_sdk.integrations.openai import OpenAIIntegration
from sentry_sdk.integrations.stdlib import StdlibIntegration
Expand Down Expand Up @@ -36,7 +37,7 @@

@ai_track("My async OpenAI workflow")
async def my_workflow(client):
with sentry_sdk.start_transaction(name="openai-async"):
with sentry_sdk.traces.start_span(name="openai-async"):
# Responses API with tools
response = await client.responses.create(
model="gpt-4o-mini",
Expand Down
5 changes: 3 additions & 2 deletions test-openai/main_conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from openai import OpenAI

import sentry_sdk
import sentry_sdk.traces
from sentry_sdk.ai.monitoring import ai_track
from sentry_sdk.ai.utils import set_conversation_id
from sentry_sdk.integrations.openai import OpenAIIntegration
Expand All @@ -21,7 +22,7 @@ def conversation_workflow(client):

messages = []

with sentry_sdk.start_transaction(name="openai-conversation"):
with sentry_sdk.traces.start_span(name="openai-conversation"):
# Turn 1: Initial question
messages.append({"role": "user", "content": "Hi! I'm planning a trip to Japan. What's the best time to visit?"})

Expand Down Expand Up @@ -80,7 +81,7 @@ def interleaved_conversations_workflow(client):
messages_a = []
messages_b = []

with sentry_sdk.start_transaction(name="openai-interleaved-conversations"):
with sentry_sdk.traces.start_span(name="openai-interleaved-conversations"):
# Conversation A - Turn 1
set_conversation_id(conversation_id_a)
messages_a.append({"role": "user", "content": "I want to learn Python. Where should I start?"})
Expand Down
3 changes: 2 additions & 1 deletion test-openai/main_conversation_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from openai import AsyncOpenAI

import sentry_sdk
import sentry_sdk.traces
from sentry_sdk.ai.monitoring import ai_track
from sentry_sdk.ai.utils import set_conversation_id
from sentry_sdk.integrations.asyncio import AsyncioIntegration
Expand Down Expand Up @@ -95,7 +96,7 @@ async def concurrent_conversations_workflow(client):
print(f"Conversation A ID: {conversation_id_a}")
print(f"Conversation B ID: {conversation_id_b}")

with sentry_sdk.start_transaction(name="openai-concurrent-conversations"):
with sentry_sdk.traces.start_span(name="openai-concurrent-conversations"):
# Run both conversations concurrently
results = await asyncio.gather(
conversation_a(client, conversation_id_a),
Expand Down
3 changes: 2 additions & 1 deletion test-openai/main_custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from openai import OpenAI

import sentry_sdk
import sentry_sdk.traces
from sentry_sdk.consts import SPANTEMPLATE, SPANDATA
from sentry_sdk.integrations.openai import OpenAIIntegration
from sentry_sdk.integrations.stdlib import StdlibIntegration
Expand Down Expand Up @@ -65,7 +66,7 @@ def main():
api_key=os.environ.get("OPENAI_API_KEY"),
)

with sentry_sdk.start_transaction(name="main"):
with sentry_sdk.traces.start_span(name="main"):
my_socalled_agent(client)

print("--------------------------------")
Expand Down
3 changes: 2 additions & 1 deletion test-openai/main_streamed.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
from openai import OpenAI

import sentry_sdk
import sentry_sdk.traces
from sentry_sdk.ai.monitoring import ai_track
from sentry_sdk.integrations.openai import OpenAIIntegration
from sentry_sdk.integrations.stdlib import StdlibIntegration


@ai_track("Streamed OpenAI workflow")
def streamed_workflow(client):
with sentry_sdk.start_transaction(name="openai-streamed"):
with sentry_sdk.traces.start_span(name="openai-streamed"):
# Chat Completions API with streaming
print("Starting streamed chat completion...")
stream = client.chat.completions.create(
Expand Down
3 changes: 2 additions & 1 deletion test-openai/main_truncation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from openai import OpenAI

import sentry_sdk
import sentry_sdk.traces
from sentry_sdk.ai.monitoring import ai_track
from sentry_sdk.integrations.openai import OpenAIIntegration
from sentry_sdk.integrations.stdlib import StdlibIntegration
Expand All @@ -24,7 +25,7 @@ def generate_long_message(index):

@ai_track("My truncation test workflow")
def my_truncation_workflow(client):
with sentry_sdk.start_transaction(name="openai-truncation-test"):
with sentry_sdk.traces.start_span(name="openai-truncation-test"):
messages = []

for i in range(25):
Expand Down
Loading