Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add breadcrumb description #489

Merged
merged 3 commits into from Aug 30, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions sentry_sdk/integrations/redis.py
Expand Up @@ -33,6 +33,9 @@ def sentry_patched_execute_command(self, name, *args, **kwargs):
description = " ".join(description_parts)

with hub.start_span(op="redis", description=description) as span:
if name:
span.set_tag("redis.command", name)

if name and args and name.lower() in ("get", "set", "setex", "setnx"):
span.set_tag("redis.key", args[0])

Expand Down
5 changes: 4 additions & 1 deletion sentry_sdk/tracing.py
Expand Up @@ -394,7 +394,9 @@ def record_http_request(hub, url, method):
def _maybe_create_breadcrumbs_from_span(hub, span):
# type: (sentry_sdk.Hub, Span) -> None
if span.op == "redis":
hub.add_breadcrumb(type="redis", category="redis", data=span._tags)
hub.add_breadcrumb(
message=span.description, type="redis", category="redis", data=span._tags
)
elif span.op == "http" and span.is_success():
hub.add_breadcrumb(
type="http",
Expand All @@ -406,6 +408,7 @@ def _maybe_create_breadcrumbs_from_span(hub, span):
hub.add_breadcrumb(
type="subprocess",
category="subprocess",
message=span.description,
data=span._data,
hint={"popen_instance": span._data.get("popen_instance")},
)
3 changes: 2 additions & 1 deletion tests/integrations/redis/test_redis.py
Expand Up @@ -18,7 +18,8 @@ def test_basic(sentry_init, capture_events):

assert crumb == {
"category": "redis",
"data": {"redis.key": "foobar"},
"message": "GET 'foobar'",
"data": {"redis.key": "foobar", "redis.command": "GET"},
"timestamp": crumb["timestamp"],
"type": "redis",
}
7 changes: 6 additions & 1 deletion tests/integrations/stdlib/test_subprocess.py
Expand Up @@ -38,11 +38,12 @@ def __len__(self):
True,
marks=pytest.mark.skipif(
platform.python_implementation() == "PyPy",
reason="https://github.com/getsentry/sentry-python/pull/449",
reason="https://bitbucket.org/pypy/pypy/issues/3050/subprocesspopen-only-accepts-sequences",
),
),
False,
],
ids=("as_iterator", "as_list"),
)
@pytest.mark.parametrize("env_mapping", [None, os.environ, ImmutableDict(os.environ)])
@pytest.mark.parametrize("with_cwd", [True, False])
Expand Down Expand Up @@ -126,10 +127,14 @@ def test_subprocess_basic(
assert crumb == {
"category": "subprocess",
"data": data,
"message": crumb["message"],
"timestamp": crumb["timestamp"],
"type": "subprocess",
}

if not iterator:
assert crumb["message"].startswith(sys.executable + " ")

assert transaction_event["type"] == "transaction"

subprocess_span, = transaction_event["spans"]
Expand Down