Skip to content
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

🐛 Optimizing Sentry Integration: Making Initialization Optional and Enhancing Exception Reporting #2450

Closed
kneerose opened this issue Dec 2, 2024 · 0 comments · Fixed by #2470
Assignees
Labels
🐛 Bug Something isn't working Other area

Comments

@kneerose
Copy link
Contributor

kneerose commented Dec 2, 2024

Context

I am working on making Sentry initialization optional to control its usage across different deployment environments. This will allow us to enable Sentry selectively based on the deployment environment. On the frontend, I have updated some options for this purpose. PR #2449. Your feedback is welcome and appreciated.

On the backend, Sentry is currently initialized every time an exception is triggered because it is integrated with the exception handler. A better approach would be to initialize the Sentry service once when the application starts and then use it only to send reports when exceptions occur, instead of reinitializing and sending reports on each exception.

Current Sentry Integration on Backend

exceptionHandler :: VVAConfig -> Maybe Request -> SomeException -> IO ()
exceptionHandler vvaConfig mRequest exception = do
  print mRequest
  print exception
  let isNotTimeoutThread x = case fromException x of
        Just TimeoutThread -> False
        _                  -> True
      isNotConnectionClosedByPeer x = case fromException x of
        Just ConnectionClosedByPeer -> False
        _                           -> True
  guard . isNotTimeoutThread $ exception
  guard . isNotConnectionClosedByPeer $ exception
  let env = sentryEnv vvaConfig
  sentryService <-
    initRaven
      (sentryDSN vvaConfig)
      id
      sendRecord
      silentFallback
  register
    sentryService
    "vva.be"
    Error
    (formatMessage mRequest exception)
    (recordUpdate env mRequest exception)
    ```
@kneerose kneerose added the 🐛 Bug Something isn't working label Dec 2, 2024
@bosko-m bosko-m moved this to To do in Govtool all Dec 2, 2024
placek added a commit that referenced this issue Dec 4, 2024
Updated the application to initialize the Sentry service at the
beginning of the app lifecycle rather than during each exception
occurrence. This change ensures that the Sentry service is set up once
when the application starts, saving resources and potentially increasing
the application's performance by avoiding repetitive initializations.
The Sentry service is passed to the exception handler during setup and
is used consistently throughout the application's uptime. This aligns
with the user story's requirement to optimize exception handling
efficiency by centralizing Sentry service initialization.
@placek placek linked a pull request Dec 4, 2024 that will close this issue
placek added a commit that referenced this issue Dec 5, 2024
…-integration-making-initialization-optional-and-enhancing-exception-reporting

[#2450] Initialize Sentry service at application start
@github-project-automation github-project-automation bot moved this from To do to Done in Govtool all Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Something isn't working Other area
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants