-
Notifications
You must be signed in to change notification settings - Fork 91
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
ref(server): Transform EnvelopeManager into a sequential pipeline #1416
Conversation
11d2d7f
to
453b92d
Compare
453b92d
to
190fb73
Compare
598f674
to
def67d4
Compare
* master: feat(server): Garbage collector thread for project cache eviction (#1410)
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.
Guide for Reviewers: Start in endpoints/common.rs
and then follow the messages QueueEnvelope
-> ValidateEnvelope
-> AddSamplingState
-> ProcessEnvelope
-> SubmitEnvelope
.
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.
Great stuff!
context.notify(HandleEnvelope { | ||
envelope: event_envelope, | ||
envelope_context: event_context, | ||
ProjectCache::from_registry().do_send(ValidateEnvelope::new( |
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.
What would be super-nice is a diagram with Actors and Messages and how they changed. I would even volunteer to draw it :)
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.
👍 much appreciated. One of the follow-ups mentioned in the description includes updating the documentation, which contains a graph that would need updating: https://getsentry.github.io/relay/relay_server/index.html#sequence-diagram-of-components-inside-relay
Co-authored-by: Floris Bruynooghe <flub@sentry.io>
The QueueEnvelope message no longer needs to reside on the EnvelopeManager since #1416. Instead, it has become a simple dispatch function that calls ProcessMetrics and ValidateEnvelope directly on the target actors. To skip a redundant message, this PR removes this message entirely and moves its code into the endpoint handler code. The BufferGuard has moved into utilities. There is no expected change in behavior or performance, although there could be a slight decrease in latency since the endpoint no longer has to wait for this actor.
Removes the long-running handler future in EnvelopeManager, and instead pass envelopes through explicit queues the ingestion stages. Actual error handling is now localized in every step of the pipeline.
This helps to improve Relay's response time when buffering requests.
Endpoint
The store endpoint handler remains unchanged. It calls the same messages and eventually invokes
QueueEnvelope
. That message splits up the Envelope and immediately sends it to theProjectCache
. In a follow-up, this can be moved directly into the endpoint, theEnvelopeManager
is no longer needed for this.Project Cache Queues
The biggest change is within the
ProjectCache
and projects. Instead of responding toCheckEnvelope
, the projects now take ownership of envelopes and put them into queues if they are not up-to-date. The precise sequence is:ValidateEnvelope
message. If the project state is valid, this immediately validates and forwards the envelopes to the next stage (see 3). Otherwise, put them on a local queue on the project.update_state
on the project, which flushes the queues of pending envelopes. This is guaranteed to run eventually, if project fetching fails or times out.AddSamplingState
. Otherwise, directly forward to processing (step 5).ProcessEnvelope
to the envelope processor, along with the project states.Remaining Queueing
Control flow of the remaining pipeline steps did not change:
ProcessEnvelope
to theEnvelopeProcessor
.EnvelopeManager
with a new messageSubmitEnvelope
. This message runs the final dispatch between HTTP upstream (SendEnvelope
), Kafka (StoreEnvelope
), or capturing (Capture
).Drop Guards
There are now 3 places where futures can be dropped, which are individually monitored:
Drop
implementation that logs how many events have been dropped. In normal operation, only empty projects are evicted from the cache.EnvelopeProcessor
does not have any drop guarding. This is complicated to achieve, and the processor's queues are usually near empty. We can introduce a drop guard when migrating the processor to tokio.SubmitEnvelope
still features the former drop guarded future.Resources
Prepared by:
Follow-ups:
CheckEnvelope
andProcessEnvelope
.QueueEnvelope
message and instead invoke this as function directly in the endpoint handler.EnvelopeContext
intoProcessingError
, clean up metrics emission, and improve control flow.update_state
.relay-server
.#skip-changelog