Skip to content

Commit

Permalink
Merge branch 'master' into feat/redirect-dsn
Browse files Browse the repository at this point in the history
* master:
  ref(common): Make the DSN public key Copy (#795)
  ref(server): Bring back upstream response transformer (#794)
  ref(server): Upstream request retries & re-authentication (#788)
  • Loading branch information
jan-auer committed Oct 5, 2020
2 parents 2a58344 + 79ebd1e commit 75bd299
Show file tree
Hide file tree
Showing 10 changed files with 688 additions and 114 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

- Fix issue where `$span` would not be recognized in Advanced Data Scrubbing. ([#781](https://github.com/getsentry/relay/pull/781))
- Accept big-endian minidumps. ([#789](https://github.com/getsentry/relay/pull/789))
- Detect network outages and retry sending events instead of dropping them. ([#788](https://github.com/getsentry/relay/pull/788))

## 20.9.0

Expand Down
13 changes: 8 additions & 5 deletions relay-common/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize};
#[doc(inline)]
pub use sentry_types::ProjectId;

/// TODO: Doc
/// An error parsing [`ProjectKey`](struct.ProjectKey.html).
#[derive(Clone, Copy, Debug)]
pub struct ParseProjectKeyError;

Expand All @@ -18,7 +18,9 @@ impl fmt::Display for ParseProjectKeyError {

impl std::error::Error for ParseProjectKeyError {}

/// TODO: Document
/// The public key used in a DSN to identify and authenticate for a project at Sentry.
///
/// Project keys are always 32-character hexadecimal strings.
#[derive(Clone, Copy, Eq, Hash, Ord, PartialOrd, PartialEq)]
pub struct ProjectKey([u8; 32]);

Expand All @@ -42,7 +44,7 @@ impl<'de> Deserialize<'de> for ProjectKey {
}

impl ProjectKey {
/// TODO: Document
/// Parses a `ProjectKey` from a string.
pub fn parse(key: &str) -> Result<Self, ParseProjectKeyError> {
if key.len() != 32 || !key.is_ascii() {
return Err(ParseProjectKeyError);
Expand All @@ -53,10 +55,11 @@ impl ProjectKey {
Ok(project_key)
}

/// TODO: Document
/// Returns the string representation of the project key.
#[inline]
pub fn as_str(&self) -> &str {
// TODO: Describe safety
// Safety: The string is already validated to be of length 32 and valid ASCII when
// constructing `ProjectKey`.
unsafe { std::str::from_utf8_unchecked(&self.0) }
}
}
Expand Down
24 changes: 12 additions & 12 deletions relay-config/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ use relay_redis::RedisConfig;
use crate::byte_size::ByteSize;
use crate::upstream::UpstreamDescriptor;

const DEFAULT_NETWORK_OUTAGE_GRACE_PERIOD: u64 = 10;

/// Defines the source of a config error
#[derive(Debug)]
enum ConfigErrorSource {
Expand Down Expand Up @@ -546,13 +548,12 @@ struct Http {
///
/// Defaults to `600` (10 minutes).
auth_interval: Option<u64>,
/// The time until Relay considers authentication dropped after experiencing errors.
/// The maximum time of experiencing uninterrupted network failures until Relay considers that
/// it has encountered a network outage in seconds.
///
/// If connection with the upstream resumes or authentication succeeds during the grace period,
/// Relay retains normal operation. If, instead, connection errors or failed re-authentication
/// attempts persist beyond the grace period, Relay suspends event submission and reverts into
/// authentication mode.
auth_grace_period: u64,
/// During a network outage relay will try to reconnect and will buffer all upstream messages
/// until it manages to reconnect.
outage_grace_period: u64,
/// Content encoding to apply to upstream store requests.
///
/// By default, Relay applies `gzip` content encoding to compress upstream requests. Compression
Expand All @@ -578,7 +579,7 @@ impl Default for Http {
max_retry_interval: 60, // 1 minute
host_header: None,
auth_interval: Some(600), // 10 minutes
auth_grace_period: 10,
outage_grace_period: DEFAULT_NETWORK_OUTAGE_GRACE_PERIOD,
encoding: HttpEncoding::Gzip,
}
}
Expand Down Expand Up @@ -1161,11 +1162,10 @@ impl Config {
}
}

/// The maximum amount of time that a Relay is allowed to take to re-authenticate with
/// the upstream after which it is declared as un-authenticated (if it is not able to
/// authenticate).
pub fn http_auth_grace_period(&self) -> Duration {
Duration::from_secs(self.values.http.auth_grace_period)
/// The maximum time of experiencing uninterrupted network failures until Relay considers that
/// it has encountered a network outage.
pub fn http_outage_grace_period(&self) -> Duration {
Duration::from_secs(self.values.http.outage_grace_period)
}

/// Content encoding of upstream requests.
Expand Down
Loading

0 comments on commit 75bd299

Please sign in to comment.