Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Process Unreal crash reports as an internal integration item. ([#6598](https://github.com/getsentry/relay/pull/6598))
- Report specific discard reasons for log and span integration items instead of `integration`. ([#6604](https://github.com/getsentry/relay/pull/6604))
- Update sentry-conventions to 0.30.0. Adds `aws.lambda.initialization_type`, `aws.lambda.web.endpoint_name`, and `faas.max_memory` with manual scrubbing policies. ([#6586](https://github.com/getsentry/relay/pull/6586))
- Split processor service into `EnvelopeProcessor` and `BucketProcessor`. ([#6622](https://github.com/getsentry/relay/pull/6622))

**Bug Fixes**:

Expand Down
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5178,6 +5178,7 @@ dependencies = [
"flume",
"futures",
"pin-project-lite",
"relay-log",
"relay-system",
"tokio",
]
Expand Down
2 changes: 1 addition & 1 deletion relay-sampling/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ pub enum RuleType {
/// Like trace rules, it is evaluated on the [`DynamicSamplingContext`](crate::DynamicSamplingContext).
Project,
// NOTE: If you add a new `RuleType` that is not supposed to sample transactions, you need to
// edit the `sample_envelope` function in `EnvelopeProcessorService`.
// edit the dynamic sampling business logic.
/// If the sampling config contains new rule types, do not sample at all.
#[serde(other)]
Unsupported,
Expand Down
50 changes: 35 additions & 15 deletions relay-server/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ use crate::services::outcome::{
ClientReportOutcomeProducerService, NullOutcomeProducerService, OutcomeProducerService,
TrackOutcome,
};
use crate::services::processor::{
self, EnvelopeProcessor, EnvelopeProcessorService, EnvelopeProcessorServicePool,
};
use crate::services::processor::{self, EnvelopeProcessor};
use crate::services::projects::cache::{ProjectCacheHandle, ProjectCacheService};
use crate::services::projects::source::ProjectSource;
use crate::services::proxy_processor::{ProxyAddrs, ProxyProcessorService};
Expand All @@ -49,6 +47,7 @@ use relay_redis::redis::Script;
#[cfg(feature = "processing")]
use relay_redis::{RedisClients, RedisError, RedisScripts};
use relay_system::{Addr, Service, ServiceSpawn, ServiceSpawnExt as _, channel};
use relay_threading::ServicePool;

/// Indicates the type of failure of the server.
#[derive(Debug, thiserror::Error)]
Expand Down Expand Up @@ -108,7 +107,7 @@ pub fn create_runtime(name: &'static str, threads: usize) -> relay_system::Runti
.build()
}

fn create_processor_pool(config: &ConfigSnapshot) -> Result<EnvelopeProcessorServicePool> {
fn create_processor_pool(config: &ConfigSnapshot) -> Result<ServicePool> {
// Adjust thread count for small cpu counts to not have too many idle cores
// and distribute workload better.
let thread_count = match config.cpu_concurrency() {
Expand Down Expand Up @@ -193,9 +192,9 @@ impl ServiceState {

// Create an address for the `EnvelopeProcessor`, which can be injected into the
// other services.
let (processor, processor_rx) = match current_config.relay_mode() {
let (envelope_processor, envelope_processor_rx) = match current_config.relay_mode() {
RelayMode::Proxy => channel(ProxyProcessorService::name()),
RelayMode::Managed => channel(EnvelopeProcessorService::name()),
RelayMode::Managed => channel("envelope_processor"),

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The name of this service queue would have changed anyway (from relay_server::services::processor::envelopeprocessorservice to something like relay_threading::service::asyncpoolservice::..), so I decided to keep it simple and just name it envelope_processor.

};

let (aggregator, aggregator_rx) = channel(RouterService::name());
Expand All @@ -205,7 +204,7 @@ impl ServiceState {
_ => match current_config.relay_mode() {
RelayMode::Proxy => services.start(ClientReportOutcomeProducerService::new(
&current_config,
processor.clone(),
envelope_processor.clone(),
)),
RelayMode::Managed => services.start(OutcomeProducerService::new(
Arc::clone(&config),
Expand Down Expand Up @@ -274,7 +273,7 @@ impl ServiceState {
memory_stat.clone(),
global_config_rx.clone(),
project_cache_handle.clone(),
processor.clone(),
envelope_processor.clone(),
outcome_aggregator.clone(),
services,
);
Expand All @@ -290,33 +289,54 @@ impl ServiceState {
upstream_relay: upstream_relay.clone(),
},
),
processor_rx,
envelope_processor_rx,
);
(None, None, None)
}
RelayMode::Managed => {
let processor_pool = create_processor_pool(&current_config)?;
// Share the quota cache between envelope and bucket processing.
#[cfg(feature = "processing")]
let rate_limiter =
processor::create_rate_limiter(&current_config, redis_clients.clone());

let bucket_processor = services.start(processor::bucket::create_service(
processor_pool.clone(),
config.clone(),
global_config_handle.clone(),
project_cache_handle.clone(),
cogs.clone(),
#[cfg(feature = "processing")]
rate_limiter.clone(),
processor::bucket::Addrs {
outcome_aggregator: outcome_aggregator.clone(),
upstream_relay: upstream_relay.clone(),
#[cfg(feature = "processing")]
store_forwarder: store.clone(),
},
metric_outcomes.clone(),
));

let router = RouterService::new(
handle.clone(),
current_config.default_aggregator_config().clone(),
current_config.secondary_aggregator_configs().clone(),
Some(processor.clone().recipient()),
Some(bucket_processor.recipient()),
project_cache_handle.clone(),
);
let router_handle = router.handle();
services.start_with(router, aggregator_rx);

services.start_with(
EnvelopeProcessorService::new(
processor::envelope::create_service(
processor_pool.clone(),
config.clone(),
global_config_handle.clone(),
project_cache_handle.clone(),
cogs.clone(),
#[cfg(feature = "processing")]
redis_clients.clone(),
processor::Addrs {
rate_limiter,
processor::envelope::Addrs {
outcome_aggregator: outcome_aggregator.clone(),
upstream_relay: upstream_relay.clone(),
#[cfg(feature = "processing")]
Expand All @@ -327,7 +347,7 @@ impl ServiceState {
},
metric_outcomes.clone(),
),
processor_rx,
envelope_processor_rx,
);

let autoscaling = services.start(AutoscalingMetricService::new(
Expand Down Expand Up @@ -380,7 +400,7 @@ impl ServiceState {

let registry = Registry {
cogs,
processor,
processor: envelope_processor,
health_check,
outcome_aggregator,
relay_cache,
Expand Down
6 changes: 3 additions & 3 deletions relay-server/src/services/autoscaling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use std::sync::Arc;

use crate::MemoryStat;
use crate::services::buffer::PartitionedEnvelopeBuffer;
use crate::services::processor::EnvelopeProcessorServicePool;
use relay_system::{
AsyncResponse, Controller, FromMessage, Handle, Interface, RuntimeMetrics, Sender, Service,
};
use relay_threading::ServicePool;
use tokio::time::Instant;

/// Service that tracks internal relay metrics so that they can be exposed.
Expand All @@ -23,15 +23,15 @@ pub struct AutoscalingMetricService {
/// This will always report `1` unless the instance is shutting down.
up: u8,
/// Gives access to AsyncPool metrics.
async_pool: EnvelopeProcessorServicePool,
async_pool: ServicePool,
}

impl AutoscalingMetricService {
pub fn new(
memory_stat: MemoryStat,
envelope_buffer: Arc<PartitionedEnvelopeBuffer>,
handle: Handle,
async_pool: EnvelopeProcessorServicePool,
async_pool: ServicePool,
) -> Self {
let runtime_metrics = handle.metrics();
Self {
Expand Down
Loading
Loading