Skip to content

Commit 475e623

Browse files
authored
feat(server): Implement an HTTP outcomes producer (#592)
Add support for generating and forwarding Outcomes for non processing relays.
1 parent 17066dc commit 475e623

File tree

8 files changed

+450
-119
lines changed

8 files changed

+450
-119
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ We have switched to [CalVer](https://calver.org/)! Relay's version is always in
1919

2020
**Internal**:
2121

22+
- Add support for Outcomes generation in non processing relays.([#592](https://github.com/getsentry/relay/pull/592))
2223
- Ignore non-Rust folders for faster rebuilding and testing. ([#578](https://github.com/getsentry/relay/pull/578))
2324
- Invalid session payloads are now logged for SDK debugging. ([#584](https://github.com/getsentry/relay/pull/584), [#591](https://github.com/getsentry/relay/pull/591))
2425
- Remove unused `rev` from project state. ([#586](https://github.com/getsentry/relay/pull/586))

relay-config/src/config.rs

+39-6
Original file line numberDiff line numberDiff line change
@@ -351,9 +351,6 @@ pub struct Relay {
351351
pub tls_identity_path: Option<PathBuf>,
352352
/// Password for the PKCS12 archive.
353353
pub tls_identity_password: Option<String>,
354-
/// Controls whether outcomes will be emitted when processing is disabled.
355-
/// Processing relays always emit outcomes (for backwards compatibility).
356-
pub emit_outcomes: bool,
357354
}
358355

359356
impl Default for Relay {
@@ -366,7 +363,6 @@ impl Default for Relay {
366363
tls_port: None,
367364
tls_identity_path: None,
368365
tls_identity_password: None,
369-
emit_outcomes: false,
370366
}
371367
}
372368
}
@@ -710,6 +706,31 @@ impl Default for Processing {
710706
}
711707
}
712708

709+
/// Outcome generation specific configuration values.
710+
#[derive(Serialize, Deserialize, Debug)]
711+
#[serde(default)]
712+
pub struct Outcomes {
713+
/// Controls whether outcomes will be emitted when processing is disabled.
714+
/// Processing relays always emit outcomes (for backwards compatibility).
715+
pub emit_outcomes: bool,
716+
/// The maximum number of outcomes that are batched before being sent
717+
/// via http to the upstream (only applies to non processing relays)
718+
pub batch_size: usize,
719+
/// The maximum time interval (in milliseconds) that an outcome may be batched
720+
/// via http to the upstream (only applies to non processing relays)
721+
pub batch_interval: u64,
722+
}
723+
724+
impl Default for Outcomes {
725+
fn default() -> Self {
726+
Outcomes {
727+
emit_outcomes: false,
728+
batch_size: 1000,
729+
batch_interval: 500,
730+
}
731+
}
732+
}
733+
713734
/// Minimal version of a config for dumping out.
714735
#[derive(Serialize, Deserialize, Debug, Default)]
715736
pub struct MinimalConfig {
@@ -757,6 +778,8 @@ struct ConfigValues {
757778
sentry: Sentry,
758779
#[serde(default)]
759780
processing: Processing,
781+
#[serde(default)]
782+
outcomes: Outcomes,
760783
}
761784

762785
impl ConfigObject for ConfigValues {
@@ -838,7 +861,7 @@ impl Config {
838861
"true" | "1" => processing.enabled = true,
839862
"false" | "0" | "" => processing.enabled = false,
840863
_ => {
841-
return Err(ConfigError::new(ConfigErrorKind::InvalidValue).field("processing"))
864+
return Err(ConfigError::new(ConfigErrorKind::InvalidValue).field("processing"));
842865
}
843866
}
844867
}
@@ -1044,7 +1067,17 @@ impl Config {
10441067

10451068
/// Returns the emit_outcomes flag
10461069
pub fn emit_outcomes(&self) -> bool {
1047-
self.values.relay.emit_outcomes
1070+
self.values.outcomes.emit_outcomes
1071+
}
1072+
1073+
/// Returns the maximum number of outcomes that are batched before being sent
1074+
pub fn outcome_batch_size(&self) -> usize {
1075+
self.values.outcomes.batch_size
1076+
}
1077+
1078+
/// Returns the maximum interval that an outcome may be batched
1079+
pub fn outcome_batch_interval(&self) -> Duration {
1080+
Duration::from_millis(self.values.outcomes.batch_interval)
10481081
}
10491082

10501083
/// Returns the log level.

0 commit comments

Comments
 (0)