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
18 changes: 2 additions & 16 deletions tests/integrations/redis/asyncio/test_redis_asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,33 +34,19 @@ async def test_async_basic(sentry_init, capture_events):
}


@pytest.mark.parametrize(
"is_transaction, send_default_pii, expected_first_ten",
[
(False, False, ["GET 'foo'", "SET 'bar' [Filtered]", "SET 'baz' [Filtered]"]),
(True, True, ["GET 'foo'", "SET 'bar' 1", "SET 'baz' 2"]),
],
)
@pytest.mark.asyncio
async def test_async_redis_pipeline(
sentry_init,
capture_items,
is_transaction,
send_default_pii,
expected_first_ten,
):
async def test_async_redis_pipeline(sentry_init, capture_items):
sentry_init(
integrations=[RedisIntegration()],
traces_sample_rate=1.0,
send_default_pii=send_default_pii,
)

connection = FakeRedis()

items = capture_items("span")

with sentry_sdk.start_span(name="custom parent"):
pipeline = connection.pipeline(transaction=is_transaction)
pipeline = connection.pipeline()
pipeline.get("foo")
pipeline.set("bar", 1)
pipeline.set("baz", 2)
Expand Down
15 changes: 1 addition & 14 deletions tests/integrations/redis/cluster/test_redis_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,23 +104,10 @@ def test_rediscluster_basic(
assert attrs["db.redis.key"] == "bar"


@pytest.mark.parametrize(
"send_default_pii, expected_first_ten",
[
(False, ["GET 'foo'", "SET 'bar' [Filtered]", "SET 'baz' [Filtered]"]),
(True, ["GET 'foo'", "SET 'bar' 1", "SET 'baz' 2"]),
],
)
def test_rediscluster_pipeline(
sentry_init,
capture_items,
send_default_pii,
expected_first_ten,
):
def test_rediscluster_pipeline(sentry_init, capture_items):
sentry_init(
integrations=[RedisIntegration()],
traces_sample_rate=1.0,
send_default_pii=send_default_pii,
)

rc = redis.RedisCluster(host="localhost", port=6379)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,23 @@ async def test_async_breadcrumb(sentry_init, capture_events):


@pytest.mark.parametrize(
"send_default_pii, description",
"data_collection, description",
[
(False, "SET 'bar' [Filtered]"),
(True, "SET 'bar' 1"),
({"database_query_data": False}, "SET 'bar' [Filtered]"),
({"database_query_data": True}, "SET 'bar' 1"),
],
)
@pytest.mark.asyncio
async def test_async_basic(
sentry_init,
capture_items,
send_default_pii,
data_collection,
description,
):
sentry_init(
integrations=[RedisIntegration()],
traces_sample_rate=1.0,
send_default_pii=send_default_pii,
data_collection=data_collection,
)

connection = cluster.RedisCluster(host="localhost", port=6379)
Expand All @@ -105,24 +105,11 @@ async def test_async_basic(
assert attrs["db.redis.key"] == "bar"


@pytest.mark.parametrize(
"send_default_pii, expected_first_ten",
[
(False, ["GET 'foo'", "SET 'bar' [Filtered]", "SET 'baz' [Filtered]"]),
(True, ["GET 'foo'", "SET 'bar' 1", "SET 'baz' 2"]),
],
)
@pytest.mark.asyncio
async def test_async_redis_pipeline(
sentry_init,
capture_items,
send_default_pii,
expected_first_ten,
):
async def test_async_redis_pipeline(sentry_init, capture_items):
sentry_init(
integrations=[RedisIntegration()],
traces_sample_rate=1.0,
send_default_pii=send_default_pii,
)

connection = cluster.RedisCluster(host="localhost", port=6379)
Expand Down
46 changes: 0 additions & 46 deletions tests/integrations/redis/test_redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,52 +42,6 @@ def test_basic(sentry_init, capture_events):
}


@pytest.mark.parametrize(
"data_collection, expected_first_ten",
[
(
{"database_query_data": False},
["GET 'foo'", "SET 'bar'", "SET 'baz'"],
),
(
{"database_query_data": True},
["GET 'foo'", "SET 'bar' 1", "SET 'baz' 2"],
),
],
)
def test_redis_pipeline_data_collection(
sentry_init,
capture_items,
data_collection,
expected_first_ten,
):
sentry_init(
integrations=[RedisIntegration()],
traces_sample_rate=1.0,
data_collection=data_collection,
)

connection = FakeRedis()

items = capture_items("span")

with sentry_sdk.start_span(name="custom parent"):
pipeline = connection.pipeline(transaction=False)
pipeline.get("foo")
pipeline.set("bar", 1)
pipeline.set("baz", 2)
pipeline.execute()

sentry_sdk.flush()

assert len(items) == 2
pipeline_span, parent_span = items[0].payload, items[1].payload

assert parent_span["name"] == "custom parent"
assert pipeline_span["name"] == "redis.pipeline.execute"
assert pipeline_span["attributes"]["sentry.op"] == "db.redis"


def test_pii_data_redacted(
sentry_init,
capture_items,
Expand Down
Loading