Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configurable limit for the maximum age and number of events in the event store and remove old events before sending (close #860) #861

Merged
merged 4 commits into from
Jan 27, 2024

Conversation

matus-tomlein
Copy link
Contributor

Issue #860

The event store is currently unbounded meaning that if events fail to be sent to the collector, they are never removed from the event store. This can lead to it growing endlessly (if for instance an ad blocker blocks the collector domain) which is likely to have an impact on the app.

We should add configurable limits to the event store so that old events are removed. We could have two such limits:

  • maximum event store size – in case the number of events surpasses this threshold, oldest events will be removed until we are under the threshold. Default could be 1000.
  • maximum event age – in case there are events older than this threshold, we should remove them. Default could be 30 days.

The implementation in this PR adds these limits and enforces them before each emit attempt. They are enforced by running a single SQL statement which should be relatively efficient.

Copy link
Contributor

@mscwilson mscwilson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Tests/Storage/TestDatabase.swift Outdated Show resolved Hide resolved
@matus-tomlein matus-tomlein merged commit 39b8250 into release/6.0.0 Jan 27, 2024
10 checks passed
@matus-tomlein matus-tomlein deleted the issue/event_store_size branch January 27, 2024 09:30
matus-tomlein added a commit that referenced this pull request Feb 1, 2024
…e event store and remove old events before sending (close #860)

PR #861
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.

2 participants