Skip to content

Commit

Permalink
fix(server): Increase size limits for batch endpoints (#3562)
Browse files Browse the repository at this point in the history
These endpoints receive large batches of JSON data from trusted sources.
We started seeing some 4xx responses in S4S after switching to 60s
bucketing for custom metrics.
  • Loading branch information
jjbayer authored May 7, 2024
1 parent 1121a5e commit 47331df
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- Forward `span.data` on the Kafka message. ([#3523](https://github.com/getsentry/relay/pull/3523))
- Tag span duration metric like exclusive time. ([#3524](https://github.com/getsentry/relay/pull/3524))
- Emit negative outcomes for denied metrics. ([#3508](https://github.com/getsentry/relay/pull/3508))
- Increase size limits for internal batch endpoints. ([#3562](https://github.com/getsentry/relay/pull/3562))

## 24.4.2

Expand Down
11 changes: 9 additions & 2 deletions relay-server/src/endpoints/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ use relay_config::Config;
use crate::middlewares;
use crate::service::ServiceState;

/// Size limit for internal batch endpoints.
const BATCH_JSON_BODY_LIMIT: usize = 50_000_000; // 50 MB

#[rustfmt::skip]
pub fn routes<B>(config: &Config) -> Router<ServiceState, B>
where
Expand All @@ -62,12 +65,15 @@ where
let web_routes = Router::new()
.route("/api/0/relays/projectconfigs/", post(project_configs::handle))
.route("/api/0/relays/publickeys/", post(public_keys::handle))
.route("/api/0/relays/outcomes/", post(batch_outcomes::handle))
.route("/api/0/relays/metrics/", post(batch_metrics::handle))
// Network connectivity check for downstream Relays, same as the internal health check.
.route("/api/0/relays/live/", get(health_check::handle_live))
.route_layer(DefaultBodyLimit::max(crate::constants::MAX_JSON_SIZE));

let batch_routes = Router::new()
.route("/api/0/relays/outcomes/", post(batch_outcomes::handle))
.route("/api/0/relays/metrics/", post(batch_metrics::handle))
.route_layer(DefaultBodyLimit::max(BATCH_JSON_BODY_LIMIT));

// Ingestion routes pointing to /api/:project_id/
let store_routes = Router::new()
// Legacy store path that is missing the project parameter.
Expand Down Expand Up @@ -97,6 +103,7 @@ where

router.merge(internal_routes)
.merge(web_routes)
.merge(batch_routes)
.merge(store_routes)
// Forward all other API routes to the upstream. This will 404 for non-API routes.
.fallback(forward::forward)
Expand Down

0 comments on commit 47331df

Please sign in to comment.