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(metrics): Route to different aggregators #2341

Merged
merged 17 commits into from
Jul 25, 2023
Merged

Conversation

jjbayer
Copy link
Member

@jjbayer jjbayer commented Jul 21, 2023

Place a router in front of the relay_metrics::Aggregator service, to allow different aggregator configurations for different use cases. This will allow us to

  1. change the bucket interval for span metrics from 10 seconds to 1 minute to improve aggregation,
  2. (potentially) set a different maximum length for tag values for span metrics.

Old:

flowchart LR
    Service -->|metrics| Aggregator
Loading

New:

flowchart LR
   Service -->|metrics| Router
   Router -->|metrics| agg_d["Aggregator (default)"]
   Router -->|metrics| agg_1["Aggregator (spans)"]
Loading

.map(|mri| mri.namespace)
.ok()
});
// TODO: Parse MRI only once, move validation from Aggregator here.
Copy link
Member Author

Choose a reason for hiding this comment

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

Will take care of this in a follow-up.

@jjbayer jjbayer marked this pull request as ready for review July 24, 2023 09:49
@jjbayer jjbayer requested a review from a team July 24, 2023 09:49
}
});
});
relay_statsd::metric!(
Copy link
Contributor

Choose a reason for hiding this comment

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

really wish github would show it in another color if only the indentation changed

Aggregator::InsertMetrics(msg) => self.handle_metrics(msg),
Aggregator::MergeBuckets(msg) => self.handle_metrics(msg),
#[cfg(test)]
Aggregator::BucketCountInquiry(_, _sender) => (), // not supported
Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose this is fine because the tests will simply use the aggregator service directly?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah it's not ideal, but acceptable IMO because this message is only used in one test.

Copy link
Contributor

@TBS1996 TBS1996 left a comment

Choose a reason for hiding this comment

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

Reading through it, it makes sense to me and seems pretty clever. Although I'm not that confident to know I didn't miss any details since most my effort was on understanding it as a whole

Co-authored-by: Tor <tor.saebjoernsen@sentry.io>
@jjbayer jjbayer merged commit 00178e7 into master Jul 25, 2023
@jjbayer jjbayer deleted the feat/metrics-router branch July 25, 2023 08:40
jjbayer added a commit that referenced this pull request Jul 25, 2023
We currently shift the flush time of each metrics bucket by an offset
based on the project key. This prevents large peaks every interval, but
still allows flushing buckets from the same projects together, which
makes sense especially when the buckets are then sent to the upstream in
per-project envelopes.

With span metrics, we have seen that even buckets from the same project
can cause a lot of traffic. With
#2341, we want to increase the
bucket interval for span metrics to one minute. To prevent large,
project-specific peaks for span metrics, allow configuring a more random
distribution over time.

This should be used only in processing Relays where buckets are sent via
Kafka.
jjbayer added a commit that referenced this pull request Jul 26, 2023
Follow-up to #2341:

Now that span metrics can have their own configuration, use the correct
one to trim span descriptions.
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.

2 participants