-
Notifications
You must be signed in to change notification settings - Fork 93
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
fix(metrics): Enforce metric name length limit [INGEST-1205] #1238
Conversation
relay-metrics/src/aggregation.rs
Outdated
@@ -1055,6 +1074,10 @@ impl Aggregator { | |||
let timestamp = key.timestamp; | |||
let project_key = key.project_key; | |||
|
|||
let key = key | |||
.validate_name(&self.config) | |||
.map_err(|()| AggregateMetricsError)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please double check my reasoning, but I think returning an AggregateMetricsError
here causes the entire batch of buckets to fail:
relay/relay-metrics/src/aggregation.rs
Lines 1134 to 1143 in 043479f
pub fn merge_all<I>( | |
&mut self, | |
project_key: ProjectKey, | |
buckets: I, | |
) -> Result<(), AggregateMetricsError> | |
where | |
I: IntoIterator<Item = Bucket>, | |
{ | |
for bucket in buckets.into_iter() { | |
self.merge(project_key, bucket)?; |
Not sure what the best solution is, either swallow the error here or change merge_all
to swallow the error there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah right. fwiw that bogus code came from https://github.com/getsentry/relay/pull/1235/files#diff-9bce334fb404ce42d375eab0d36d6bb5d79f4d373c8c92c02f8a70dfea0cc1d8R1083
i'm gonna play around with this a bit and see
I'll wait for #1235 to be merged, because of the dropping buckets fix and some refactoring on validation logic (readability + reduce code duplication). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
feel free to merge after fixing the comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's rebase this on top of #1235 once that is merged.
The more checks a BucketKey has the more overwhelmed the method would be. Separated into smaller and more concise methods. The metric name is validated first because failing means dropping the bucket. Tags are checked afterward.
This option defines the maximum length of a metric, not the length of the tags' keys and values. Since this value is going to be used mostly to compare strings, making it `usize` instead of any other integer size, for convenience.
569b716
to
5fa5085
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perfect!
Instructions and example for changelogFor changes exposed to the Python package, please add an entry to For changes to the Relay server, please add an entry to
To the changelog entry, please add a link to this PR (consider a more descriptive message): - Enforce metric name length limit. ([#1238](https://github.com/getsentry/relay/pull/1238)) If none of the above apply, you can opt out by adding #skip-changelog to the PR description. |
* master: fix(metrics): Enforce metric name length limit (#1238)
* master: fix(metrics): Enforce metric name length limit (#1238)
Discard metrics with too-long names before aggregating them to buckets. A metric name and its tags' keys and values are too long if they exceed the 200-byte threshold.
These limits are configurable in the
config.yml
: