Description
Description
Currently, Sentry logs are not capturing parameters and stack traces effectively, making it difficult to debug issues. The implementation should be improved to properly pass parameters and stack traces to Sentry, following best practices outlined in the Sentry Go documentation.
Acceptance Criteria
-
GIVEN an error is logged
WHEN the error is sent to Sentry
THEN it should include all relevant parameters and a stack trace -
GIVEN an error is logged
WHEN the error is sent to Sentry
THEN the error message should be structured and easy to parse in Sentry -
GIVEN an error is logged
WHEN the error is sent to Sentry
THEN the stack trace should be captured and included in the Sentry event -
GIVEN the application is running in production or staging
WHEN an error occurs
THEN the error should be logged to Sentry with the correct context and metadata
Tech Details
-
Sentry Configuration:
- Update the Sentry initialization to include additional configuration options for better error handling.
- Ensure stack traces are captured by enabling the
AttachStacktrace
option.
-
Logging Improvements:
- Use Sentry's
CaptureException
orCaptureMessage
methods to log errors with structured data. - Pass additional context (e.g., order ID, provider ID) as tags or extra data in Sentry events.
- Use Sentry's
-
Stack Trace Handling:
- Ensure stack traces are included in Sentry events by using
WithScope
orConfigureScope
.
- Ensure stack traces are included in Sentry events by using
-
Error Wrapping:
- Wrap errors with additional context to provide more detailed error messages.
Notes/Assumptions
- The Sentry DSN and environment are already configured in the server configuration.
- The application is already using
logrus
for logging, which is integrated with Sentry via thesentryhook
.