Skip to content

Add extra data in examples and/or handle ** args #2299

@nhorton

Description

@nhorton

We often get issues in code where somebody had an error condition where they had code like:

Sentry.capture_message("We hit an issue", my_method_arg: my_method_arg)

That is how structured logging is styled, and looks like it makes sense.

Sentry wants that instead to be:

Sentry.capture_message("We hit an issue", extra: {my_method_arg: my_method_arg})

The big problem with this though too is that if the only thing in the error handling was a Sentry capture, then devs often (udnerstandably) don't write a test for that case, and we only see the issue in prod when we get a syntax error on the above.

Couple things that would be nice:

  1. Add examples of extra data in the Ruby docs more. All the examples are the block style stuff with context, and not the more common style above
  2. Take ** args and pass everything you don't recognize as extras
  3. If you really can't do 2 for some reason, at least don't raise exceptions when RAILS_ENV == production for it.

Metadata

Metadata

Assignees

Labels

No labels
No labels
No fields configured for issues without a type.

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions