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

metrics(processor): emit counter for feedback screenshots #3603

Merged
merged 17 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions relay-server/src/services/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1496,6 +1496,7 @@ impl EnvelopeProcessorService {
if state.has_event() {
event::scrub(state)?;
event::serialize(state)?;
event::emit_feedback_metrics(state.envelope());
}

attachment::scrub(state);
Expand Down
22 changes: 21 additions & 1 deletion relay-server/src/services/processor/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use relay_quotas::DataCategory;
use relay_statsd::metric;
use serde_json::Value as SerdeValue;

use crate::envelope::{AttachmentType, ContentType, Item, ItemType};
use crate::envelope::{AttachmentType, ContentType, Envelope, Item, ItemType};
use crate::extractors::RequestMeta;
use crate::services::outcome::Outcome;
use crate::services::processor::{
Expand Down Expand Up @@ -420,6 +420,26 @@ pub fn has_unprintable_fields(event: &Annotated<Event>) -> bool {
}
}

//TODO: comment
//TODO: add test: all incr/no incr cases, envelope unchanged
aliu39 marked this conversation as resolved.
Show resolved Hide resolved
pub fn emit_feedback_metrics(envelope: &Envelope) -> i64 {
aliu39 marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

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

Why does this function return the count? To make it testable?

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed the return value since we're ok with no tests

let mut has_feedback = false;
let mut num_attachments = 0;
for item in envelope.items() {
match item.ty() {
ItemType::UserReportV2 => has_feedback = true,
ItemType::Attachment => num_attachments += 1,
_ => (),
}
}
if has_feedback && num_attachments > 0 {
metric!(counter(RelayCounters::FeedbackAttachments) += num_attachments);
num_attachments
} else {
0
}
}

/// Checks for duplicate items in an envelope.
///
/// An item is considered duplicate if it was not removed by sanitation in `process_event` and
Expand Down
5 changes: 5 additions & 0 deletions relay-server/src/statsd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,9 @@ pub enum RelayCounters {
/// Counter for when the DSC is missing from an event that comes from an SDK that should support
/// it.
MissingDynamicSamplingContext,
/// The number of attachments processed in the same envelope as a user_report_v2 event.
#[cfg(feature = "processing")]
FeedbackAttachments,
}

impl CounterMetric for RelayCounters {
Expand Down Expand Up @@ -720,6 +723,8 @@ impl CounterMetric for RelayCounters {
#[cfg(feature = "processing")]
RelayCounters::TransactionsFromSpans => "transactions_from_spans",
RelayCounters::MissingDynamicSamplingContext => "missing_dynamic_sampling_context",
#[cfg(feature = "processing")]
RelayCounters::FeedbackAttachments => "processing.feedback_attachments",
Copy link
Member Author

Choose a reason for hiding this comment

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

open to other names

}
}
}
Expand Down
Loading