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
38 changes: 2 additions & 36 deletions tests/integrations/aws_lambda/test_aws_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,20 +335,6 @@ def test_user_info_with_data_collection_user_info_on(lambda_client, test_environ
assert _get_span_attr(attrs, "user.id") == "42"


def test_user_info_with_data_collection_user_info_off(lambda_client, test_environment):
lambda_client.invoke(
FunctionName="BasicOkDataCollectionUserInfoOff",
Payload=USER_INFO_PAYLOAD,
)
span_items = test_environment["server"].span_items

segment_spans = [s for s in span_items if s.get("is_segment")]
assert len(segment_spans) == 1
attrs = segment_spans[0]["attributes"]

assert "user.id" not in attrs


def test_request_data_with_data_collection_allowlist(lambda_client, test_environment):
payload = b"""
{
Expand Down Expand Up @@ -902,9 +888,7 @@ def test_url_query_params_with_data_collection(lambda_client, test_environment):
)


def test_span_streaming_user_info_with_send_default_pii(
lambda_client, test_environment
):
def test_user_info_with_send_default_pii(lambda_client, test_environment):
payload = b"""
{
"resource": "/asd",
Expand Down Expand Up @@ -944,25 +928,7 @@ def test_span_streaming_user_info_with_send_default_pii(
assert _get_span_attr(attrs, "user.id") == "42"


def test_span_streaming_user_info_with_data_collection_user_info_on(
lambda_client, test_environment
):
lambda_client.invoke(
FunctionName="BasicOkSpanStreamingDataCollectionUserInfoOn",
Payload=USER_INFO_PAYLOAD,
)
span_items = test_environment["server"].span_items

segment_spans = [s for s in span_items if s.get("is_segment")]
assert len(segment_spans) == 1
attrs = segment_spans[0]["attributes"]

assert _get_span_attr(attrs, "user.id") == "42"


def test_span_streaming_user_info_with_data_collection_user_info_off(
lambda_client, test_environment
):
def test_user_info_with_data_collection_user_info_off(lambda_client, test_environment):
lambda_client.invoke(
FunctionName="BasicOkSpanStreamingDataCollectionUserInfoOff",
Payload=USER_INFO_PAYLOAD,
Expand Down
35 changes: 35 additions & 0 deletions tests/integrations/pydantic_ai/test_pydantic_ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -1093,6 +1093,7 @@ async def test_context_cleanup_after_run(sentry_init, get_test_agent):
sentry_init(
integrations=[PydanticAIIntegration()],
traces_sample_rate=1.0,
trace_lifecycle="stream",
)

# Verify context is not set before run
Expand All @@ -1116,6 +1117,7 @@ def test_context_cleanup_after_run_sync(sentry_init, get_test_agent, sync_event_
sentry_init(
integrations=[PydanticAIIntegration()],
traces_sample_rate=1.0,
trace_lifecycle="stream",
)

# Verify context is not set before run
Expand All @@ -1140,6 +1142,7 @@ async def test_context_cleanup_after_streaming(sentry_init, get_test_agent):
sentry_init(
integrations=[PydanticAIIntegration()],
traces_sample_rate=1.0,
trace_lifecycle="stream",
)

# Verify context is not set before run
Expand All @@ -1166,6 +1169,7 @@ async def test_context_cleanup_on_error(sentry_init, get_test_agent):
sentry_init(
integrations=[PydanticAIIntegration()],
traces_sample_rate=1.0,
trace_lifecycle="stream",
)

test_agent = get_test_agent()
Expand Down Expand Up @@ -1200,6 +1204,7 @@ async def test_context_isolation_concurrent_agents(sentry_init, get_test_agent):
sentry_init(
integrations=[PydanticAIIntegration()],
traces_sample_rate=1.0,
trace_lifecycle="stream",
)

# Create a second agent
Expand Down Expand Up @@ -1355,6 +1360,7 @@ async def test_model_name_extraction_with_callable(
sentry_init(
integrations=[PydanticAIIntegration()],
traces_sample_rate=1.0,
trace_lifecycle="stream",
)

# Test the utility function directly
Expand Down Expand Up @@ -1384,6 +1390,7 @@ async def test_model_name_extraction_fallback_to_str(
sentry_init(
integrations=[PydanticAIIntegration()],
traces_sample_rate=1.0,
trace_lifecycle="stream",
)

# Test the utility function directly
Expand Down Expand Up @@ -1617,6 +1624,7 @@ async def test_update_invoke_agent_span_with_none_output(
sentry_init(
integrations=[PydanticAIIntegration()],
traces_sample_rate=1.0,
trace_lifecycle="stream",
send_default_pii=True,
)

Expand All @@ -1643,6 +1651,7 @@ async def test_update_ai_client_span_with_none_response(
sentry_init(
integrations=[PydanticAIIntegration()],
traces_sample_rate=1.0,
trace_lifecycle="stream",
)

span = sentry_sdk.traces.start_span(name="test_span")
Expand Down Expand Up @@ -1691,6 +1700,7 @@ async def test_input_messages_error_handling(
sentry_init(
integrations=[PydanticAIIntegration()],
traces_sample_rate=1.0,
trace_lifecycle="stream",
send_default_pii=True,
)

Expand Down Expand Up @@ -1720,6 +1730,7 @@ async def test_available_tools_error_handling(
sentry_init(
integrations=[PydanticAIIntegration()],
traces_sample_rate=1.0,
trace_lifecycle="stream",
)

span = sentry_sdk.traces.start_span(name="test_span")
Expand Down Expand Up @@ -1747,6 +1758,7 @@ async def test_set_usage_data_with_none_usage(
sentry_init(
integrations=[PydanticAIIntegration()],
traces_sample_rate=1.0,
trace_lifecycle="stream",
)

span = sentry_sdk.traces.start_span(name="test_span")
Expand All @@ -1772,6 +1784,7 @@ async def test_set_usage_data_with_partial_fields(
sentry_init(
integrations=[PydanticAIIntegration()],
traces_sample_rate=1.0,
trace_lifecycle="stream",
)

span = sentry_sdk.traces.start_span(name="test_span")
Expand Down Expand Up @@ -1844,6 +1857,7 @@ async def test_message_parts_with_list_content(
sentry_init(
integrations=[PydanticAIIntegration()],
traces_sample_rate=1.0,
trace_lifecycle="stream",
send_default_pii=True,
)

Expand Down Expand Up @@ -1956,6 +1970,7 @@ async def test_output_data_error_handling(
sentry_init(
integrations=[PydanticAIIntegration()],
traces_sample_rate=1.0,
trace_lifecycle="stream",
send_default_pii=True,
)

Expand Down Expand Up @@ -1988,6 +2003,7 @@ async def test_message_with_system_prompt_part(
sentry_init(
integrations=[PydanticAIIntegration()],
traces_sample_rate=1.0,
trace_lifecycle="stream",
send_default_pii=True,
)

Expand Down Expand Up @@ -2022,6 +2038,7 @@ async def test_message_with_instructions(
sentry_init(
integrations=[PydanticAIIntegration()],
traces_sample_rate=1.0,
trace_lifecycle="stream",
send_default_pii=True,
)

Expand Down Expand Up @@ -2054,6 +2071,7 @@ async def test_set_input_messages_without_prompts(
sentry_init(
integrations=[PydanticAIIntegration(include_prompts=False)],
traces_sample_rate=1.0,
trace_lifecycle="stream",
send_default_pii=True,
)

Expand All @@ -2080,6 +2098,7 @@ async def test_get_model_name_with_exception_in_callable(
sentry_init(
integrations=[PydanticAIIntegration()],
traces_sample_rate=1.0,
trace_lifecycle="stream",
)

# Create model with callable name that raises exception
Expand All @@ -2105,6 +2124,7 @@ async def test_get_model_name_with_string_model(
sentry_init(
integrations=[PydanticAIIntegration()],
traces_sample_rate=1.0,
trace_lifecycle="stream",
)

# Pass a string as model
Expand All @@ -2126,6 +2146,7 @@ async def test_get_model_name_with_none(
sentry_init(
integrations=[PydanticAIIntegration()],
traces_sample_rate=1.0,
trace_lifecycle="stream",
)

# Pass None
Expand All @@ -2150,6 +2171,7 @@ async def test_should_send_prompts_without_pii(
sentry_init(
integrations=[PydanticAIIntegration(include_prompts=True)],
traces_sample_rate=1.0,
trace_lifecycle="stream",
send_default_pii=False, # PII disabled,
)

Expand All @@ -2173,6 +2195,7 @@ async def test_set_available_tools_without_toolset(
sentry_init(
integrations=[PydanticAIIntegration()],
traces_sample_rate=1.0,
trace_lifecycle="stream",
)

span = sentry_sdk.traces.start_span(name="test_span")
Expand Down Expand Up @@ -2202,6 +2225,7 @@ async def test_set_available_tools_with_schema(
sentry_init(
integrations=[PydanticAIIntegration()],
traces_sample_rate=1.0,
trace_lifecycle="stream",
)

span = sentry_sdk.traces.start_span(name="test_span")
Expand Down Expand Up @@ -2237,6 +2261,7 @@ async def test_execute_tool_span_creation(
sentry_init(
integrations=[PydanticAIIntegration()],
traces_sample_rate=1.0,
trace_lifecycle="stream",
send_default_pii=True,
)

Expand All @@ -2260,6 +2285,7 @@ async def test_execute_tool_span_with_mcp_type(
sentry_init(
integrations=[PydanticAIIntegration()],
traces_sample_rate=1.0,
trace_lifecycle="stream",
send_default_pii=True,
)

Expand All @@ -2284,6 +2310,7 @@ async def test_execute_tool_span_without_prompts(
sentry_init(
integrations=[PydanticAIIntegration(include_prompts=False)],
traces_sample_rate=1.0,
trace_lifecycle="stream",
send_default_pii=True,
)

Expand All @@ -2305,6 +2332,7 @@ async def test_execute_tool_span_with_none_args(
sentry_init(
integrations=[PydanticAIIntegration()],
traces_sample_rate=1.0,
trace_lifecycle="stream",
send_default_pii=True,
)

Expand All @@ -2327,6 +2355,7 @@ async def test_update_execute_tool_span_with_none_span(
sentry_init(
integrations=[PydanticAIIntegration()],
traces_sample_rate=1.0,
trace_lifecycle="stream",
)

# Update with None span - should not raise
Expand All @@ -2351,6 +2380,7 @@ async def test_update_execute_tool_span_with_none_result(
sentry_init(
integrations=[PydanticAIIntegration()],
traces_sample_rate=1.0,
trace_lifecycle="stream",
send_default_pii=True,
)

Expand All @@ -2373,6 +2403,7 @@ async def test_tool_execution_without_span_context(
sentry_init(
integrations=[PydanticAIIntegration()],
traces_sample_rate=1.0,
trace_lifecycle="stream",
)

# Create a simple agent with no tools (won't have function_toolset)
Expand Down Expand Up @@ -2405,6 +2436,7 @@ async def test_invoke_agent_span_with_callable_instruction(
sentry_init(
integrations=[PydanticAIIntegration()],
traces_sample_rate=1.0,
trace_lifecycle="stream",
send_default_pii=True,
)

Expand Down Expand Up @@ -2436,6 +2468,7 @@ async def test_invoke_agent_span_with_string_instructions(
sentry_init(
integrations=[PydanticAIIntegration()],
traces_sample_rate=1.0,
trace_lifecycle="stream",
send_default_pii=True,
)

Expand Down Expand Up @@ -2463,6 +2496,7 @@ async def test_ai_client_span_with_streaming_flag(
sentry_init(
integrations=[PydanticAIIntegration()],
traces_sample_rate=1.0,
trace_lifecycle="stream",
)

# Set streaming flag in scope
Expand All @@ -2489,6 +2523,7 @@ async def test_ai_client_span_gets_agent_from_scope(
sentry_init(
integrations=[PydanticAIIntegration()],
traces_sample_rate=1.0,
trace_lifecycle="stream",
)

# Set agent in scope
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations/starlette/test_starlette.py
Original file line number Diff line number Diff line change
Expand Up @@ -1441,7 +1441,7 @@ def test_active_thread_id(sentry_init, capture_items, endpoint):


@pytest.mark.parametrize("endpoint", ["/sync/thread_ids", "/async/thread_ids"])
def test_http_route_span_streaming(sentry_init, capture_items, endpoint):
def test_http_route(sentry_init, capture_items, endpoint):
sentry_init(
auto_enabling_integrations=False,
integrations=[StarletteIntegration(transaction_style="url")],
Expand Down
38 changes: 0 additions & 38 deletions tests/profiler/test_continuous_profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,44 +558,6 @@ def test_continuous_profiler_manual_start_and_stop_noop_when_using_trace_lifecyl
mode,
class_name,
teardown_profiling,
):
options = make_options(
mode=mode, profile_session_sample_rate=0.0, lifecycle="trace"
)
sentry_init(
traces_sample_rate=1.0,
**options,
)

with mock.patch(
f"sentry_sdk.profiler.continuous_profiler.{class_name}.ensure_running"
) as mock_ensure_running:
start_profiler()
mock_ensure_running.assert_not_called()

with mock.patch(
f"sentry_sdk.profiler.continuous_profiler.{class_name}.teardown"
) as mock_teardown:
stop_profiler()
mock_teardown.assert_not_called()


@pytest.mark.parametrize(
["mode", "class_name"],
[
pytest.param("thread", "ThreadContinuousScheduler"),
pytest.param(
"gevent",
"GeventContinuousScheduler",
marks=requires_gevent,
),
],
)
def test_continuous_profiler_manual_start_and_stop_noop_when_using_trace_lifecyle_span_streaming(
sentry_init,
mode,
class_name,
teardown_profiling,
):
options = make_options(
mode=mode, profile_session_sample_rate=0.0, lifecycle="trace"
Expand Down
Loading
Loading