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): Org rate limit per metric bucket #2758

Merged
merged 42 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
49b6d7d
split and partition buckets in envelope processor
Dav1dde Nov 17, 2023
da0ebea
produce outcomes for metrics
Dav1dde Nov 17, 2023
3e3f869
wip
TBS1996 Nov 21, 2023
bdb83ac
wip
TBS1996 Nov 22, 2023
fa0c081
wip
TBS1996 Nov 23, 2023
3c40af6
wip
TBS1996 Nov 23, 2023
99c00c4
add outcomes
TBS1996 Nov 24, 2023
f01ad02
merge attempt
TBS1996 Nov 28, 2023
59edc28
wip
TBS1996 Nov 28, 2023
7714338
wip
TBS1996 Nov 28, 2023
8285e39
wip
TBS1996 Nov 28, 2023
0722a57
wip
TBS1996 Nov 29, 2023
f2dd09e
wip
TBS1996 Nov 29, 2023
d4cd3fc
wip
TBS1996 Nov 29, 2023
60040e8
wip
TBS1996 Nov 30, 2023
86e97dd
wip
TBS1996 Nov 30, 2023
b46d7ea
wip
TBS1996 Nov 30, 2023
e2d60c4
wip
TBS1996 Nov 30, 2023
9ea64bb
cl
TBS1996 Nov 30, 2023
a8b8701
make header
TBS1996 Dec 1, 2023
531bd28
outcomes
TBS1996 Dec 1, 2023
a897801
.
TBS1996 Dec 1, 2023
b49a8fe
merge
TBS1996 Dec 1, 2023
0fe5b91
use source q
TBS1996 Dec 1, 2023
47ce74c
.
TBS1996 Dec 1, 2023
4d143a7
merge
TBS1996 Dec 1, 2023
b433ce0
lints
TBS1996 Dec 1, 2023
c168326
fix
TBS1996 Dec 1, 2023
1e0a7e5
lint
TBS1996 Dec 1, 2023
38ce8ee
address feedback
TBS1996 Dec 5, 2023
9ecd26c
limiting on non-proc relays
TBS1996 Dec 5, 2023
e7b1b49
change to ratelimiting per bucket
TBS1996 Dec 5, 2023
e485c7b
nit
TBS1996 Dec 5, 2023
e4efae4
rename batches
TBS1996 Dec 5, 2023
54d8e0a
rename batches
TBS1996 Dec 5, 2023
7de002a
add integration test
TBS1996 Dec 6, 2023
2e5725c
Merge branch 'master' into tor/orgtotal
TBS1996 Dec 6, 2023
82326a0
fix timestamp and log
TBS1996 Dec 6, 2023
99e7efd
fix
TBS1996 Dec 6, 2023
7d3e220
fix the fix
TBS1996 Dec 6, 2023
5aa22cc
nit
TBS1996 Dec 6, 2023
974ebe5
fix comp
TBS1996 Dec 6, 2023
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 @@ -23,6 +23,7 @@
- Temporarily add metric summaries on spans and top-level transaction events to link DDM with performance monitoring. ([#2757](https://github.com/getsentry/relay/pull/2757))
- Add size limits on metric related envelope items. ([#2800](https://github.com/getsentry/relay/pull/2800))
- Include the size offending item in the size limit error message. ([#2801](https://github.com/getsentry/relay/pull/2801))
- Org rate limit metrics per bucket. ([#2758](https://github.com/getsentry/relay/pull/2758))

## 23.11.2

Expand Down
1 change: 1 addition & 0 deletions py/sentry_relay/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class DataCategory(IntEnum):
SPAN = 12
MONITOR_SEAT = 13
USER_REPORT_V2 = 14
METRIC_BUCKET = 15
UNKNOWN = -1
# end generated

Expand Down
4 changes: 4 additions & 0 deletions relay-base-schema/src/data_category.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ pub enum DataCategory {
/// Currently standardized on name UserReportV2 to avoid clashing with the old UserReport.
/// TODO(jferg): Rename this to UserFeedback once old UserReport is deprecated.
UserReportV2 = 14,
/// Metric bucket.
MetricBucket = 15,
//
// IMPORTANT: After adding a new entry to DataCategory, go to the `relay-cabi` subfolder and run
// `make header` to regenerate the C-binding. This allows using the data category from Python.
Expand Down Expand Up @@ -93,6 +95,7 @@ impl DataCategory {
"span" => Self::Span,
"monitor_seat" => Self::MonitorSeat,
"feedback" => Self::UserReportV2,
"metric_bucket" => Self::MetricBucket,
_ => Self::Unknown,
}
}
Expand All @@ -116,6 +119,7 @@ impl DataCategory {
Self::Span => "span",
Self::MonitorSeat => "monitor_seat",
Self::UserReportV2 => "feedback",
Self::MetricBucket => "metric_bucket",
Self::Unknown => "unknown",
}
}
Expand Down
28 changes: 12 additions & 16 deletions relay-cabi/include/relay.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
/**
* Classifies the type of data that is being ingested.
*/
enum RelayDataCategory
{
enum RelayDataCategory {
/**
* Reserved and unused.
*/
Expand Down Expand Up @@ -97,6 +96,10 @@ enum RelayDataCategory
* TODO(jferg): Rename this to UserFeedback once old UserReport is deprecated.
*/
RELAY_DATA_CATEGORY_USER_REPORT_V2 = 14,
/**
* Metric bucket.
*/
RELAY_DATA_CATEGORY_METRIC_BUCKET = 15,
Copy link
Member

Choose a reason for hiding this comment

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

Note that this will require a release of the python library and bump in Sentry and Snuba.

/**
* Any other data category not known by this Relay.
*/
Expand All @@ -107,8 +110,7 @@ typedef int8_t RelayDataCategory;
/**
* Controls the globbing behaviors.
*/
enum GlobFlags
{
enum GlobFlags {
/**
* When enabled `**` matches over path separators and `*` does not.
*/
Expand All @@ -131,8 +133,7 @@ typedef uint32_t GlobFlags;
/**
* Represents all possible error codes.
*/
enum RelayErrorCode
{
enum RelayErrorCode {
RELAY_ERROR_CODE_NO_ERROR = 0,
RELAY_ERROR_CODE_PANIC = 1,
RELAY_ERROR_CODE_UNKNOWN = 2,
Expand All @@ -157,8 +158,7 @@ typedef uint32_t RelayErrorCode;
* Values from <https://github.com/open-telemetry/opentelemetry-specification/blob/8fb6c14e4709e75a9aaa64b0dbbdf02a6067682a/specification/api-tracing.md#status>
* Mapping to HTTP from <https://github.com/open-telemetry/opentelemetry-specification/blob/8fb6c14e4709e75a9aaa64b0dbbdf02a6067682a/specification/data-http.md#status>
*/
enum RelaySpanStatus
{
enum RelaySpanStatus {
/**
* The operation completed successfully.
*
Expand Down Expand Up @@ -283,8 +283,7 @@ typedef struct RelayStoreNormalizer RelayStoreNormalizer;
* - When obtained as instance through return values, always free the string.
* - When obtained as pointer through field access, never free the string.
*/
typedef struct RelayStr
{
typedef struct RelayStr {
/**
* Pointer to the UTF-8 encoded string data.
*/
Expand All @@ -308,8 +307,7 @@ typedef struct RelayStr
* - When obtained as instance through return values, always free the buffer.
* - When obtained as pointer through field access, never free the buffer.
*/
typedef struct RelayBuf
{
typedef struct RelayBuf {
/**
* Pointer to the raw data.
*/
Expand All @@ -327,8 +325,7 @@ typedef struct RelayBuf
/**
* Represents a key pair from key generation.
*/
typedef struct RelayKeyPair
{
typedef struct RelayKeyPair {
/**
* The public key used for verifying Relay signatures.
*/
Expand All @@ -342,8 +339,7 @@ typedef struct RelayKeyPair
/**
* A 16-byte UUID.
*/
typedef struct RelayUuid
{
typedef struct RelayUuid {
/**
* UUID bytes in network byte order (big endian).
*/
Expand Down
11 changes: 5 additions & 6 deletions relay-quotas/src/quota.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ impl CategoryUnit {
| DataCategory::Span
| DataCategory::MonitorSeat
| DataCategory::Monitor
| DataCategory::MetricBucket
| DataCategory::UserReportV2 => Some(Self::Count),
DataCategory::Attachment => Some(Self::Bytes),
DataCategory::Session => Some(Self::Batched),
Expand Down Expand Up @@ -295,16 +296,14 @@ impl Quota {
// Check for a scope identifier constraint. If there is no constraint, this means that the
// quota matches any scope. In case the scope is unknown, it will be coerced to the most
// specific scope later.
let scope_id = match self.scope_id {
Some(ref scope_id) => scope_id,
None => return true,
let Some(scope_id) = self.scope_id.as_ref() else {
return true;
};

// Check if the scope identifier in the quota is parseable. If not, this means we cannot
// fulfill the constraint, so the quota does not match.
let parsed = match scope_id.parse::<u64>() {
Ok(parsed) => parsed,
Err(_) => return false,
let Ok(parsed) = scope_id.parse::<u64>() else {
return false;
};

// At this stage, require that the scope is known since we have to fulfill the constraint.
Expand Down
Loading
Loading