Skip to content

feat: Sentry error tracking integration#76

Open
derrickmehaffy wants to merge 10 commits into
mainfrom
feat/sentry
Open

feat: Sentry error tracking integration#76
derrickmehaffy wants to merge 10 commits into
mainfrom
feat/sentry

Conversation

@derrickmehaffy

@derrickmehaffy derrickmehaffy commented Mar 1, 2026

Copy link
Copy Markdown
Member

Summary

  • Bundles Sentry SDK (v8.33.0) for automatic error reporting with async non-blocking delivery
  • New ErrorHandler utility replaces ~190 Logger.severe() calls across ~50 files — all errors now report to Sentry alongside console logging
  • Buffers pre-init errors (during config/data loading) and flushes them once Sentry is ready (pre_init:true tag)
  • Wraps scheduled tasks, async futures, and shutdown steps to prevent silent thread death and swallowed errors
  • Sentry config lives in config/debug.json under a "sentry" section (no separate file)
  • Auto-migration: existing config/sentry.json values are read into debug.json on first load, old file deleted
  • /f admin sentry command lets server owners view status and opt out/in at runtime
  • /f admin sentrytest sends a test event to verify the integration
  • Rich context on every event: server version, patchline, installed mods, OS, Java version, server config
  • Auto-detects environment from server patchline (release→production, pre-release→staging, dev→development)
  • Source context upload via Sentry Gradle plugin — stack traces show source code in Sentry dashboard

Test plan

  • ./gradlew :HyperFactions:compileJava compiles cleanly
  • /f admin sentrytest sends test event to Sentry dashboard
  • Malformed config/data JSON files produce errors visible in Sentry (via pre-init buffer)
  • Installed mods list appears in Sentry event context
  • Clean start: debug.json generates with "sentry" section, no sentry.json created
  • Migration: place old sentry.json in config dir, restart — values migrate into debug.json, old file deleted
  • /f admin sentry shows correct status
  • /f admin sentry disable closes Sentry and saves config
  • /f admin sentry enable re-initializes Sentry and saves config
  • Verify periodic tasks survive exceptions (scheduler threads don't die)
  • Verify shutdown completes all steps even if one fails

Non-blocking async error reporting to Sentry with fail-safe wrapping.
Includes configurable DSN, source context upload, and /f admin sentrytest command.
Config loads in enable() during start(), not setup(). Calling
ConfigManager.get().sentry() in setup() returned null.
Fix task dependency for all Sentry tasks on generateBuildInfo.
Auto-upload source bundle after every build via finalizedBy.
Tags: hytale.server.version, plugin.version, java.version, os
Context: structured server info with CPU count and max memory
Includes server_name, max_players, and MOTD from HytaleServerConfig.
Maps ManifestUtil.getPatchline() to Sentry environments:
release → production, pre-release → staging, dev → development.
Falls back to config value if detection fails.
Lists all loaded plugins with name, version, and state.
Refreshed on BootEvent for a complete picture after all plugins load.
Change HashMap type from <String, String> with unsafe double-cast to
<String, Object> which setContexts() accepts directly. Add total_count
field and debug logging for verification.
Add ErrorHandler utility class that centralizes error handling — all
errors are now logged to console AND reported to Sentry. Convert ~190
Logger.severe() calls in catch blocks across ~50 files to route through
ErrorHandler. Wrap scheduled tasks with wrapTask() to prevent silent
thread death, guard async futures, and isolate shutdown steps.

Add pre-init error buffering to SentryIntegration so errors during
config/data loading (before Sentry initializes) are captured and
flushed once Sentry is ready, tagged with pre_init:true.

Wire WriteResult.Failure storage errors (with nullable Exception cause)
through to Sentry via new report(@nullable) overload.
Move sentry configuration from standalone config/sentry.json into a
nested "sentry" section within config/debug.json. Auto-migration reads
existing sentry.json values on first load and deletes the old file.

Add /f admin sentry command for server owners to view status, opt out,
or opt back in to error reporting at runtime without editing config files.

Remove SentryConfig class, update ConfigManager, SentryIntegration, and
all callers to use DebugConfig for sentry settings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant