Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(server): Implement an HTTP outcomes producer #592

Merged
merged 17 commits into from
Jun 9, 2020
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 @@ -19,6 +19,7 @@ We have switched to [CalVer](https://calver.org/)! Relay's version is always in

**Internal**:

- Add support for Outcomes generation in non processing relays.([#592](https://github.com/getsentry/relay/pull/592))
- Ignore non-Rust folders for faster rebuilding and testing. ([#578](https://github.com/getsentry/relay/pull/578))
- 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))
- Remove unused `rev` from project state. ([#586](https://github.com/getsentry/relay/pull/586))
Expand Down
45 changes: 39 additions & 6 deletions relay-config/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,6 @@ pub struct Relay {
pub tls_identity_path: Option<PathBuf>,
/// Password for the PKCS12 archive.
pub tls_identity_password: Option<String>,
/// Controls whether outcomes will be emitted when processing is disabled.
/// Processing relays always emit outcomes (for backwards compatibility).
pub emit_outcomes: bool,
}

impl Default for Relay {
Expand All @@ -366,7 +363,6 @@ impl Default for Relay {
tls_port: None,
tls_identity_path: None,
tls_identity_password: None,
emit_outcomes: false,
}
}
}
Expand Down Expand Up @@ -710,6 +706,31 @@ impl Default for Processing {
}
}

/// Outcome generation specific configuration values.
#[derive(Serialize, Deserialize, Debug)]
#[serde(default)]
pub struct Outcomes {
/// Controls whether outcomes will be emitted when processing is disabled.
/// Processing relays always emit outcomes (for backwards compatibility).
pub emit_outcomes: bool,
/// The maximum number of outcomes that are batched before being sent
/// via http to the upstream (only applies to non processing relays)
pub batch_size: usize,
/// The maximum time interval (in milliseconds) that an outcome may be batched
/// via http to the upstream (only applies to non processing relays)
pub batch_interval: u64,
}

impl Default for Outcomes {
fn default() -> Self {
Outcomes {
emit_outcomes: false,
batch_size: 1000,
batch_interval: 500,
}
}
}

/// Minimal version of a config for dumping out.
#[derive(Serialize, Deserialize, Debug, Default)]
pub struct MinimalConfig {
Expand Down Expand Up @@ -757,6 +778,8 @@ struct ConfigValues {
sentry: Sentry,
#[serde(default)]
processing: Processing,
#[serde(default)]
outcomes: Outcomes,
}

impl ConfigObject for ConfigValues {
Expand Down Expand Up @@ -838,7 +861,7 @@ impl Config {
"true" | "1" => processing.enabled = true,
"false" | "0" | "" => processing.enabled = false,
_ => {
return Err(ConfigError::new(ConfigErrorKind::InvalidValue).field("processing"))
return Err(ConfigError::new(ConfigErrorKind::InvalidValue).field("processing"));
}
}
}
Expand Down Expand Up @@ -1044,7 +1067,17 @@ impl Config {

/// Returns the emit_outcomes flag
pub fn emit_outcomes(&self) -> bool {
self.values.relay.emit_outcomes
self.values.outcomes.emit_outcomes
}

/// Returns the maximum number of outcomes that are batched before being sent
pub fn outcome_batch_size(&self) -> usize {
self.values.outcomes.batch_size
}

/// Returns the maximum interval that an outcome may be batched
pub fn outcome_batch_interval(&self) -> Duration {
Duration::from_millis(self.values.outcomes.batch_interval)
}

/// Returns the log level.
Expand Down
Loading