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
10 changes: 2 additions & 8 deletions tests/integrations/aiohttp/test_aiohttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1904,10 +1904,7 @@ async def test_server_url_query_data_collection_span_streaming(
sentry_init(
integrations=[AioHttpIntegration()],
traces_sample_rate=1.0,
_experiments={
"trace_lifecycle": "stream",
**init_kwargs.pop("_experiments", {}),
},
trace_lifecycle="stream",
**init_kwargs,
)

Expand Down Expand Up @@ -1949,10 +1946,7 @@ async def test_client_url_query_data_collection_span_streaming(
sentry_init(
integrations=[AioHttpIntegration()],
traces_sample_rate=1.0,
_experiments={
"trace_lifecycle": "stream",
**init_kwargs.pop("_experiments", {}),
},
trace_lifecycle="stream",
**init_kwargs,
)

Expand Down
32 changes: 8 additions & 24 deletions tests/integrations/aiomysql/test_aiomysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,9 +441,7 @@ async def test_query_source_disabled(
"traces_sample_rate": 1.0,
"enable_db_query_source": False,
"db_query_source_threshold_ms": 0,
"_experiments": {
"trace_lifecycle": "stream" if span_streaming else "static",
},
"trace_lifecycle": "stream" if span_streaming else "static",
}

sentry_init(**sentry_options)
Expand Down Expand Up @@ -516,9 +514,7 @@ async def test_query_source_enabled(
"integrations": [AioMySQLIntegration()],
"traces_sample_rate": 1.0,
"db_query_source_threshold_ms": 0,
"_experiments": {
"trace_lifecycle": "stream" if span_streaming else "static",
},
"trace_lifecycle": "stream" if span_streaming else "static",
}
if enable_db_query_source is not None:
sentry_options["enable_db_query_source"] = enable_db_query_source
Expand Down Expand Up @@ -591,9 +587,7 @@ async def test_query_source(sentry_init, capture_events, capture_items, span_str
traces_sample_rate=1.0,
enable_db_query_source=True,
db_query_source_threshold_ms=0,
_experiments={
"trace_lifecycle": "stream" if span_streaming else "static",
},
trace_lifecycle="stream" if span_streaming else "static",
)

if span_streaming:
Expand Down Expand Up @@ -692,9 +686,7 @@ async def test_no_query_source_if_duration_too_short(
traces_sample_rate=1.0,
enable_db_query_source=True,
db_query_source_threshold_ms=100,
_experiments={
"trace_lifecycle": "stream" if span_streaming else "static",
},
trace_lifecycle="stream" if span_streaming else "static",
)

if span_streaming:
Expand Down Expand Up @@ -789,9 +781,7 @@ async def test_query_source_if_duration_over_threshold(
traces_sample_rate=1.0,
enable_db_query_source=True,
db_query_source_threshold_ms=100,
_experiments={
"trace_lifecycle": "stream" if span_streaming else "static",
},
trace_lifecycle="stream" if span_streaming else "static",
)

if span_streaming:
Expand Down Expand Up @@ -915,9 +905,7 @@ async def test_span_origin(sentry_init, capture_events, capture_items, span_stre
sentry_init(
integrations=[AioMySQLIntegration()],
traces_sample_rate=1.0,
_experiments={
"trace_lifecycle": "stream" if span_streaming else "static",
},
trace_lifecycle="stream" if span_streaming else "static",
)

if span_streaming:
Expand Down Expand Up @@ -972,9 +960,7 @@ async def test_multiline_query_description_normalized(
sentry_init(
integrations=[AioMySQLIntegration()],
traces_sample_rate=1.0,
_experiments={
"trace_lifecycle": "stream" if span_streaming else "static",
},
trace_lifecycle="stream" if span_streaming else "static",
)

if span_streaming:
Expand Down Expand Up @@ -1099,9 +1085,7 @@ async def test_db_data_on_spans(
sentry_init(
integrations=[AioMySQLIntegration()],
traces_sample_rate=1.0,
_experiments={
"trace_lifecycle": "stream" if span_streaming else "static",
},
trace_lifecycle="stream" if span_streaming else "static",
)

if span_streaming:
Expand Down
58 changes: 21 additions & 37 deletions tests/integrations/asgi/test_asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,7 @@ async def test_capture_transaction(
sentry_init(
send_default_pii=should_send_pii,
traces_sample_rate=1.0,
_experiments={
"trace_lifecycle": "stream" if span_streaming else "static",
},
trace_lifecycle="stream" if span_streaming else "static",
)
app = SentryAsgiMiddleware(asgi3_app)

Expand Down Expand Up @@ -262,9 +260,7 @@ async def test_capture_transaction_with_error(
sentry_init(
send_default_pii=True,
traces_sample_rate=1.0,
_experiments={
"trace_lifecycle": "stream" if span_streaming else "static",
},
trace_lifecycle="stream" if span_streaming else "static",
)

app = SentryAsgiMiddleware(asgi3_app_with_error)
Expand Down Expand Up @@ -330,9 +326,7 @@ async def test_has_trace_if_performance_enabled(
):
sentry_init(
traces_sample_rate=1.0,
_experiments={
"trace_lifecycle": "stream" if span_streaming else "static",
},
trace_lifecycle="stream" if span_streaming else "static",
)
app = SentryAsgiMiddleware(asgi3_app_with_error_and_msg)

Expand Down Expand Up @@ -425,9 +419,7 @@ async def test_trace_from_headers_if_performance_enabled(
):
sentry_init(
traces_sample_rate=1.0,
_experiments={
"trace_lifecycle": "stream" if span_streaming else "static",
},
trace_lifecycle="stream" if span_streaming else "static",
)
app = SentryAsgiMiddleware(asgi3_app_with_error_and_msg)

Expand Down Expand Up @@ -526,9 +518,7 @@ async def test_websocket(
sentry_init(
send_default_pii=True,
traces_sample_rate=1.0,
_experiments={
"trace_lifecycle": "stream" if span_streaming else "static",
},
trace_lifecycle="stream" if span_streaming else "static",
)

asgi3_ws_app = SentryAsgiMiddleware(asgi3_ws_app)
Expand Down Expand Up @@ -655,9 +645,7 @@ async def test_transaction_style(
sentry_init(
send_default_pii=True,
traces_sample_rate=1.0,
_experiments={
"trace_lifecycle": "stream" if span_streaming else "static",
},
trace_lifecycle="stream" if span_streaming else "static",
)
app = SentryAsgiMiddleware(asgi3_app, transaction_style=transaction_style)

Expand Down Expand Up @@ -874,8 +862,8 @@ async def test_get_request_attributes_url_with_filtered_host(
sentry_init(
send_default_pii=True,
traces_sample_rate=1.0,
trace_lifecycle="stream",
_experiments={
"trace_lifecycle": "stream",
"data_collection": {
"http_headers": {"request": {"mode": "allowlist", "terms": []}}
},
Expand Down Expand Up @@ -906,8 +894,8 @@ async def test_get_request_attributes_url_with_headers_off(
sentry_init(
send_default_pii=True,
traces_sample_rate=1.0,
trace_lifecycle="stream",
_experiments={
"trace_lifecycle": "stream",
"data_collection": {"http_headers": {"request": {"mode": "off"}}},
},
)
Expand Down Expand Up @@ -1140,9 +1128,11 @@ async def test_get_request_attributes_query_data_collection(
expected_query,
expected_url_full,
):
kwargs = {k: v for k, v in init_kwargs.items() if k != "_experiments"}
experiments = {"trace_lifecycle": "stream", **init_kwargs.get("_experiments", {})}
sentry_init(traces_sample_rate=1.0, _experiments=experiments, **kwargs)
sentry_init(
traces_sample_rate=1.0,
trace_lifecycle="stream",
**init_kwargs,
)
app = SentryAsgiMiddleware(asgi3_app)

items = capture_items("span")
Expand Down Expand Up @@ -1242,9 +1232,11 @@ async def test_get_request_data_env_user_info(
async def test_get_request_attributes_client_address_user_info(
sentry_init, capture_items, asgi3_app, init_kwargs, has_client, expect_ip
):
kwargs = {k: v for k, v in init_kwargs.items() if k != "_experiments"}
experiments = {"trace_lifecycle": "stream", **init_kwargs.get("_experiments", {})}
sentry_init(traces_sample_rate=1.0, _experiments=experiments, **kwargs)
sentry_init(
traces_sample_rate=1.0,
trace_lifecycle="stream",
**init_kwargs,
)
app = SentryAsgiMiddleware(asgi3_app)

scope = _http_scope()
Expand Down Expand Up @@ -1304,9 +1296,7 @@ async def test_transaction_name(
"""
sentry_init(
traces_sample_rate=1.0,
_experiments={
"trace_lifecycle": "stream" if span_streaming else "static",
},
trace_lifecycle="stream" if span_streaming else "static",
)

if span_streaming:
Expand Down Expand Up @@ -1390,9 +1380,7 @@ def dummy_traces_sampler(sampling_context):
sentry_init(
traces_sampler=dummy_traces_sampler,
traces_sample_rate=1.0,
_experiments={
"trace_lifecycle": "stream" if span_streaming else "static",
},
trace_lifecycle="stream" if span_streaming else "static",
)

app = SentryAsgiMiddleware(asgi3_app, transaction_style=transaction_style)
Expand All @@ -1415,9 +1403,7 @@ async def test_custom_transaction_name(
):
sentry_init(
traces_sample_rate=1.0,
_experiments={
"trace_lifecycle": "stream" if span_streaming else "static",
},
trace_lifecycle="stream" if span_streaming else "static",
)
app = SentryAsgiMiddleware(asgi3_custom_transaction_app)

Expand Down Expand Up @@ -1505,11 +1491,9 @@ async def app(scope, receive, send):
await send({"type": "http.response.body", "body": b"Hello, world!"})

kwargs = dict(init_kwargs)
experiments = kwargs.pop("_experiments", {})
sentry_init(
trace_lifecycle="stream",
traces_sample_rate=1.0,
_experiments=experiments,
**kwargs,
)
sentry_app = SentryAsgiMiddleware(app)
Expand Down
28 changes: 7 additions & 21 deletions tests/integrations/asyncio/test_asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ async def test_create_task(
integrations=[
AsyncioIntegration(),
],
_experiments={
"trace_lifecycle": "stream" if span_streaming else "static",
},
trace_lifecycle="stream" if span_streaming else "static",
)

if span_streaming:
Expand Down Expand Up @@ -171,9 +169,7 @@ async def test_gather(
integrations=[
AsyncioIntegration(),
],
_experiments={
"trace_lifecycle": "stream" if span_streaming else "static",
},
trace_lifecycle="stream" if span_streaming else "static",
)

if span_streaming:
Expand Down Expand Up @@ -463,9 +459,7 @@ async def test_span_origin(
sentry_init(
integrations=[AsyncioIntegration()],
traces_sample_rate=1.0,
_experiments={
"trace_lifecycle": "stream" if span_streaming else "static",
},
trace_lifecycle="stream" if span_streaming else "static",
)

if span_streaming:
Expand Down Expand Up @@ -520,9 +514,7 @@ async def test_task_spans_false(
integrations=[
AsyncioIntegration(task_spans=False),
],
_experiments={
"trace_lifecycle": "stream" if span_streaming else "static",
},
trace_lifecycle="stream" if span_streaming else "static",
)

if span_streaming:
Expand Down Expand Up @@ -594,9 +586,7 @@ async def test_delayed_enable_integration(
):
sentry_init(
traces_sample_rate=1.0,
_experiments={
"trace_lifecycle": "stream" if span_streaming else "static",
},
trace_lifecycle="stream" if span_streaming else "static",
)

assert "asyncio" not in sentry_sdk.get_client().integrations
Expand Down Expand Up @@ -711,9 +701,7 @@ async def test_delayed_enable_integration_after_disabling(
sentry_init(
disabled_integrations=[AsyncioIntegration()],
traces_sample_rate=1.0,
_experiments={
"trace_lifecycle": "stream" if span_streaming else "static",
},
trace_lifecycle="stream" if span_streaming else "static",
)

assert "asyncio" not in sentry_sdk.get_client().integrations
Expand Down Expand Up @@ -782,9 +770,7 @@ async def test_internal_tasks_not_wrapped(
sentry_init(
integrations=[AsyncioIntegration()],
traces_sample_rate=1.0,
_experiments={
"trace_lifecycle": "stream" if span_streaming else "static",
},
trace_lifecycle="stream" if span_streaming else "static",
)

async def user_task():
Expand Down
Loading
Loading