relay_quotas

Struct Quota

source
pub struct Quota {
    pub id: Option<String>,
    pub categories: DataCategories,
    pub scope: QuotaScope,
    pub scope_id: Option<String>,
    pub limit: Option<u64>,
    pub window: Option<u64>,
    pub namespace: Option<MetricNamespace>,
    pub reason_code: Option<ReasonCode>,
}
Expand description

Configuration for a data ingestion quota (rate limiting).

Sentry applies multiple quotas to incoming data before accepting it, some of which can be configured by the customer. Each piece of data (such as event, attachment) will be counted against all quotas that it matches with based on the category.

Fields§

§id: Option<String>

The unique identifier for counting this quota. Required, except for quotas with a limit of 0, since they are statically enforced.

§categories: DataCategories

A set of data categories that this quota applies to. If missing or empty, this quota applies to all data.

§scope: QuotaScope

A scope for this quota. This quota is enforced separately within each instance of this scope (e.g. for each project key separately). Defaults to QuotaScope::Organization.

§scope_id: Option<String>

Identifier of the scope to apply to. If set, then this quota will only apply to the specified scope instance (e.g. a project key). Requires scope to be set explicitly.

§limit: Option<u64>

Maximum number of matching events allowed. Can be 0 to reject all events, None for an unlimited counted quota, or a positive number for enforcement. Requires window if the limit is not 0.

For attachments, this limit expresses the number of allowed bytes.

§window: Option<u64>

The time window in seconds to enforce this quota in. Required in all cases except limit=0, since those quotas are not measured.

§namespace: Option<MetricNamespace>

The namespace the quota applies to.

If None, it will match any namespace.

§reason_code: Option<ReasonCode>

A machine readable reason returned when this quota is exceeded. Required in all cases except limit=None, since unlimited quotas can never be exceeded.

Implementations§

source§

impl Quota

source

pub fn is_valid(&self) -> bool

Returns whether this quota is valid for tracking.

There are a few conditions at which quotas are invalid:

  • The quota only applies to Unknown data categories.
  • The quota is counted (not limit 0) but specifies categories with different units.
  • The quota references an unsupported namespace.
source

pub fn matches(&self, scoping: ItemScoping<'_>) -> bool

Checks whether the quota’s constraints match the current item.

Trait Implementations§

source§

impl Clone for Quota

source§

fn clone(&self) -> Quota

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Quota

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for Quota

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl PartialEq for Quota

source§

fn eq(&self, other: &Quota) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Quota

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl StructuralPartialEq for Quota

Auto Trait Implementations§

§

impl Freeze for Quota

§

impl RefUnwindSafe for Quota

§

impl Send for Quota

§

impl Sync for Quota

§

impl Unpin for Quota

§

impl UnwindSafe for Quota

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T