-
Couldn't load subscription status.
- Fork 569
Fix clickhouse logic for generator case #4722
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
Conversation
| **kwargs: Any, | ||
| ) -> Any: | ||
| span = getattr(self.connection, "_sentry_span", None) | ||
| if span is None: |
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.
moved this to an early return
| rv = original_send_data( | ||
| self, sample_block, data, types_check, columnar, *args, **kwargs | ||
| ) | ||
|
|
||
| if should_send_default_pii() and db_params: | ||
| # need to do this after the original function call to make sure | ||
| # db_params is populated correctly | ||
| saved_db_data["db.params"] = db_params | ||
| span.set_attribute("db.params", _serialize_span_attribute(db_params)) | ||
|
|
||
| return rv |
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.
Potential bug: If original_send_data fails, the exception prevents span attributes from being set, losing debugging context for the failed database operation.
-
Description: If the
original_send_datacall raises an exception, execution is halted before span attributes likedb.paramscan be set. This is problematic because the integration's purpose is to provide observability, which is most critical during failures. The current implementation leads to a loss of valuable debugging context when a database operation fails. For operations involving generators, any partially collected parameters are also lost, further hindering debugging efforts. The span itself may also not be finished correctly, leading to incomplete traces. -
Suggested fix: Wrap the
original_send_datacall in atry...finallyblock. The logic to set span attributes likedb.paramsshould be moved into thefinallyblock. This ensures that the debugging information is attached to the span even iforiginal_send_dataraises an exception, after which the exception can propagate normally.
severity: 0.7, confidence: 0.95
Did we get this right? 👍 / 👎 to inform future reviews.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## potel-base #4722 +/- ##
==============================================
- Coverage 84.80% 84.78% -0.03%
==============================================
Files 158 158
Lines 15812 15816 +4
Branches 2518 2519 +1
==============================================
- Hits 13410 13409 -1
- Misses 1636 1642 +6
+ Partials 766 765 -1
|
we need to call the original function first for
db_paramsto be correctly populated in the generator case(see diff without whitespace)