Commit graph

1560 commits

Author SHA1 Message Date
Lambda
148df18989
Stop debug-logging every incoming request 2024-06-04 13:32:31 -07:00
Benjamin Lee
3551a6ef7a
fix dropped events in search
The previous code would drop some events entirely if any events between
`skip` and `skip + limit` were not visible to the user. This would cause
the set of events skipped by the `skip(skip)` method to extend past
`skip` in the raw result set, because `skip(skip)` was being called
*after* filtering out invisible events.

This bug will become much more severe with a full filtering
implementation, because it will be more likely for events to be filtered
out. Currently, it is only possible to trigger with rooms that have
history visibility set to "invited" or "joined".
2024-06-04 01:12:53 -07:00
Benjamin Lee
0cdf03288a
fix missing next_batch for search
The previous code would fail to return next_batch if any of the events
in the window were not visible to the user. It would also return an
unnecessary next_batch when no more results are available if the total
number of results is exactly `skip + limit`.

This bug will become much more severe with a full filtering
implementation, because we will be more likely to trigger it by
filtering out events in a search call. Currently, it is only possible to
trigger with rooms that have history visibility set to "invited" or
"joined".
2024-06-04 01:12:53 -07:00
Charles Hall
c1ec1111ae
improve route-not-found tracing event 2024-06-03 18:18:44 -07:00
Charles Hall
04ecf4972e
record histogram of http requests 2024-06-03 18:18:44 -07:00
Charles Hall
a0b92c82e8
set up opentelemetry for metrics
Also adds an `allow_prometheus` option (disabled by default) to expose
a `/metrics` endpoint that returns Prometheus data.
2024-06-03 18:18:44 -07:00
Charles Hall
94fda7c875
improve usage of Resource
* Extract into reusable function (we'll need this later)
* Merge the values we want to override over the defaults, instead of
  dropping the defaults completely
* Don't unnecessarily allocate (the `vec![]` usage is gone)
2024-06-03 18:18:44 -07:00
Benjamin Lee
c64a474954
workaround to fix search in element
We inherited a similar workaround from conduit, but removed it in
71c48f66c4. At the time, it was not clear
that this had broken search.

Fixes: !26
2024-06-03 18:02:41 -07:00
Lambda
5c39c7c5ff Use destination field in X-Matrix Authorization header
Both validating and sending it is a MUST since Matrix v1.3.
2024-06-03 20:50:49 +00:00
Lambda
62dd097f49 Use Ruma XMatrix type instead of rolling our own
Both the hand-rolled parser and serialization were wrong in countless
ways. The current Ruma parser is much better, and the Ruma serialization
will be fixed by https://github.com/ruma/ruma/pull/1830.
2024-06-03 20:50:49 +00:00
Lambda
bf1d54defc axum: factor out non-generic parts of request conversion
This saves ~10% in binary size!
2024-05-31 10:42:47 +00:00
Lambda
b6fc9b0feb
service/media: add some tracing 2024-05-30 15:40:28 -07:00
Lambda
0a92c72566
Put thumbnail creation inside spawn_blocking()
This can take milliseconds or even several seconds for huge inputs,
while the rule of thumb is <100us between await points.
2024-05-30 15:40:28 -07:00
Lambda
c973485c73
service/media: refactor to reduce indentation 2024-05-30 15:40:24 -07:00
Benjamin Lee
ec1b086a35
very minor cleanup in the sync endpoint
I meant to do this in 146465693e, but
looks like I forgot.
2024-05-30 10:19:24 -07:00
Benjamin Lee
72962c6402
enable allow_federation config by default
We inherited the disabled-by-default setting from conduit. Conduwuit
change it to enabled-by-default in [1]. This can make things confusing
for users migrating from conduwuit to grapevine, especially since we
currently do not log a warning when federation is disabled.

[1]: 24605e151d
2024-05-30 09:30:13 -07:00
Lambda
12e7f525aa Clean up and deduplicate parse_servercurrentevent() 2024-05-29 20:42:59 +00:00
Lambda
25353da8b8 sending.rs: record handler errors using Display 2024-05-29 20:42:46 +00:00
Lambda
fb52ded222 sending.rs: try to preserve requester spans
Add a `follows_from` relationship to the dispatched worker's span
pointing to the caller of `send_*()`, if known.
2024-05-29 20:42:46 +00:00
Lambda
18992b4d1d sending.rs: rename OutgoingKind to Destination
That's what it is. It describes the destination of the event.
2024-05-29 20:42:45 +00:00
Lambda
9071e11e06 sending.rs: move handler functions out of service
These don't take `self`, no reason for them to be associated functions.
2024-05-29 20:42:14 +00:00
Lambda
13f79dfee1 sending.rs: factor out event handlers into separate functions
This allows for much nicer control flow, since they don't need to return
Result<OutgoingKind, (OutgoingKind, Error)>.
2024-05-29 20:42:14 +00:00
Lambda
5caafdec06 sending.rs: formatting 2024-05-29 20:42:14 +00:00
Lambda
aa69b7d15c sending.rs: rename handle_futures->handle_response
The future is already done when this is called.
2024-05-29 20:42:14 +00:00
Lambda
9961f1465f sending.rs: add RequestData to replace big tuple 2024-05-29 20:42:14 +00:00
Lambda
e294543ddb sending.rs: add RequestKey
Much easier to reason about than with a bunch of Vec<u8> everywhere.
2024-05-29 20:42:13 +00:00
Charles Hall
507de063f5
don't hardcode EnvFilter for tracing-flame 2024-05-27 10:06:26 -07:00
Lambda
7a154f7416
observability: allow combining multiple tracing layers
Previously, jaeger, tracing_flame and stderr output were mutually
exclusive. There's no good reason for this.
2024-05-27 10:03:44 -07:00
Lambda
263edcc8a1
observability: don't drop tracing_flame drop guard until exit 2024-05-27 10:02:42 -07:00
Charles Hall
c17ab5328d
factor observability things into its own module
And also create a new error for the observability initialization.
2024-05-27 10:01:00 -07:00
Charles Hall
8f0fdfb2f2
upgrade all cargo dependencies
Unfortunately we need to pull tracing-opentelemetry from git because
there hasn't been a release including the dependency bump on the other
opentelemetry crates.
2024-05-26 19:47:00 -07:00
Charles Hall
13de9ecd41
enable unnecessary_to_owned lint
*facepalm*
2024-05-26 19:47:00 -07:00
Charles Hall
7e7911abcf
enable thread_local_initializer_can_be_made_const
There's barely enough room in the commit title for this lint's name...
2024-05-26 19:47:00 -07:00
Charles Hall
3daf2229d6
enable option_as_ref_cloned lint 2024-05-26 19:47:00 -07:00
Charles Hall
eaeb7620d9
enable multiple_bound_locations lint 2024-05-26 19:47:00 -07:00
Charles Hall
92d9f81a78
enable mixed_attributes_style lint 2024-05-26 19:47:00 -07:00
Charles Hall
41a5e6fb50
enable manual_is_variant_and lint 2024-05-26 19:47:00 -07:00
Charles Hall
5048af3a8f
enable doc_markdown lint 2024-05-26 19:47:00 -07:00
Charles Hall
c9859a9b2d
enable assigning_clones lint 2024-05-26 19:47:00 -07:00
Charles Hall
793d809ac6
enable unused_qualifications lint 2024-05-26 19:47:00 -07:00
Charles Hall
d7e945f4c5
enable dead_code lint 2024-05-26 19:46:48 -07:00
Lambda
67cb6f817d Instrument caches 2024-05-22 20:10:42 +00:00
Lambda
62bff27d50 Remove unused cache 2024-05-22 20:08:43 +00:00
Charles Hall
6e2eec012f
special case userroomid_highlightcount
This fixes the panic on startup with a fresh database.
2024-05-21 17:56:56 -07:00
Charles Hall
b3709f262e
panic when a column family would be created twice
`create_cf` already fails when the column family already exists, but
this gives us a much better error message; namely, it tells us what
column family name is at fault.
2024-05-21 17:48:33 -07:00
Charles Hall
53fbd3fc41
store old_cfs as a HashSet
This list can't have duplicates.
2024-05-21 17:25:23 -07:00
Charles Hall
a60a9551e1
Revert "Merge branch 'check-if-membership-is-case-endpoints' into 'next'"
This reverts commit 7ace9b0dff, reversing
changes made to 624654a88b.
2024-05-21 16:34:26 -07:00
Charles Hall
49660b9e39
return a concrete error type from try_main
Also adds a utility for formatting an error message in addition to all
of its sources, i.e. errors that came before it that led to the current
error.

This helps us to provide better error messages to users by including
more information: both our own error message and all of the underlying
error messages, if any, instead of only one or the other.
2024-05-20 14:51:30 -07:00
Charles Hall
4407e15d78
reword error message about GRAPEVINE_CONFIG
The new message more accurately reflects the purpose and behaviors of
the environment variable.
2024-05-20 14:47:38 -07:00
Charles Hall
23f99015df
return ExitCode instead of using panic or exit
`panic!()` (and things that invoke it, such as `expect` and `unwrap`)
produces terrible looking error messages and `std::process::exit()`
doesn't run destructors. Instead, we'll make a `try_main` that can
return a `Result` with a structured error type, but for now I'm going to
be lazy and just use `Box<dyn Error>`. Then, `main` will call it and
return the appropriate `ExitCode` value based on `try_main`'s `Result`.
This gives us the opportunity to produce good error messages and doesn't
violently terminate the program.
2024-05-20 14:47:34 -07:00