sentryR
is an unofficial R client for Sentry.
Currently tested with Plumber APIs.
You can install the current development version of sentryR
with:
# install.packages("devtools")
devtools::install_github("ozean12/sentryR")
Configure your project in Sentry, and set its DSN as an environment variable.
Example Plumber API:
library(plumber)
library(sentryR)
sentry.config(Sys.getenv('SENTRY_DSN'))
defaultErrorHandler <- plumber:::defaultErrorHandler()
errorHandler <- function(req, res, err) {
sentry.captureException(err, req)
defaultErrorHandler(req, res, err)
}
r <- plumb("R/api.R")
r$setErrorHandler(errorHandler)
r$run(host = "0.0.0.0", port = 8000)
also wrap your functions with withCapturedCalls
and you're good to go!
#* @get /error
api.error <- withCapturedCalls(function(res, req){
stop("error")
})
PRs and issues are welcome! ๐