-
Notifications
You must be signed in to change notification settings - Fork 85
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): Add ability to compute metrics summary and attach it to events #3769
Conversation
/// Merges a [`MetricsSummary`] into itself. | ||
/// | ||
/// The merge operation concatenates tags of the same metric even if they are identical for the | ||
/// sake of simplicity. This doesn't cause issues for us, under the assumption that the two | ||
/// summaries do not have overlapping metric names (which is the case for us since summaries | ||
/// computed by the SDKs have metric names that are different from the ones we generate in | ||
/// Relay). | ||
/// | ||
/// Do not use this function to merge any arbitrary [`MetricsSummary`]s. |
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.
I am not happy about this comment, open for suggestions.
if buckets.is_empty() { | ||
return None; | ||
} |
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.
Small optimization to avoid creating an aggregator with nothing inside.
} | ||
|
||
/// Computes the [`MetricsSummary`] from a slice of [`Bucket`]s. | ||
pub fn compute(buckets: &[Bucket]) -> Option<MetricsSummary> { |
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 add a form of option or feature flag that controls whether this code should actually run. A global flag would be absolutely sufficient, though it would be useful to have the ability to control this per organization/project. Choose based on what's more straight forward to integrate.
.filter(|b| matches!(b.name.namespace(), MetricNamespace::Custom)); | ||
|
||
let aggregator = MetricsSummaryAggregator::from_buckets(filtered_buckets); | ||
if aggregator.is_empty() { |
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.
We do the check in the aggregator directly so that we avoid collecting the filtered buckets into a vector just for the sake of determining the size before calling from_buckets
.
This PR introduces functionality to compute metric summaries from a slice of
Bucket
s, adhering to the semantics currently used in our SDKs.The motivation for this change stems from our decision to discontinue metric emission from SDKs, instead extracting them in Relay through specified configurations. Without this update, the current Relay implementation would compromise the product experience, as it cannot extract metric summaries from event-derived metrics. This PR addresses and resolves this limitation.
Currently, metrics summaries are computed only for metrics belonging to the
custom
namespace.Closes: getsentry/sentry#73152