sentry-unity icon indicating copy to clipboard operation
sentry-unity copied to clipboard

Improve event debouncing and throtteling

Open bitsandfoxes opened this issue 9 months ago • 0 comments
trafficstars

Goal

The goal is to provide more granular control over event debouncing. Particularly, for high-frequency events like those from Update() functions. This allows users to preserve quota while keeping error reporting intact.

Current Problem

  1. Events from Update() functions that run every frame can quickly consume error reporting quotas
  2. Current debouncing is not flexible enough for different types of events. i.e. There's not debouncing for exceptions
  3. Existing workarounds in BeforeSend (stack trace checking + random sampling) are hacky and might miss important errors

Current Implementation

We're using the following debouncer https://github.com/getsentry/sentry-unity/blob/main/src/Sentry.Unity/TimeDebounceBase.cs

in the Application Logging Integration https://github.com/getsentry/sentry-unity/blob/596ad1ddcd260f44fff90c82cd737e2b32bdabc0/src/Sentry.Unity/Integrations/UnityApplicationLoggingIntegration.cs#L57-L71

Proposal

Implement configurable debouncing that allows:

  • Event based debouncing options: error, exception
  • Different debouncing intervals for different event types?
  • Deduplication detection
    • Can the stacktrace be used?
    • Can we leverage exception.HResult? Maybe in combination with the stacktrace?

Additional Consideration

The .NET SDK has its own debouncer now (for memory dumps). Can this be reused?

The Godot SDK has event throtteling implemented as part of its logging intgration.

bitsandfoxes avatar Feb 03 '25 14:02 bitsandfoxes