-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
100 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...code/core/metrics/BStatsMetricsSetup.java → ...de/core/telemetry/BStatsMetricsSetup.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
...core-core/src/main/java/com/eternalcode/core/telemetry/sentry/SentryExceptionHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.eternalcode.core.telemetry.sentry; | ||
|
||
import io.sentry.Sentry; | ||
|
||
public class SentryExceptionHandler implements Thread.UncaughtExceptionHandler { | ||
|
||
@Override | ||
public void uncaughtException(Thread thread, Throwable throwable) { | ||
Sentry.captureException(throwable); | ||
} | ||
|
||
} |
53 changes: 53 additions & 0 deletions
53
eternalcore-core/src/main/java/com/eternalcode/core/telemetry/sentry/SentrySetup.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.eternalcode.core.telemetry.sentry; | ||
|
||
import com.eternalcode.core.configuration.implementation.PluginConfiguration; | ||
import com.eternalcode.core.injector.annotations.Inject; | ||
import com.eternalcode.core.injector.annotations.component.Controller; | ||
import com.eternalcode.core.publish.Subscribe; | ||
import com.eternalcode.core.publish.Subscriber; | ||
import com.eternalcode.core.publish.event.EternalInitializeEvent; | ||
import com.eternalcode.core.publish.event.EternalShutdownEvent; | ||
import io.papermc.lib.PaperLib; | ||
import io.sentry.Sentry; | ||
import org.bukkit.Server; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
import java.util.Arrays; | ||
|
||
@Controller | ||
class SentrySetup implements Subscriber { | ||
|
||
public static final String SENTRY_DSN = "https://4bf366d0d9f1da00162b9e629a80be52@o4505014505177088.ingest.sentry.io/4506093905051648"; | ||
private final PluginConfiguration pluginConfiguration; | ||
|
||
@Inject | ||
SentrySetup(PluginConfiguration pluginConfiguration) { | ||
this.pluginConfiguration = pluginConfiguration; | ||
} | ||
|
||
@Subscribe(EternalInitializeEvent.class) | ||
public void onInitialize(JavaPlugin javaPlugin) { | ||
if (this.pluginConfiguration.useSentry) { | ||
Sentry.init(options -> { | ||
options.setDsn(SENTRY_DSN); | ||
options.setTracesSampleRate(1.0); | ||
|
||
Server server = javaPlugin.getServer(); | ||
options.setTag("serverVersion", server.getVersion()); | ||
options.setTag("serverSoftware", PaperLib.getEnvironment().getName()); | ||
}); | ||
|
||
Thread.setDefaultUncaughtExceptionHandler(new SentryExceptionHandler()); | ||
|
||
javaPlugin.getLogger().info("Sentry initialized"); | ||
} | ||
} | ||
|
||
@Subscribe(EternalShutdownEvent.class) | ||
public void onShutdown() { | ||
if (this.pluginConfiguration.useSentry) { | ||
Sentry.close(); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters