Commit Graph

226 Commits

Author SHA1 Message Date
Klaas van Schelven
6b8d912e1a Store remote_addr on the event
Fix #165
2025-07-25 21:54:32 +02:00
Klaas van Schelven
7b340fd8ff Hide in-progress deletions of Project & Issue from the UI
I've done a full grep on Issue.objects, Project.objects and get_object_or_404
equivelents, and applying some common sense. The goal: avoid having
confusing/half-broken pages in the UI.

On index-usage: I've decided not to update the indexes. The assumption is:
`is_deleted` items will be a tiny minority of items in general, making the
cost/benefit analysis not turn out favorably (just scanning them out as a final
step is more efficient).  Also: sqlite is able to use the correct index without
adding a special one, proof:

```
EXPLAIN QUERY PLAN SELECT [..] WHERE ("issues_issue"."project_id" = 1 AND "issues_issue"."is_muted" = (0) AND "issues_issue"."is_resolved" = (0)) ORDER BY "issues_issue"."last_seen" DESC LIMIT 250;
QUERY PLAN
`--SEARCH issues_issue USING INDEX issue_list_open (project_id=? AND is_resolved=? AND is_muted=?)

EXPLAIN QUERY PLAN SELECT [..] WHERE ("issues_issue"."project_id" = 1 AND "issues_issue"."is_muted" = (0) AND "issues_issue"."is_resolved" = (0) AND "issues_issue"."is_deleted" = 0) ORDER BY "issues_issue"."last_seen" DESC LIMIT 250;
QUERY PLAN
`--SEARCH issues_issue USING INDEX issue_list_open (project_id=? AND is_resolved=? AND is_muted=?)
```

See #139 for the 0/1 notation in the above.

(Project-indexes: not an issue, the scale is "below relevance for indexes")
2025-07-07 10:27:36 +02:00
Klaas van Schelven
6b9e4d8011 Project.delete_deferred(): first version (WIP)
Implemented using a batch-wise dependency-scanner in delayed
(snappea) style.

* no real point-of-entry in the (regular, non-admin) UI yet.
* no hiding of Projects which are delete-in-progress from the UI

* lack of DRY
* some unnessary work (needed in the Issue-context, but not here)
  is still being done.

See #50
2025-07-03 21:01:28 +02:00
Klaas van Schelven
b58058ccd1 Repeatable tests/fix CI/CD
fixes KeyError: "exception"
2025-05-18 09:48:21 +02:00
Klaas van Schelven
49e6700d4a Grouping.grouping_key: hash it for the index 2025-05-06 11:32:19 +02:00
Klaas van Schelven
cc2b22f08e Digest: check Grouping.exists only once (save a query) 2025-05-06 10:30:51 +02:00
Klaas van Schelven
50343c0b2c Document further thoughts on store-envelopes in DB 2025-04-12 21:28:04 +02:00
Klaas van Schelven
ce87d901a1 Tests: use known_broken more aptly
for those tests that rely on a single sample, just pick a non-broken one,
rather than have skip-semantics
2025-03-31 14:55:39 +02:00
Klaas van Schelven
9b1911aded Fix issue.stored_event_count for eviction/retention 2025-03-31 14:51:58 +02:00
Klaas van Schelven
1b7865d3b9 Eviction: Tests and rewrite-for-understanding of epoch_bounds_with_irrelevance 2025-03-19 11:56:55 +01:00
Klaas van Schelven
7a19e2d277 Tags; deducing tags; search on tags; WIP 2025-02-27 13:12:49 +01:00
Klaas van Schelven
757ee31bed Support for CORS
Tested in-browser with:

```
function main() {
    $.ajax({
        type: "POST",
        url: "http://bugsink:8000/api/1/store/",
        headers: {
            "Content-Type": "application/json",
            "X-Sentry-Auth": "Sentry sentry_key=a2df4cd647dc4b7a8a81b78a3601eba1, sentry_version=7, sentry_client=bugsink/0.0.1",
        },
        data: JSON.stringify({foo: "Bar"}),
        success: function(data) {
            console.log(data);
        }
    });
}
```
2025-02-20 14:43:10 +01:00
Klaas van Schelven
934764dd8c Tests: Better error message for failing integration tests 2025-02-20 09:26:04 +01:00
Klaas van Schelven
3ccef7fd50 FileEventStorage: create dir on-demand; fix and add tests 2025-02-12 21:19:18 +01:00
Klaas van Schelven
7109ddeade tag test as 'samples'
it's calling a test that so-tagged, so logically it should also be
2025-02-12 20:54:41 +01:00
Klaas van Schelven
615d2da4c8 Chache stored_event_count (on Issue and Projet)
"possibly expensive" turned out to be "actually expensive". On 'emu', with 1.5M
events, the counts take 85 and 154 ms for Project and Issue respectively;
bottlenecking our digestion to ~3 events/s.

Note: this is single-issue, single-project (presumably, the cost would be lower
for more spread-out cases)

Note on indexes: Event already has indexes for both Project & Issue (though as
the first item in a multi-column index). Without checking further: that appears
to not "magically solve counting".

This commit also optimizes the .count() on the issue-detail event list (via
Paginator).

This commit also slightly changes the value passed as `stored_event_count` to
be used for `get_random_irrelevance` to be the post-evication value. That won't
matter much in practice, but is slightly more correct IMHO.
2025-02-06 16:24:25 +01:00
Klaas van Schelven
19bb91b636 Fix: set digested_at time correctly 2025-01-31 16:23:09 +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
c42aa9118a Describe role of Grouping and how it relates to Issue
third time's a charm (5e5b53abed, 48307daa0f)
2025-01-31 15:25:18 +01:00
Klaas van Schelven
672bbde4ba Fix DeprecationWarning ('warn') 2025-01-31 13:18:02 +01:00
Klaas van Schelven
43a6049180 Fix warning in tests (unclosed file) 2025-01-31 13:17:20 +01:00
Klaas van Schelven
9ae6233965 Wrap 2 more BASE_URL usages with str()
In 59372aba33 a lazily evaluated BASE_URL tool was introduced.
I found 2 more cases in which BASE_URL was not "collapsed into a
string" magically by `__add__`, one of which actually causing
an `Object of type TenantBaseURL is not JSON serializable`
2025-01-30 08:52:38 +01:00
Klaas van Schelven
452ac806b7 Raise from None
See https://www.bugsink.com/blog/using-raise-from-none-in-python/
in this case: PermissionDenied so clearly implies 'not found in db' that
the details of not finding are truly immaterial
2025-01-29 09:09:05 +01:00
Klaas van Schelven
59372aba33 First version of multi-tenant setup (EE) 2025-01-29 09:04:19 +01:00
Klaas van Schelven
ae9cb209a5 Create 'bsmain' (for bugsink-main) app to hold commands
As had been noted on some of the commands, 'ingest' was not the best place for
them.  However, [project-level apps are not supported in
Django](https://forum.djangoproject.com/t/allow-project-to-have-management-commands/5220/2)
So just create a 'main' app. I want to qualify it as 'myproject-main' though, to avoid
further unqualified global namespace pollution. And I want to avoid prefixing with 'bugsink'
b/c that's annoying for tab-completion. So 'bs' it is.

I've moved all commands over; even though a case could be made that the "feeding" commands
(raise_exception, send_json, stress_test) are somewhat related to ingestion, that's not
a very good case :-)
2025-01-23 11:55:34 +01:00
Klaas van Schelven
7727bc6168 Show dsn-as-understood when failing to authenticate in error message
status code for PermissionDenied rather than 404 also
2025-01-22 22:15:53 +01:00
Klaas van Schelven
505cae4b18 fix: don't raise non-existing exception
the previously referred type is from the DRF, but we don't use that
2025-01-17 17:04:28 +01:00
Klaas van Schelven
ed9ffa248d jsonschema check: allow for .values to be missing
see #16
2024-12-16 11:23:55 +01:00
Klaas van Schelven
b597d91af7 Become robust for lack of .values key in exception
Fix #16
2024-12-16 11:22:32 +01:00
Klaas van Schelven
f7280eaf75 flake8 2024-11-28 14:34:01 +01:00
Klaas van Schelven
ad3e758822 When Dogfooding, monkey-path MAX_DATABAG_* constants
See https://github.com/getsentry/sentry-python/issues/3209 for why
2024-11-28 14:28:35 +01:00
Klaas van Schelven
95c9dfa7a1 Use fastjsonschema's detailed_exceptions=False
We don't use fastjsonschema's exception info, falling back to jsonschema for that. Not using the info is faster.
Possible because https://github.com/horejsek/python-fastjsonschema/issues/187 was completed.

I did not at present do any speed/memory checks, but the diff is quite promising :-)
2024-11-28 11:42:16 +01:00
Klaas van Schelven
fa0c3aa325 X-Forwarded-For spoofing tool as an arg; Remove accidentally checked in file 2024-11-22 09:29:27 +01:00
Klaas van Schelven
1ca83bba83 SetRemoteAddrMiddleware for X-Real-IP and X-Forwarded-For 2024-11-21 09:53:16 +01:00
Klaas van Schelven
4a28c51b6a Tests: Add known-broken handling for events that are invalid on purpose 2024-11-15 11:20:12 +01:00
Klaas van Schelven
3222c0d85e Fix the tests (missing initial data in transactiontestcase) 2024-11-15 10:14:01 +01:00
Klaas van Schelven
0f60dab032 phone-home: on (docker) server-start too 2024-11-11 14:37:27 +01:00
Klaas van Schelven
488b52ea04 prestart command (simplying the throwaway Docker install) 2024-11-06 09:38:54 +01:00
Klaas van Schelven
1755fa32c0 Envelope parsing: push exception about lack of errors up into parser
fail-fast, rather than return-none-fail-later
2024-10-14 16:15:45 +02:00
Klaas van Schelven
1ca7a1ecd9 Envelope-parser parameter rename for clarity
the error is about whether an EOF can happen _right after_ the
header is parsed.
2024-10-14 11:34:11 +02:00
Klaas van Schelven
782bb81b82 Envelope is not actually json; let's reflect that in the filename 2024-10-09 09:38:00 +02:00
Klaas van Schelven
cba2eb3584 Envelope-store logging: point to exact location for download 2024-10-09 09:36:17 +02:00
Klaas van Schelven
55e077e974 Document a finding 2024-10-08 22:09:26 +02:00
Klaas van Schelven
98776ebdfb Storing of envelopes: added as a debugging tool 2024-10-08 13:19:07 +02:00
Klaas van Schelven
0e48f346d1 Avoid cross-transaction pollution
in IMMEDIATE mode, project was passed from an (implicit) read transaction to
the immediate_atomic-wrapped code; this meant that it was possible to miscount
project.digested_event_count
2024-10-08 11:53:31 +02:00
Klaas van Schelven
f0006a63f5 raise_exception helper: tag should be string
> Tags are key/value string pairs that are both indexed and searchable.
2024-10-08 11:00:57 +02:00
Klaas van Schelven
5e5b53abed Remove a false comment
(groupings do imply issues, it's a FK)
2024-09-27 18:14:51 +02:00
Klaas van Schelven
c50ae7afe7 Pin sample to test
on github.com the glob evaluated such that the sample could not be
modified according to the test-setup
2024-09-19 15:01:07 +02:00
Klaas van Schelven
b2b63c9664 Use precompiled event_schema.py 2024-09-19 14:57:47 +02:00
Klaas van Schelven
8f0985cbe5 fastjsonschema: don't touch my data please!
I'm sure this can be useful, but since I validate before storing, this is just
a ReallyBadIdea(TM). For one, it makes it so that running with different settings
of VALIDATE_ON_DIGEST leads to different data in the DB
2024-09-19 13:46:13 +02:00