Skip to content

fix(metrics): Enforce metric name length limit [INGEST-1205] - #1238

Merged
iker-barriocanal merged 11 commits into
masterfrom
iker/fix/metrics-conf-name-limit
Apr 27, 2022
Merged

iker-barriocanal merged 11 commits into
masterfrom
iker/fix/metrics-conf-name-limit

Conversation

@iker-barriocanal

@iker-barriocanal iker-barriocanal commented Apr 22, 2022 •

Copy link
Copy Markdown
Contributor

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:

aggregator:
  max_name_length: 200
  max_tag_key_length: 200
  max_tag_value_length: 200

Comment thread relay-metrics/src/aggregation.rs Resolved
Comment thread relay-metrics/src/aggregation.rs Outdated

let key = key
.validate_name(&self.config)
.map_err(|()| AggregateMetricsError)?;

Copy link
Copy Markdown
Member

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:

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Comment thread relay-metrics/src/aggregation.rs Resolved
@iker-barriocanal

Copy link
Copy Markdown
Contributor Author

I'll wait for #1235 to be merged, because of the dropping buckets fix and some refactoring on validation logic (readability + reduce code duplication).

@untitaker untitaker left a comment

Copy link
Copy Markdown
Member

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

Comment thread relay-metrics/src/aggregation.rs Resolved

@jan-auer jan-auer left a comment

Copy link
Copy Markdown
Member

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.

Comment thread relay-metrics/src/aggregation.rs Resolved
Comment thread relay-metrics/src/aggregation.rs Resolved
Comment thread relay-metrics/src/aggregation.rs Resolved
Comment thread relay-metrics/src/aggregation.rs Resolved
@untitaker
untitaker self-requested a review April 26, 2022 10:53
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.
@iker-barriocanal
iker-barriocanal force-pushed the iker/fix/metrics-conf-name-limit branch from 569b716 to 5fa5085 Compare April 27, 2022 14:49

@untitaker untitaker left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

perfect!

@iker-barriocanal
iker-barriocanal merged commit 10874b5 into master Apr 27, 2022
@iker-barriocanal
iker-barriocanal deleted the iker/fix/metrics-conf-name-limit branch April 27, 2022 18:14
@github-actions

Copy link
Copy Markdown
Fails
🚫 Please consider adding a changelog entry for the next release.
Instructions and example for changelog

For changes exposed to the Python package, please add an entry to py/CHANGELOG.md. This includes, but is not limited to event normalization, PII scrubbing, and the protocol.

For changes to the Relay server, please add an entry to CHANGELOG.md under the following heading:

  1. Features: For new user-visible functionality.
  2. Bug Fixes: For user-visible bug fixes.
  3. Internal: For features and bug fixes in internal operation, especially processing mode.

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.

Generated by 🚫 dangerJS against 1298620

jan-auer added a commit that referenced this pull request Apr 28, 2022
* master:
  fix(metrics): Enforce metric name length limit (#1238)
jan-auer added a commit that referenced this pull request Apr 28, 2022
* master:
  fix(metrics): Enforce metric name length limit (#1238)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants