-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
fix(detectors): Improve filtering for connection spans in N+1 DB detector #101217
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,7 +124,11 @@ def on_complete(self) -> None: | |
self._maybe_store_problem() | ||
|
||
def _is_db_op(self, op: str) -> bool: | ||
return op.startswith("db") and not op.startswith("db.redis") | ||
return ( | ||
op.startswith("db") | ||
and not op.startswith("db.redis") | ||
and not op.startswith("db.connection") | ||
) | ||
|
||
def _maybe_use_as_source(self, span: Span) -> None: | ||
parent_span_id = span.get("parent_span_id", None) | ||
|
@@ -279,6 +283,11 @@ def get_valid_db_span_description(span: Span) -> str | None: | |
""" | ||
default_description = span.get("description", "") | ||
db_system = span.get("sentry_tags", {}).get("system", "") | ||
|
||
# Connection spans can have `op` as `db` but we don't want to trigger on them. | ||
if "pg-pool.connect" in default_description: | ||
return None | ||
Comment on lines
+288
to
+289
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Potential bug: The code does not handle cases where a span's description is explicitly
|
||
|
||
# Trigger pathway on `mongodb`, `mongoose`, etc... | ||
if "mongo" in db_system: | ||
description = span.get("sentry_tags", {}).get("description") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: N+1 Detector Span Processing Inconsistency
The N+1 detector inconsistently handles
pg-pool.connect
spans. They pass the initial_is_db_op()
check, allowing partial processing, but are later filtered out byget_valid_db_span_description()
. This can lead to false N+1 detections or problems failing to be stored.