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(client-reports): Protocol support for client reports #1074

Merged
merged 12 commits into from
Sep 8, 2021

Conversation

mitsuhiko
Copy link
Member

@mitsuhiko mitsuhiko commented Sep 3, 2021

This adds support for client reports from the SDKs. This feature is primarily used to allow client SDKs to emit outcomes.

The way this is currently implemented is that we add a new envelope item type called client_report which contains these outcomes. The envelope item type is intentionally kept flexible for future expansion as we already discussed emitting other internal debug information upstream which is unrelated to outcomes (eg: number of breadcrumbs discarded and configuration errors).

Because of how SDKs are currently implemented we now reserve internal as data category for such metric items. Relay however will never emit such a data category as we do not want to communicate actual rate limits for such envelope items.

From the relay perspective any outcome reason that an SDK emits is acceptable and upstreamed. It's up to the snuba consumer to whitelist these outcomes to avoid writing bad data into the kafka topic. This way SDKs can send more outcomes even if relays have not been updated.

Refs INGEST-343

@mitsuhiko
Copy link
Member Author

This assumption is likely very wrong now:

        fn started(&mut self, context: &mut Self::Context) {
            // Set the mailbox size to the size of the envelope buffer. This is a rough estimate but
            // should ensure that we're not dropping outcomes unintentionally.
            let mailbox_size = self.config.envelope_buffer_size() as usize;
            context.set_mailbox_capacity(mailbox_size);

@@ -1451,6 +1454,11 @@ impl Config {
self.values.limits.max_attachments_size.as_bytes()
}

/// Returns the maxmium combined size of client reports in bytes.
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure if we want this config flag, but if we do, we probably need to document it.

@@ -84,7 +84,7 @@ pub struct TrackOutcome {
/// The event's data category.
pub category: DataCategory,
/// The number of events or total attachment size in bytes.
pub quantity: usize,
pub quantity: u32,
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'm changing this to u32 because we do not actually permit anything larger than a u32 on the kafka topic or it will fatally fail in the consumer.

quantity: limit.quantity,
// XXX: on the limiter we have quantity of usize, but in the protocol
// and data store we're limited to u32.
quantity: limit.quantity as u32,
Copy link
Member Author

Choose a reason for hiding this comment

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

Since I only changed it on the protocol to a u32 we have a few of these now which are just suboptimal casts.

@mitsuhiko mitsuhiko marked this pull request as ready for review September 4, 2021 21:12
@mitsuhiko mitsuhiko requested a review from a team September 4, 2021 21:12
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.

I have some concerns about how DataCategory=0 is redefined and also wonder why you define it that way in Relay if it's never going to be emitted or consumed over the wire from/to Relay.

I also am scared of building something here that fundamentally cannot be rate-limited. We can have a killswitch in Relay to drop those client reports, but they have to pass through Relay to be detected, can't be dropped on LB and SDKs will not honor 429 on them even if we decide to emit any, as far as I understand.

@mitsuhiko mitsuhiko requested a review from untitaker September 8, 2021 11:22
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.

I think my comment about validation being in internal/processing Relays vs Snuba still applies. Again I would like us to consider doing this validation in Relay, we can still have the same exact validation we have in Snuba running in processing relays exclusively.

We have the same pattern for most kinds of data validation, and where we don't (enums in eg event schema) we actually know it to be a problem.

We discussed some stuff on the call about truncation and there was the valid argument that all relays will still have to truncate values, but I think that's fine and doesn't change anything here.

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.

approving to unblock but again I'm really not happy with how this is designed

@mitsuhiko mitsuhiko merged commit bf9710d into master Sep 8, 2021
@mitsuhiko mitsuhiko deleted the feature/client-reports branch September 8, 2021 14:16
@untitaker untitaker restored the feature/client-reports branch September 8, 2021 16:53
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.

2 participants