-
Notifications
You must be signed in to change notification settings - Fork 116
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
Multiple errors support #1210
Multiple errors support #1210
Conversation
You wrote quite a lengthy set of instructions, but you can also run |
✅ on all the above -- will amend the PR tomorrow with #1212 and |
Implement a new `add_error` method that allows for multiple errors to be added to a transaction. These additional errors are stored on the Ruby transaction object. When the transaction is completed, duplicate the current transaction to report each of the errors in its own duplicate transaction. https://appsignal.slack.com/archives/CNPP953E2/p1720083599598159 [skip ci]
Implement support for the `appsignal_transaction_duplicate` method implemented in the agent side the extension, in both the Ruby C extension and the JRuby FFI extension. Implement a `duplicate` method for the `Transaction` class that calls the extension's own `duplicate` method to duplicate a transaction.
This fixes a bug where, when overwriting an already set error by setting an error that has no error causes, the error causes from the first error would be kept.
When a transaction does not have an error, but it does have one or more additional errors, instead of reporting the error-less transaction alongside its duplicates, set the last additional error as the error for this transaction.
Report at most ten additional errors per transaction. If more errors are provided, report only the last ten additional errors. Pass the extension as an option when initialising the transaction object.
Within the `report_error` helper, use `add_error` instead of the `set_error` method, so that multiple errors can be reported from the same transaction.
Test the actual transactions being created, not if we call certain methods or not.
Test the behavior of the private duplicate method in the complete method tests that call this private method.
Instead of having `add_error` always add the errors to the additional errors array, and then "promoting" the last of those errors to an error in the current transaction later, when the transaction is completed, do it when an error is first added using `add_error`. To avoid calls to `set_error` overriding this error instead of adding a new one, make `set_error` into an alias to `add_error`. Move the logic to set an error in the transaction into a private `_set_error` method.
Before this change, the last ten additional errors would be kept, alongside with the first (non-additional) error. This was a strange mix of behaviours that would have been hard to document. Instead, we can now document that we keep the first ten errors. The language emitted in the warning has been modified to avoid any mention of "additional" errors.
The agent update and changesets are updated automatically. [skip review]
Keep all errors in an array, including the first error. Do not add an error to the errors array if it is already present in the array.
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.
👏
lib/appsignal/transaction.rb
Outdated
@@ -541,8 +537,54 @@ def to_h | |||
end | |||
alias_method :to_hash, :to_h | |||
|
|||
protected | |||
|
|||
attr_writer :ext, :is_duplicate |
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.
attr_writer :ext, :is_duplicate | |
attr_writer :is_duplicate |
I don't see where this is used. Can we remove it?
This is a message from the daily scheduled checks. |
When calling `Appsignal.report_error` with a block, always create a new transaction when a block is given.
For future Tom and Noemi, and other readers, the last commit comes from this internal discussion (and some messages around that specific thread). |
See https://github.com/appsignal/appsignal-agent/pull/1186 for context.
Also see the test setup: appsignal/test-setups#222
A release of the agent containing the changes in the agent PR will be added to this PR before merging.
Support multiple errors per transaction
Implement a new
add_error
method that allows for multiple errorsto be added to a transaction. These additional errors are stored on
the Ruby transaction object. When the transaction is completed,
duplicate the current transaction to report each of the errors
in its own duplicate transaction.
https://appsignal.slack.com/archives/CNPP953E2/p1720083599598159
Add .duplicate transaction method
Implement support for the
appsignal_transaction_duplicate
methodimplemented in the agent side the extension, in both the Ruby C
extension and the JRuby FFI extension.
Implement a
duplicate
method for theTransaction
class thatcalls the extension's own
duplicate
method to duplicate atransaction.
Always set error causes when setting errors
This fixes a bug where, when overwriting an already set error by
setting an error that has no error causes, the error causes from the
first error would be kept.
Avoid reporting performance and error sample
When a transaction does not have an error, but it does have one or
more additional errors, instead of reporting the error-less
transaction alongside its duplicates, set the last additional error
as the error for this transaction.
Limit additional errors
Report at most ten additional errors per transaction. If more errors
are provided, report only the last ten additional errors.
Pass the extension as an option when initialising the transaction
object.
Use add_error in report_error helper
Within the
report_error
helper, useadd_error
instead of theset_error
method, so that multiple errors can be reported fromthe same transaction.