51 Commits

Author SHA1 Message Date
Klaas van Schelven
a6ead89ca8 Remove event.debug_info
basically unused
2025-11-09 20:58:39 +01:00
Klaas van Schelven
1262719e4b Comments about (SDK-generated) event_id's uniqueness
'original sin' in 238fb6dda7
2025-09-09 21:13:54 +02:00
Klaas van Schelven
6b8d912e1a Store remote_addr on the event
Fix #165
2025-07-25 21:54:32 +02:00
Klaas van Schelven
403e28adb4 Remove 'choices' from Event.model
See https://github.com/getsentry/sentry-docs/pull/14331

See https://code.djangoproject.com/ticket/22837 for the migration-clobbering
2025-07-16 10:38:06 +02:00
Klaas van Schelven
cb3168133e Fix Event-deletion from the admin
b/c of the introduction of on_delete=DO_NOTHING, this was broken.
this is the quick & dirty fix (no tests)
2025-07-04 17:33:02 +02:00
Klaas van Schelven
28b2ce0eaf Various models: .project SET_NULL => DO_NOTHING
Like e45c61d6f0, but for .project.

I originally thought `SET_NULL` would be a good way to "do stuff later", but
that's only so the degree that [1] updates are cheaper than deletes and [2]
2nd-order effects (further deletes in the dep-tree) are avoided.

Now that we have explicit Project-deletion (deps-first, delayed, properly batched)
the SET_NULL behavior is always a no-op (but with cost in queries).

As a result, in the test for project deletion (which has deletes for many
of the altered models), the following 12 queries are no longer done:

```
SELECT "projects_project"."id", [..many fields..] FROM "projects_project" WHERE "projects_project"."id" = 1
DELETE FROM "projects_projectmembership" WHERE "projects_projectmembership"."project_id" IN (1)
DELETE FROM "alerts_messagingserviceconfig" WHERE "alerts_messagingserviceconfig"."project_id" IN (1)
UPDATE "releases_release" SET "project_id" = NULL WHERE "releases_release"."project_id" IN (1)
UPDATE "issues_issue" SET "project_id" = NULL WHERE "issues_issue"."project_id" IN (1)
UPDATE "issues_grouping" SET "project_id" = NULL WHERE "issues_grouping"."project_id" IN (1)
UPDATE "events_event" SET "project_id" = NULL WHERE "events_event"."project_id" IN (1)
UPDATE "tags_tagkey" SET "project_id" = NULL WHERE "tags_tagkey"."project_id" IN (1)
UPDATE "tags_tagvalue" SET "project_id" = NULL WHERE "tags_tagvalue"."project_id" IN (1)
UPDATE "tags_eventtag" SET "project_id" = NULL WHERE "tags_eventtag"."project_id" IN (1)
UPDATE "tags_issuetag" SET "project_id" = NULL WHERE "tags_issuetag"."project_id" IN (1)
```
2025-07-03 21:49:49 +02:00
Klaas van Schelven
e45c61d6f0 Various models: .issue and .grouping; SET_NULL => DO_NOTHING
I originally thought `SET_NULL` would be a good way to "do stuff later", but
that's only so the degree that [1] updates are cheaper than deletes and [2]
2nd-order effects (further deletes in the dep-tree) are avoided.

Now that we have explicit Issue-deletion (deps-first, delayed, properly batched)
the SET_NULL behavior is always a no-op (but with cost in queries).

As a result, in the test for issue deletion (which has deletes for many
of the altered models), the following 8 queries are no longer done:

```
SELECT "issues_grouping"."id", [..many fields..] FROM "issues_grouping" WHERE "issues_grouping"."id" IN (1)
UPDATE "events_event" SET "grouping_id" = NULL WHERE "events_event"."grouping_id" IN (1)

[.. a few moments later..]

SELECT "issues_issue"."id", [..many fields..] FROM "issues_issue" WHERE "issues_issue"."id" = 'uuid'
UPDATE "issues_grouping" SET "issue_id" = NULL WHERE "issues_grouping"."issue_id" IN ('uuid')
UPDATE "issues_turningpoint" SET "issue_id" = NULL WHERE "issues_turningpoint"."issue_id" IN ('uuid')
UPDATE "events_event" SET "issue_id" = NULL WHERE "events_event"."issue_id" IN ('uuid')
UPDATE "tags_eventtag" SET "issue_id" = NULL WHERE "tags_eventtag"."issue_id" IN ('uuid')
UPDATE "tags_issuetag" SET "issue_id" = NULL WHERE "tags_issuetag"."issue_id" IN ('uuid')
```

(breaks the tests b/c of constraints and not always using factories; will fix next)
2025-07-03 11:33:58 +02:00
Klaas van Schelven
f76d3f4f40 Merge branch 'main' into tag-search 2025-03-05 16:05:17 +01:00
Klaas van Schelven
f25d693804 Add postgres to GitHub CI
A first step towards (experimental) postgres support, see #21
2025-03-05 12:20:51 +01:00
Klaas van Schelven
b98c1d4f44 MySQL recover from IntegrityError
as we do for the sqlite case

the need for this was revealed by running the testsuite against mysql
2025-03-05 11:04:41 +01:00
Klaas van Schelven
4cde74d7cb Event search: first version 2025-03-04 13:51:56 +01:00
Klaas van Schelven
c8ecf508de Tags: on event details page show calculated tags
(not just the explicitly provided ones)
2025-03-03 11:29:07 +01:00
Klaas van Schelven
7a19e2d277 Tags; deducing tags; search on tags; WIP 2025-02-27 13:12:49 +01:00
Klaas van Schelven
5559fba754 Introduce FileEventStorage
An (optional) way to store the `event_data` (full event as JSON)
outside the DB. This is expected to be useful for larger setups,
because it gives you:

* A more portable database (e.g. backups); (depeding on event size
  the impact on your DB is ~50x.
* Less worries about hitting "physical" limits (e.g. disk size, max
  file size) for your DB.

Presumably (more testing will happen going forwards) it will:

* Speed up migrations (especially on sqlite, which does full table
  copies)
* Speed up event ingestion(?)

Further improvements in this commit:

* `delete_with_limit` was removed; this removes one tie-in to MySQL/Sqlite
    (See #21 for this bullet)
2025-02-12 17:11:24 +01:00
Klaas van Schelven
14d8e9e2fb Fix: remove missed line
Should have been removed in cc861c8ba3
2025-02-11 11:00:23 +01:00
Klaas van Schelven
cc861c8ba3 Remove 2 fields that were "temporary [..] to get a sense of the shape of the data 2025-02-09 21:12:25 +01:00
Klaas van Schelven
a717dd7374 Truncate input-data that exceeds max_length
Avoiding any (1406, "Data too long for column ...") on MySQL.

For the 'plainly provided' fields I followed the documented maximums which are
also our DB maximums. For calculated_* I harmonized with what Sentry &
GlitchTip both do (and which was already partially reflected in the code), i.e.
128 and 1024.
2025-02-08 21:21:55 +01:00
Klaas van Schelven
561c1d324a event.data getters
in preparation for scenarios where the dumped data is not stored in the DB
2025-02-07 17:09:36 +01:00
Klaas van Schelven
9ee623de6b Add Event.grouping field and fill it
An event always has a single (automatically calculated) Grouping associated with it.
We add this info to the Event model (we'll soon display it in the UI, and as per the
now-removed comment it's simply the consistent thing to do)
2025-01-31 16:16:07 +01:00
Klaas van Schelven
a54ec29433 Reraise rather than assert-for-nonexception
this expresses more clearly what the intention is, and the result is more clear too
(one less level of exception-chaining)
2025-01-17 17:04:20 +01:00
Klaas van Schelven
f2a78fed9d Use the envelope's event_id when using the envelope endpoint
* As per the spec 'takes precendence'
* Also fixes the reported bug on Laravel, which apparently doesn't send event_id
  as part of the event payload.
* Fixes the envelope tests (they were doing nothing when I moved the
  data samples around recently)
* Adds a 'no event_id in data, but yes in envelope' test to that test.
* Adds handling to send_json such that we can send envelopes when the event_id
  is missing from the event data.
2024-09-18 11:36:47 +02:00
Klaas van Schelven
ff618099dc event-model TODOs: reorganize and reflect that these are not TODOs for now 2024-09-13 09:51:30 +02:00
Klaas van Schelven
b76e474ef1 Navigation: fix for missing events
Now that we have eviction, events may disappear. Deal with it:

* event-specific 404 that still allows for navigation
* first/last buttons
* navigation to prev/next when prev/next is not just 1 step away
* don't use HttpRedirect for "lookup based" views
    in principle, the thing you were looking for might go missing in-between
    drawback: these URLs are not "stable"
2024-07-19 11:03:08 +02:00
Klaas van Schelven
3128392d9a Distinguish ingested_at and digested_at 2024-07-18 14:45:59 +02:00
Klaas van Schelven
c01d332e18 Rename ingest_order to digest_order and clarify event_count
* issue.event_count to digested_event_count
* event.ingest_order to event.digest_order
* issue.ingest_order to digest_order

This is generally more correct/explicit, and is also in preparation
of doing work on-digest (which may or may not happen)
2024-07-16 15:23:40 +02:00
Klaas van Schelven
93365f4c8d Period-counting using SQL instead of custom-made (PoC)
The direct cause for this was the following observation: there was no mechanism
in place to safeguard counted events across evictions, i.e. the following order
of events was not accounted for:

* ingest/digest a bunch of events (PCs correctly updated)
* eviction (PC still correct)
* server/snappea restart (PC reloaded, but based on new events. not correct).

I though about various approaches to fix this (e.g. snapshotting) but in the end
such approaches added even more complexity to the PC mechanism. I decided to first
check how non-performant the SQL route would be, and this PoC seems to say: just
go SQL.

There's also a small semantic change (probably in the direction of what you'd
expect), namely: the periods are no longer 'calendar' periods.
2024-07-15 14:28:13 +02:00
Klaas van Schelven
fe6c955465 never_evict events that are a Historic Turning Point
Both for technical (foreign keys) and business reasons (these are events you
care about)
2024-06-24 22:50:00 +02:00
Klaas van Schelven
adda019cef Add an index to the Event model for eviction
Unscientifically (n=1, changing circumstances), this improved times like so when the max was 10k:

* 573.56ms EVICT; down to 8813, max irr. from 15 to 13 in 171ms+402ms and 5+4 queries  (pre-index)
* 229.34ms EVICT; down to 7643, max irr. from 15 to 12 in 7ms+222ms and 5+7 queries    (post-index)

The order of the index was chosen because we have 3 types of queries in our algo:

* on Project -> irrelevance <= amount of work
* on Project, timestamp -> irrelevance <= observed irrelevances
* on Project, timestamp, irrelevance -> deletion
2024-06-24 14:29:01 +02:00
Klaas van Schelven
ea6aa9bbca Retention/quotas: something that 'seems to work' (doesn't immediately crash) 2024-06-21 11:50:13 +02:00
Klaas van Schelven
c2b821589d Retention, WIP (yesterday) 2024-06-21 09:28:04 +02:00
Klaas van Schelven
58435754e0 Digest immediately implemented 2024-04-26 14:48:07 +02:00
Klaas van Schelven
f098802fde Event already exists: return 400; implement with one less query 2024-04-11 11:03:41 +02:00
Klaas van Schelven
4dfefec468 denormalize/cache last_frame_* and transaction on Event and Issue
for performance, but also fixes:

* not just the 'last frame' but the 'last relevant frame' (in-app)
* truncation is properly done (matching the DB size, and for each of the fields)
2024-04-10 09:12:15 +02:00
Klaas van Schelven
ba6b158848 Fix on previous commit (wrong unique index) 2024-04-10 08:54:58 +02:00
Klaas van Schelven
d46cb7f6e8 DB: unique_together and PositiveIntegerField 2024-04-09 12:34:29 +02:00
Klaas van Schelven
82b8c014e7 Add title to event-details 2024-04-09 09:39:50 +02:00
Klaas van Schelven
1b37298a95 ingest_order: first setup 2024-04-08 22:13:52 +02:00
Klaas van Schelven
652823f8c3 Store calculated type and value on issue and event and use these values in the templates 2024-04-08 15:30:41 +02:00
Klaas van Schelven
d94bfa8aa6 Log Messages: my first take
they should somehow show up in the title; in the interface it should be clear that we're
dealing with log messages (rather than exceptions)
2024-04-04 15:40:31 +02:00
Klaas van Schelven
fea9d5a90d Push comments into help-text 2024-03-30 21:02:26 +01:00
Klaas van Schelven
9936c93b4e Events <-> RawEvents FK 2024-01-07 22:39:56 +01:00
Klaas van Schelven
186ddb62cf Event.from_ingested 2024-01-07 22:31:07 +01:00
Klaas van Schelven
6a27a248af Split up ingest/digest (and have a test for process_event) 2024-01-07 22:09:38 +01:00
Klaas van Schelven
94661b4bb8 Swap FK event<->issue 2024-01-05 22:38:59 +01:00
Klaas van Schelven
e3433e8ddb server-side timestamp fixes (untested) 2024-01-05 20:40:41 +01:00
Klaas van Schelven
89cab4f3c8 WIP: midway checkin in the PeriodCounter registry stuff 2024-01-05 20:20:14 +01:00
Klaas van Schelven
be845ec393 Links from/to the admin 2023-11-17 22:45:16 +01:00
Klaas van Schelven
c054b48a4b Download and raw links 2023-11-13 18:35:29 +01:00
Klaas van Schelven
725822ce3d Events: some modelling and a command to ingest JSONs from other projects as examples 2023-11-11 21:13:15 +01:00
Klaas van Schelven
238fb6dda7 Event as a Django model (first version) 2023-11-11 12:33:37 +01:00