Skip to content

Commit fb9135d

Browse files
authored
fix: Add breadcrumb description (getsentry#489)
* fix: Add breadcrumb description * fix: Fix more breadcrumb descriptions * fix: Formatting
1 parent fff3f5a commit fb9135d

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

sentry_sdk/integrations/redis.py

+3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ def sentry_patched_execute_command(self, name, *args, **kwargs):
3333
description = " ".join(description_parts)
3434

3535
with hub.start_span(op="redis", description=description) as span:
36+
if name:
37+
span.set_tag("redis.command", name)
38+
3639
if name and args and name.lower() in ("get", "set", "setex", "setnx"):
3740
span.set_tag("redis.key", args[0])
3841

sentry_sdk/tracing.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,9 @@ def record_http_request(hub, url, method):
394394
def _maybe_create_breadcrumbs_from_span(hub, span):
395395
# type: (sentry_sdk.Hub, Span) -> None
396396
if span.op == "redis":
397-
hub.add_breadcrumb(type="redis", category="redis", data=span._tags)
397+
hub.add_breadcrumb(
398+
message=span.description, type="redis", category="redis", data=span._tags
399+
)
398400
elif span.op == "http" and span.is_success():
399401
hub.add_breadcrumb(
400402
type="http",
@@ -406,6 +408,7 @@ def _maybe_create_breadcrumbs_from_span(hub, span):
406408
hub.add_breadcrumb(
407409
type="subprocess",
408410
category="subprocess",
411+
message=span.description,
409412
data=span._data,
410413
hint={"popen_instance": span._data.get("popen_instance")},
411414
)

tests/integrations/redis/test_redis.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ def test_basic(sentry_init, capture_events):
1818

1919
assert crumb == {
2020
"category": "redis",
21-
"data": {"redis.key": "foobar"},
21+
"message": "GET 'foobar'",
22+
"data": {"redis.key": "foobar", "redis.command": "GET"},
2223
"timestamp": crumb["timestamp"],
2324
"type": "redis",
2425
}

tests/integrations/stdlib/test_subprocess.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,12 @@ def __len__(self):
3838
True,
3939
marks=pytest.mark.skipif(
4040
platform.python_implementation() == "PyPy",
41-
reason="https://github.com/getsentry/sentry-python/pull/449",
41+
reason="https://bitbucket.org/pypy/pypy/issues/3050/subprocesspopen-only-accepts-sequences",
4242
),
4343
),
4444
False,
4545
],
46+
ids=("as_iterator", "as_list"),
4647
)
4748
@pytest.mark.parametrize("env_mapping", [None, os.environ, ImmutableDict(os.environ)])
4849
@pytest.mark.parametrize("with_cwd", [True, False])
@@ -126,10 +127,14 @@ def test_subprocess_basic(
126127
assert crumb == {
127128
"category": "subprocess",
128129
"data": data,
130+
"message": crumb["message"],
129131
"timestamp": crumb["timestamp"],
130132
"type": "subprocess",
131133
}
132134

135+
if not iterator:
136+
assert crumb["message"].startswith(sys.executable + " ")
137+
133138
assert transaction_event["type"] == "transaction"
134139

135140
subprocess_span, = transaction_event["spans"]

0 commit comments

Comments
 (0)