diff --git a/src/main/scala/thurloe/Main.scala b/src/main/scala/thurloe/Main.scala index 1f973da7..b8124c37 100644 --- a/src/main/scala/thurloe/Main.scala +++ b/src/main/scala/thurloe/Main.scala @@ -19,7 +19,8 @@ object Main extends App { sys.env.get("SENTRY_DSN").foreach { dsn => val options = new SentryOptions() options.setDsn(dsn) - Sentry.init() + options.setEnvironment(sys.env.getOrElse("SENTRY_ENVIRONMENT", "unknown")) + Sentry.init(options) } // We need an ActorSystem to host our application in diff --git a/src/main/scala/thurloe/service/ThurloeService.scala b/src/main/scala/thurloe/service/ThurloeService.scala index ac75ed00..f2e82ff4 100644 --- a/src/main/scala/thurloe/service/ThurloeService.scala +++ b/src/main/scala/thurloe/service/ThurloeService.scala @@ -5,6 +5,7 @@ import akka.http.scaladsl.model.{ContentTypes, HttpEntity, StatusCodes} import akka.http.scaladsl.server.Directives._ import akka.http.scaladsl.server.Route import com.typesafe.scalalogging.LazyLogging +import io.sentry.Sentry import spray.json._ import thurloe.database.DatabaseOperation.DatabaseOperation import thurloe.database.{DataAccess, DatabaseOperation, KeyNotFoundException} @@ -62,6 +63,7 @@ trait ThurloeService extends LazyLogging { private def handleError(e: Throwable) = extract(_.request) { request => + Sentry.captureException(e) logger.error(s"error handling request: ${request.method} ${request.uri}", e) complete(StatusCodes.InternalServerError, s"$Interjection $e") }