From 1a11303640431db0aa908dbc5d059520dc0e4adc Mon Sep 17 00:00:00 2001 From: inductor Date: Mon, 8 May 2023 02:13:19 +0900 Subject: [PATCH 1/4] Add Sentry --- build.sbt | 3 +++ .../com/github/unchama/seichiassist/SeichiAssist.scala | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/build.sbt b/build.sbt index 4b27dd2393..062ba654f7 100644 --- a/build.sbt +++ b/build.sbt @@ -116,6 +116,9 @@ val dependenciesToEmbed = Seq( // ajd4jp "com.github.KisaragiEffective" % "ajd4jp-mirror" % "8.0.2.2021", + + // Sentry + "io.sentry" % "sentry" % "6.18.1", ) // endregion diff --git a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala index 5d9dc4d1ba..2630ad5295 100644 --- a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala +++ b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala @@ -92,6 +92,7 @@ import com.github.unchama.seichiassist.task.PlayerDataSaveTask import com.github.unchama.seichiassist.task.global._ import com.github.unchama.util.{ActionStatus, ClassUtils} import io.chrisdavenport.log4cats.slf4j.Slf4jLogger +import io.sentry.Sentry import org.bukkit.Bukkit import org.bukkit.ChatColor._ import org.bukkit.entity.{Entity, Player, Projectile} @@ -136,6 +137,15 @@ class SeichiAssist extends JavaPlugin() { implicit val loggerF: io.chrisdavenport.log4cats.Logger[IO] = Slf4jLogger.getLoggerFromSlf4j(logger) + Sentry.init(options -> { + options.setDsn("https://7f241763b17c49db982ea29ad64b0264@sentry.onp.admin.seichi.click/2"); + // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring. + // We recommend adjusting this value in production. + options.setTracesSampleRate(1.0); + // When first trying Sentry it's good to see what the SDK is doing: + options.setDebug(true); + }); + // endregion private var repeatedTaskFiber: Option[Fiber[IO, List[Nothing]]] = None From 3a209fadb03fced6abcdab32c264563feea5b067 Mon Sep 17 00:00:00 2001 From: inductor Date: Mon, 8 May 2023 02:18:48 +0900 Subject: [PATCH 2/4] fix format --- .../scala/com/github/unchama/seichiassist/SeichiAssist.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala index 2630ad5295..20e3df702a 100644 --- a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala +++ b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala @@ -137,7 +137,7 @@ class SeichiAssist extends JavaPlugin() { implicit val loggerF: io.chrisdavenport.log4cats.Logger[IO] = Slf4jLogger.getLoggerFromSlf4j(logger) - Sentry.init(options -> { + Sentry.init(options => { options.setDsn("https://7f241763b17c49db982ea29ad64b0264@sentry.onp.admin.seichi.click/2"); // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring. // We recommend adjusting this value in production. From 56fac9060e691cc9668d0be62ade68f4ab45ee3d Mon Sep 17 00:00:00 2001 From: inductor Date: Mon, 8 May 2023 02:43:31 +0900 Subject: [PATCH 3/4] set server id on sentry --- .../unchama/seichiassist/SeichiAssist.scala | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala index 20e3df702a..3ae7e49b50 100644 --- a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala +++ b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala @@ -93,6 +93,7 @@ import com.github.unchama.seichiassist.task.global._ import com.github.unchama.util.{ActionStatus, ClassUtils} import io.chrisdavenport.log4cats.slf4j.Slf4jLogger import io.sentry.Sentry +import io.sentry.SentryLevel; import org.bukkit.Bukkit import org.bukkit.ChatColor._ import org.bukkit.entity.{Entity, Player, Projectile} @@ -137,15 +138,6 @@ class SeichiAssist extends JavaPlugin() { implicit val loggerF: io.chrisdavenport.log4cats.Logger[IO] = Slf4jLogger.getLoggerFromSlf4j(logger) - Sentry.init(options => { - options.setDsn("https://7f241763b17c49db982ea29ad64b0264@sentry.onp.admin.seichi.click/2"); - // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring. - // We recommend adjusting this value in production. - options.setTracesSampleRate(1.0); - // When first trying Sentry it's good to see what the SDK is doing: - options.setDebug(true); - }); - // endregion private var repeatedTaskFiber: Option[Fiber[IO, List[Nothing]]] = None @@ -604,6 +596,18 @@ class SeichiAssist extends JavaPlugin() { // コンフィグ系の設定は全てConfig.javaに移動 SeichiAssist.seichiAssistConfig = Config.loadFrom(this) + Sentry.init(options => { + options.setDsn("https://7f241763b17c49db982ea29ad64b0264@sentry.onp.admin.seichi.click/2"); + // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring. + // We recommend adjusting this value in production. + options.setTracesSampleRate(1.0); + // When first trying Sentry it's good to see what the SDK is doing: + options.setDebug(true); + options.setEnvironment(SeichiAssist.seichiAssistConfig.getServerId); + }); + + Sentry.configureScope(scope => scope.setLevel(SentryLevel.WARNING)); + if (SeichiAssist.seichiAssistConfig.getDebugMode == 1) { // debugmode=1の時は最初からデバッグモードで鯖を起動 logger.info(s"${RED}SeichiAssistをデバッグモードで起動します") From b1664f4c19bc7e75442fc2da4e87a6f9a7744135 Mon Sep 17 00:00:00 2001 From: inductor Date: Mon, 8 May 2023 02:50:51 +0900 Subject: [PATCH 4/4] decrease sample rate --- .../com/github/unchama/seichiassist/SeichiAssist.scala | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala index 3ae7e49b50..d2355eb989 100644 --- a/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala +++ b/src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala @@ -598,11 +598,13 @@ class SeichiAssist extends JavaPlugin() { Sentry.init(options => { options.setDsn("https://7f241763b17c49db982ea29ad64b0264@sentry.onp.admin.seichi.click/2"); - // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring. - // We recommend adjusting this value in production. - options.setTracesSampleRate(1.0); + // パフォーマンスモニタリングに使うトレースサンプルの送信割合 + // tracesSampleRateを1.0にすると全てのイベントが送られるため、送りすぎないように調整する必要がある + options.setTracesSampleRate(0.25); // When first trying Sentry it's good to see what the SDK is doing: options.setDebug(true); + + // どのサーバーからイベントが送られているのかを判別する識別子 options.setEnvironment(SeichiAssist.seichiAssistConfig.getServerId); });