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): Actually batch by partition, set request header [INGEST-1562] #1440

Merged
merged 6 commits into from
Aug 31, 2022

Conversation

jjbayer
Copy link
Member

@jjbayer jjbayer commented Aug 30, 2022

Convert the dry run implemented in #1425 into an actual batching mechanism that splits metrics buckets into logical partitions.

The partition_key has to be passed through ProjectCache, EnvelopeManager and UpstreamRelay to be set as a header on the outgoing envelope request.

fut.spawn(context);
}
});
let num_partitions = self.config.flush_partitions.unwrap_or(1);
Copy link
Member Author

Choose a reason for hiding this comment

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

This means that we always set the X-Sentry-Relay-Shard header, even though no partitioning was requested by config. We could easily change this behavior but I thought this would keep the code nice and simple.

@@ -554,6 +554,10 @@ impl UpstreamRelay {
}
}

if let Some(partition_key) = request.request.partition_key() {
builder.header("X-Sentry-Relay-Shard", partition_key);
Copy link
Member Author

Choose a reason for hiding this comment

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

TODO: Decide on the actual name for the header.

Copy link
Member Author

Choose a reason for hiding this comment

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

Going with X-Sentry-Relay-Shard. The proposal mentions X-Relay-Shard, but other headers we set also start with X-Sentry-Relay-.

@@ -66,6 +66,7 @@ pub struct SendEnvelope {
pub http_encoding: HttpEncoding,
pub response_sender: Option<oneshot::Sender<Result<(), SendEnvelopeError>>>,
pub project_key: ProjectKey,
partition_key: Option<String>,
Copy link
Member Author

Choose a reason for hiding this comment

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

Having a String here means that other envelopes could theoretically use the same header with a different partitioning strategy.

@jjbayer jjbayer marked this pull request as ready for review August 30, 2022 15:30
@jjbayer jjbayer requested a review from a team August 30, 2022 15:30
Copy link
Member

@untitaker untitaker left a comment

Choose a reason for hiding this comment

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

PR looks fine, all i commented are nits. let's do a careful canary deploy tomorrow

relay-server/src/actors/upstream.rs Outdated Show resolved Hide resolved
@@ -353,6 +362,7 @@ impl fmt::Debug for SendMetrics {
.field("buckets", &self.buckets)
Copy link
Member

Choose a reason for hiding this comment

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

@jan-auer any idea why we don't use derive(Debug) 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.

I think we couldn't because SendMetrics used to hold an Addr<Project>. Now that Project is not an actor anymore, and this struct only holds a ProjectKey, I think we can use derive(Debug).

relay-metrics/src/aggregation.rs Show resolved Hide resolved
@jjbayer jjbayer merged commit 14d431f into master Aug 31, 2022
@jjbayer jjbayer deleted the feat/metrics-logical-partitions branch August 31, 2022 07:34
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.

None yet

2 participants