Skip to content

ref(client): Create EnvelopeSender to wrap Transport#1139

Open
szokeasaurusrex wants to merge 2 commits into
masterfrom
szokeasaurusrex/envelope-sender
Open

ref(client): Create EnvelopeSender to wrap Transport#1139
szokeasaurusrex wants to merge 2 commits into
masterfrom
szokeasaurusrex/envelope-sender

Conversation

@szokeasaurusrex

@szokeasaurusrex szokeasaurusrex commented Jun 8, 2026

Copy link
Copy Markdown
Member

Create a new EnvelopeSender type, which wraps the client's transport.

EnvelopeSender is itself a lightweight wrapper around a TransportSlot, which itself is a replacement for TransportArc and was also introduced in this change. The TransportSlot abstracts the logic for managing whether the transport is present or not, while the EnvelopeSender abstracts away the whole transport itself.

Why the change? Previously, code in several different places (the client, the batchers, and the session flusher) interacted with the transport directly. This makes it difficult for us to ensure that any preprocessing we want to do on all envelopes before they go to the transport happens in all the places we use the transport.

With this change, we can perform any needed preprocessing in the EnvelopeSender's send_envelope implementation. We intend to use this for sending client reports; we will check in EnvelopeSender's send_envelope whether there are any pending reports, and attach them to the outgoing envelope if yes.

Contributes to #1002
Contributes to RUST-154
Closes #1155
Closes RUST-230

@linear-code

linear-code Bot commented Jun 8, 2026

Copy link
Copy Markdown

RUST-154

RUST-230

@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/envelope-sender branch 2 times, most recently from 52f0b7a to 9104579 Compare June 8, 2026 09:29
@szokeasaurusrex szokeasaurusrex marked this pull request as ready for review June 8, 2026 09:30
@szokeasaurusrex szokeasaurusrex requested a review from lcian as a code owner June 8, 2026 09:30
@szokeasaurusrex szokeasaurusrex marked this pull request as draft June 8, 2026 09:38
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/envelope-sender branch from 9104579 to 863a5b5 Compare June 8, 2026 09:45
szokeasaurusrex added a commit that referenced this pull request Jun 8, 2026
Move `batcher` under `client`, as it is only used in the `client`.

Follow up to #1139, and stacked on that PR.
@szokeasaurusrex szokeasaurusrex marked this pull request as ready for review June 8, 2026 11:27
@szokeasaurusrex szokeasaurusrex marked this pull request as draft June 8, 2026 11:42
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/envelope-sender branch from 863a5b5 to 1df01c0 Compare June 8, 2026 12:00
szokeasaurusrex added a commit that referenced this pull request Jun 8, 2026
Move `batcher` under `client`, as it is only used in the `client`.

Follow up to #1139, and stacked on that PR.
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/envelope-sender branch from 1df01c0 to b2f3e71 Compare June 9, 2026 14:15
szokeasaurusrex added a commit that referenced this pull request Jun 9, 2026
Move `batcher` under `client`, as it is only used in the `client`.

Follow up to #1139, and stacked on that PR.
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/envelope-sender branch from b2f3e71 to cef2e11 Compare June 9, 2026 14:42
szokeasaurusrex added a commit that referenced this pull request Jun 9, 2026
Move `batcher` under `client`, as it is only used in the `client`.

Follow up to #1139, and stacked on that PR.
@szokeasaurusrex szokeasaurusrex marked this pull request as ready for review June 9, 2026 14:44
@szokeasaurusrex

Copy link
Copy Markdown
Member Author

@lcian This is ready for review.

I ended up changing the EnvelopeSender constructor since yesterday. It now takes a callback which builds the transport.

In the PR which implements #1004, I'll use the callback to provide the transport constructors with the handle the transport will need to use to record losses.

Comment thread sentry-core/src/client/envelope_sender.rs

@lcian lcian left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good!

Create a new `EnvelopeSender` type, which wraps the client's transport.

`EnvelopeSender` is itself a lightweight wrapper around a `TransportSlot`, which itself is a replacement for `TransportArc` and was also introduced in this change. The `TransportSlot` abstracts the logic for managing whether the transport is present or not, while the `EnvelopeSender` abstracts away the whole transport itself.

**Why the change?** Previously, code in several different places (the client, the batchers, and the session flusher) interacted with the transport directly. This makes it difficult for us to ensure that any preprocessing we want to do on all envelopes before they go to the transport happens in all the places we use the transport.

With this change, we can perform any needed preprocessing in the `EnvelopeSender`'s `send_envelope` implementation. We intend to use this for sending client reports; we will check in `EnvelopeSender`'s `send_envelope` whether there are any pending reports, and attach them to the outgoing envelope if yes.

Contributes to [#1002](#1002)
Contributes to [RUST-154](https://linear.app/getsentry/issue/RUST-154/add-shared-client-report-aggregator-and-send-client-reports-option)
Closes [#1155](#1155)
Closes [RUST-230](https://linear.app/getsentry/issue/RUST-230)
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/envelope-sender branch from cef2e11 to 587fe93 Compare June 10, 2026 09:31
cursor[bot]

This comment was marked as resolved.

Comment thread sentry-core/src/client/mod.rs Outdated
@szokeasaurusrex szokeasaurusrex marked this pull request as draft June 10, 2026 10:56
szokeasaurusrex added a commit that referenced this pull request Jun 10, 2026
Move `batcher` under `client`, as it is only used in the `client`.

Follow up to #1139, and stacked on that PR.

Closes [#1156](#1156)
Closes [RUST-231](https://linear.app/getsentry/issue/RUST-231)
@szokeasaurusrex szokeasaurusrex marked this pull request as ready for review June 10, 2026 13:54
@szokeasaurusrex szokeasaurusrex requested a review from lcian June 10, 2026 13:54
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.

Centralize envelope sending logic in sentry-core

2 participants