-
Notifications
You must be signed in to change notification settings - Fork 94
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(server): Forward metrics in proxy mode #3106
Conversation
relay-server/src/services/project.rs
Outdated
if let Some(scoping) = self.partial_scoping() { | ||
let mut bucket_map = HashMap::new(); | ||
bucket_map.insert(scoping.project_key, buckets); | ||
project_cache.send(FlushBuckets { |
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.
skipped the aggregator for simplicity because it checks for scoping from projectstate and also features in rate_limit_and_merge_buckets
.
i wasnt sure if we should also skip handle_flush_buckets
? it checks if it's ratelimited, do we care about ratelimiting in proxy mode?
tests/integration/test_metrics.py
Outdated
@@ -62,6 +62,52 @@ def metrics_by_name_group_by_project(metrics_consumer, timeout=None): | |||
return metrics_by_project | |||
|
|||
|
|||
def test_metrics_proxy_mode(mini_sentry, relay): |
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.
this test fails without the changes in this PR
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.
Nice! See comment about missing condition.
@@ -234,6 +234,15 @@ impl ProcessingGroup { | |||
)) | |||
} | |||
|
|||
let is_metric = |i: &Item| matches!(i.ty(), ItemType::Statsd | ItemType::MetricBuckets); |
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.
Might be worth adding metrics meta to the integration test as well:
let is_metric = |i: &Item| matches!(i.ty(), ItemType::Statsd | ItemType::MetricBuckets); | |
let is_metric = |i: &Item| matches!(i.ty(), ItemType::Statsd | ItemType::MetricBuckets | ItemType::MetricMeta); |
We could add a is_metrics()
method to ItemType
and use it in queue_envelope
and here.
tests/integration/test_metrics.py
Outdated
project_id = 42 | ||
|
||
timestamp = int(datetime.now(tz=timezone.utc).timestamp()) | ||
metrics_payload = f"transactions/foo:42|c\ntransactions/bar:17|c|T{timestamp}" |
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 also add a buckets payload and a metrics meta payload.
project_key: envelope.meta().public_key(), | ||
}) | ||
// Remove metric meta from the envelope and send them directly to processing. | ||
let metric_meta = envelope.take_items_by(|item| matches!(item.ty(), ItemType::MetricMeta)); |
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.
Nice! We didn't forget about metric meta.
should fix: #3042
Problem was we're not able to send metrics through without scoping from the projectstate, but in proxy mode the projectstate isn't available for non-static projects.
This PR simply skips the aggregation pipeline for metrics in proxy mode and send it to processing instead, which for metric groups does nothing and simply forwards it to upstream.