We are using a custom abstract way for handling reports.
ReportHubLogger replaces the default Unity implementation of ILogHandler. It allows us to process all logs in a fully controllable custom way and then decide what to do with them, rather than react on messages reported from the Unity's engine.
The current capabilities are:
- Providing additional data with each report
- It is represented by
ReportDataclass Category: a special marker to quickly recognize a domain the log is reported from. All categories should be defined inReportCategoryclassSceneShortInfo: a coordinate and a name of a scene the log originated from- We may include as many additional parameters as needed in the future
- It is represented by
- Having as many
IReportHandlers as needed which allow to:- Decide on an individual basis how to process/filter/debounce messages
- Control what to do with additional data. E.g.:
DebugLogReportHandler- adds a colored prefix of the[Category].
- Control the storage/target of logs. Currently, we have 2 targets:
DebugLogReportHandler- default Unity mechanism- Sentry
- A separate
CategorySeverityMatrixto enable/disable logs per handler. It is provided by theReportsHandlingSettingsscriptable object.
Instead of using Debug.LogXXX call ReportHub: it provides a similar API with extra capabilities. Everything that is reported via a default Debug.Log will have default additional data (e.g. [UNSPECIFIED] category)
Every event reaches Sentry through SentryReportHandler.BeforeSend, whether it was captured via ReportHub or directly by the SDK's own integrations (native messages, unhandled exceptions). The gate drops what the client cannot act on and keeps it as a warning breadcrumb of the next real report: un-actionable native messages, scene-script errors, disk-full IO, dropped websockets, and networking failures in local scene development.
Networking failures (UnityWebRequestException, WebException, SocketException, HttpRequestException, alone or wrapped) are also dropped while the machine is offline, since the SDK's offline cache would otherwise deliver every "Cannot resolve destination host" of an outage once the connection is back. Connectivity comes from InternetConnectivityMonitor (Utility.Networking): a TCP connect to the base domain started by RefreshIfStaleAsync once the previous result is a few seconds old, shared by concurrent callers, while IsOnline is the plain cached read. It exists because no OS-level signal works on desktop (Application.internetReachability always reports LAN, and the Mono BCL stubs NetworkInterface.GetIsNetworkAvailable to true). Because BeforeSend is synchronous, networking exceptions reported through ReportHub are held until the probe answers and only then captured or demoted; events captured directly by the SDK use the last confirmed state.
BaseUnityLoopSystem provides default capabilities to differentiate between categories:
- Category must be specified by an attribute
LogCategoryAttribute. It can be applied either to the system itself or the group.Categoryapplied to the system is prioritized. This capability is provided by the code generation so no reflection is used. - If no category is specified then a generic
ECSwill be used - When an exception occurs it will be enriched with the given category
- To log messages manually call
GetReportCategoryfrom the descendants: it is cached so it does not produce any overhead
It's strongly recommended to introduce a new report category when a new feature domain is developed. It will improve problems investigation in the future.
When an exception occurs in the ECS system it is caught and handled by ISystemGroupExceptionHandler if such is specified.
The current implementation (SceneExceptionsHandler) provides a tolerance for exceptions: no more than ECS_EXCEPTIONS_PER_MINUTE_TOLERANCE exception can be tolerated per minute. If this limit is exceeded then a new aggregate SceneExecutionException is thrown and the scene execution suspends. The exact behavior of what to do with the faulty scene is instructed by ISystemGroupExceptionHandler.Action and driven in the Unity.SystemGroups plugin:
Suspendwill stop execution but will not callDisposeof the systemsDisposewill do both
TODO
If you need errors/crash reporting on development branches, Sentry is disabled by default. In order to enable it, you need to run manually the unity-build workflow with sentry enabled selecting your target branch. You will be able to see reports on: https://decentraland.sentry.io/issues/?environment=development&project=4510719707250688&query=&referrer=issue-list&statsPeriod=24h