diff options
| author | Dan Engelbrecht <[email protected]> | 2025-06-09 12:22:27 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2025-06-09 12:22:27 +0200 |
| commit | feb888db2d557066ebe9eb3bb1d7e3b052ae1221 (patch) | |
| tree | 38002b17f35699ba61ac3d08994c3f2fa5aec8b7 /src | |
| parent | use unique tmp name for auth token file (#426) (diff) | |
| download | zen-feb888db2d557066ebe9eb3bb1d7e3b052ae1221.tar.xz zen-feb888db2d557066ebe9eb3bb1d7e3b052ae1221.zip | |
`--sentry-dsn` option for zen command line and zenserver to control Sentry reporting endpoint (#427)
moved sentry database path to temporary directory for zen commandline
Diffstat (limited to 'src')
| -rw-r--r-- | src/zen/zen.cpp | 22 | ||||
| -rw-r--r-- | src/zencore/include/zencore/sentryintegration.h | 8 | ||||
| -rw-r--r-- | src/zencore/sentryintegration.cpp | 7 | ||||
| -rw-r--r-- | src/zenserver/config.cpp | 2 | ||||
| -rw-r--r-- | src/zenserver/config.h | 51 | ||||
| -rw-r--r-- | src/zenserver/main.cpp | 6 |
6 files changed, 59 insertions, 37 deletions
diff --git a/src/zen/zen.cpp b/src/zen/zen.cpp index 119215d40..f0644a4f5 100644 --- a/src/zen/zen.cpp +++ b/src/zen/zen.cpp @@ -872,12 +872,18 @@ main(int argc, char** argv) #endif // ZEN_WITH_TRACE #if ZEN_USE_SENTRY - bool NoSentry = false; - bool SentryAllowPII = false; - Options.add_options()("no-sentry", "Disable Sentry crash handler", cxxopts::value<bool>(NoSentry)->default_value("false")); - Options.add_options()("sentry-allow-personal-info", - "Allow personally identifiable information in sentry crash reports", - cxxopts::value<bool>(SentryAllowPII)->default_value("false")); + bool NoSentry = false; + bool SentryAllowPII = false; + std::string SentryDsn; + Options + .add_option("sentry", "", "no-sentry", "Disable Sentry crash handler", cxxopts::value<bool>(NoSentry)->default_value("false"), ""); + Options.add_option("sentry", + "", + "sentry-allow-personal-info", + "Allow personally identifiable information in sentry crash reports", + cxxopts::value<bool>(SentryAllowPII)->default_value("false"), + ""); + Options.add_option("sentry", "", "sentry-dsn", "Sentry DSN to send events to", cxxopts::value<std::string>(SentryDsn), ""); #endif Options.parse_positional({"command"}); @@ -926,7 +932,7 @@ main(int argc, char** argv) if (NoSentry == false) { - std::string SentryDatabasePath = (GetRunningExecutablePath().parent_path() / ".sentry-native").string(); + std::string SentryDatabasePath = (std::filesystem::temp_directory_path() / ".zen-sentry-native").string(); ExtendableStringBuilder<512> SB; for (int i = 0; i < argc; ++i) @@ -939,7 +945,7 @@ main(int argc, char** argv) SB.Append(argv[i]); } - Sentry.Initialize(SentryDatabasePath, {}, SentryAllowPII, SB.ToString()); + Sentry.Initialize(SentryDatabasePath, {}, SentryDsn, SentryAllowPII, SB.ToString()); SentryIntegration::ClearCaches(); } diff --git a/src/zencore/include/zencore/sentryintegration.h b/src/zencore/include/zencore/sentryintegration.h index 40e22af4e..d14c1c275 100644 --- a/src/zencore/include/zencore/sentryintegration.h +++ b/src/zencore/include/zencore/sentryintegration.h @@ -31,8 +31,12 @@ public: SentryIntegration(); ~SentryIntegration(); - void Initialize(std::string SentryDatabasePath, std::string SentryAttachmentsPath, bool AllowPII, const std::string& CommandLine); - void LogStartupInformation(); + void Initialize(std::string SentryDatabasePath, + std::string SentryAttachmentsPath, + std::string SentryDsn, + bool AllowPII, + const std::string& CommandLine); + void LogStartupInformation(); static void ClearCaches(); private: diff --git a/src/zencore/sentryintegration.cpp b/src/zencore/sentryintegration.cpp index d08fb7f1d..520d5162e 100644 --- a/src/zencore/sentryintegration.cpp +++ b/src/zencore/sentryintegration.cpp @@ -31,6 +31,10 @@ ZEN_THIRD_PARTY_INCLUDES_END namespace sentry { +namespace { + static const std::string DefaultDsn("https://[email protected]/5919284"); +} + struct SentryAssertImpl : zen::AssertImpl { virtual void ZEN_FORCENOINLINE ZEN_DEBUG_SECTION @@ -194,6 +198,7 @@ SentryIntegration::~SentryIntegration() void SentryIntegration::Initialize(std::string SentryDatabasePath, std::string SentryAttachmentsPath, + std::string SentryDsn, bool AllowPII, const std::string& CommandLine) { @@ -204,7 +209,7 @@ SentryIntegration::Initialize(std::string SentryDatabasePath, SentryDatabasePath = SentryDatabasePath.substr(4); } sentry_options_t* SentryOptions = sentry_options_new(); - sentry_options_set_dsn(SentryOptions, "https://[email protected]/5919284"); + sentry_options_set_dsn(SentryOptions, SentryDsn.empty() ? sentry::DefaultDsn.c_str() : SentryDsn.c_str()); sentry_options_set_database_path(SentryOptions, SentryDatabasePath.c_str()); sentry_options_set_logger(SentryOptions, SentryLogFunction, this); if (!SentryAttachmentsPath.empty()) diff --git a/src/zenserver/config.cpp b/src/zenserver/config.cpp index e097147fc..055376b5c 100644 --- a/src/zenserver/config.cpp +++ b/src/zenserver/config.cpp @@ -443,6 +443,7 @@ ParseConfigFile(const std::filesystem::path& Path, LuaOptions.AddOption("server.logid"sv, ServerOptions.LogId, "log-id"sv); LuaOptions.AddOption("server.sentry.disable"sv, ServerOptions.NoSentry, "no-sentry"sv); LuaOptions.AddOption("server.sentry.allowpersonalinfo"sv, ServerOptions.SentryAllowPII, "sentry-allow-personal-info"sv); + LuaOptions.AddOption("server.sentry.dsn"sv, ServerOptions.SentryDsn, "sentry-dsn"sv); LuaOptions.AddOption("server.systemrootdir"sv, ServerOptions.SystemRootDir, "system-dir"sv); LuaOptions.AddOption("server.datadir"sv, ServerOptions.DataDir, "data-dir"sv); LuaOptions.AddOption("server.contentdir"sv, ServerOptions.ContentDir, "content-dir"sv); @@ -762,6 +763,7 @@ ParseCliOptions(int argc, char* argv[], ZenServerOptions& ServerOptions) options.add_options()("sentry-allow-personal-info", "Allow personally identifiable information in sentry crash reports", cxxopts::value<bool>(ServerOptions.SentryAllowPII)->default_value("false")); + options.add_options()("sentry-dsn", "Sentry DSN to send events to", cxxopts::value<std::string>(ServerOptions.SentryDsn)); options.add_options()("detach", "Indicate whether zenserver should detach from parent process group", cxxopts::value<bool>(ServerOptions.Detach)->default_value("true")); diff --git a/src/zenserver/config.h b/src/zenserver/config.h index 1d7d22ce9..1a1793b8d 100644 --- a/src/zenserver/config.h +++ b/src/zenserver/config.h @@ -169,31 +169,32 @@ struct ZenServerOptions ZenBuildStoreConfig BuildStoreConfig; ZenStatsConfig StatsConfig; ZenWorkspacesConfig WorksSpacesConfig; - std::filesystem::path SystemRootDir; // System root directory (used for machine level config) - std::filesystem::path DataDir; // Root directory for state (used for testing) - std::filesystem::path ContentDir; // Root directory for serving frontend content (experimental) - std::filesystem::path AbsLogFile; // Absolute path to main log file - std::filesystem::path ConfigFile; // Path to Lua config file - std::filesystem::path PluginsConfigFile; // Path to plugins config file - std::filesystem::path BaseSnapshotDir; // Path to server state snapshot (will be copied into data dir on start) - std::string ChildId; // Id assigned by parent process (used for lifetime management) - std::string LogId; // Id for tagging log output - std::string EncryptionKey; // 256 bit AES encryption key - std::string EncryptionIV; // 128 bit AES initialization vector - int BasePort = 8558; // Service listen port (used for both UDP and TCP) - int OwnerPid = 0; // Parent process id (zero for standalone) - bool InstallService = false; // Flag used to initiate service install (temporary) - bool UninstallService = false; // Flag used to initiate service uninstall (temporary) - bool IsDebug = false; - bool IsCleanStart = false; // Indicates whether all state should be wiped on startup or not - bool IsPowerCycle = false; // When true, the process shuts down immediately after initialization - bool IsTest = false; - bool IsDedicated = false; // Indicates a dedicated/shared instance, with larger resource requirements - bool ShouldCrash = false; // Option for testing crash handling - bool IsFirstRun = false; - bool NoSentry = false; - bool SentryAllowPII = false; // Allow personally identifiable information in sentry crash reports - bool Detach = true; // Whether zenserver should detach from existing process group (Mac/Linux) + std::filesystem::path SystemRootDir; // System root directory (used for machine level config) + std::filesystem::path DataDir; // Root directory for state (used for testing) + std::filesystem::path ContentDir; // Root directory for serving frontend content (experimental) + std::filesystem::path AbsLogFile; // Absolute path to main log file + std::filesystem::path ConfigFile; // Path to Lua config file + std::filesystem::path PluginsConfigFile; // Path to plugins config file + std::filesystem::path BaseSnapshotDir; // Path to server state snapshot (will be copied into data dir on start) + std::string ChildId; // Id assigned by parent process (used for lifetime management) + std::string LogId; // Id for tagging log output + std::string EncryptionKey; // 256 bit AES encryption key + std::string EncryptionIV; // 128 bit AES initialization vector + int BasePort = 8558; // Service listen port (used for both UDP and TCP) + int OwnerPid = 0; // Parent process id (zero for standalone) + bool InstallService = false; // Flag used to initiate service install (temporary) + bool UninstallService = false; // Flag used to initiate service uninstall (temporary) + bool IsDebug = false; + bool IsCleanStart = false; // Indicates whether all state should be wiped on startup or not + bool IsPowerCycle = false; // When true, the process shuts down immediately after initialization + bool IsTest = false; + bool IsDedicated = false; // Indicates a dedicated/shared instance, with larger resource requirements + bool ShouldCrash = false; // Option for testing crash handling + bool IsFirstRun = false; + bool NoSentry = false; + bool SentryAllowPII = false; // Allow personally identifiable information in sentry crash reports + std::string SentryDsn; + bool Detach = true; // Whether zenserver should detach from existing process group (Mac/Linux) bool ObjectStoreEnabled = false; bool NoConsoleOutput = false; // Control default use of stdout for diagnostics std::string Loggers[zen::logging::level::LogLevelCount]; diff --git a/src/zenserver/main.cpp b/src/zenserver/main.cpp index 0f647cd5c..868126533 100644 --- a/src/zenserver/main.cpp +++ b/src/zenserver/main.cpp @@ -101,7 +101,11 @@ ZenEntryPoint::Run() std::string SentryDatabasePath = (m_ServerOptions.DataDir / ".sentry-native").string(); std::string SentryAttachmentPath = m_ServerOptions.AbsLogFile.string(); - Sentry.Initialize(SentryDatabasePath, SentryAttachmentPath, m_ServerOptions.SentryAllowPII, m_ServerOptions.CommandLine); + Sentry.Initialize(SentryDatabasePath, + SentryAttachmentPath, + m_ServerOptions.SentryDsn, + m_ServerOptions.SentryAllowPII, + m_ServerOptions.CommandLine); } #endif try |