Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
- Match patterns iteratively instead of recursively. ([#6188](https://github.com/getsentry/relay/pull/6188))
- Expand size of outcome quantities from `u32` to `u64`. ([#6133](https://github.com/getsentry/relay/pull/6133))
- Internally handle outcomes as metrics. ([#6107](https://github.com/getsentry/relay/pull/6107))
- Re-introduce `projects:discard-transaction` feature flag. ([#6199](https://github.com/getsentry/relay/pull/6199))
- Have relay generate metric billing outcomes. ([#6066](https://github.com/getsentry/relay/pull/6066))
- Update sentry-conventions to 0.12.0.
- Update sentry-conventions to 0.13.0. ([#6139](https://github.com/getsentry/relay/pull/6139))
Expand Down
6 changes: 6 additions & 0 deletions relay-filter/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ pub enum FilterStatKey {
/// Filtered due to the namespace being disabled.
DisabledNamespace,

/// Filtered by Relay.
///
/// This is currently only used for transactions, after spans have been extracted.
Discarded,

/// Filtered due to a generic filter.
GenericFilter(String),
}
Expand Down Expand Up @@ -73,6 +78,7 @@ impl FilterStatKey {
FilterStatKey::FilteredTransactions => "filtered-transaction",
FilterStatKey::DeniedName => "denied-name",
FilterStatKey::DisabledNamespace => "disabled-namespace",
FilterStatKey::Discarded => "discarded",
FilterStatKey::GenericFilter(filter_identifier) => {
return Cow::Owned(filter_identifier);
}
Expand Down
10 changes: 8 additions & 2 deletions relay-server/src/processing/transactions/types/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ impl Forward for TransactionOutput {
ctx: ForwardContext<'_>,
) -> Result<(), Rejected<()>> {
use crate::services::store::StoreEvent;
use relay_dynamic_config::Feature;
use relay_filter::FilterStatKey;

let (spans, transaction) = match self {
TransactionOutput::Full(managed) => {
Expand All @@ -67,7 +69,7 @@ impl Forward for TransactionOutput {

let performance_issues_spans = ctx
.project_info
.has_feature(relay_dynamic_config::Feature::PerformanceIssuesSpans);
.has_feature(Feature::PerformanceIssuesSpans);

if let Some(spans) = spans {
let event_id = transaction.headers.event_id();
Expand Down Expand Up @@ -112,7 +114,11 @@ impl Forward for TransactionOutput {
(profile, event)
});

s.send_event(event);
let discard_transactions = ctx.project_info.has_feature(Feature::DiscardTransaction);
match discard_transactions {
false => s.send_event(event),
true => drop(event.reject_err(Outcome::Filtered(FilterStatKey::Discarded))),
}
Comment thread
Dav1dde marked this conversation as resolved.

if let Some(profile) = profile.transpose() {
s.send_to_store(profile.map(|p, _| store::convert_profile(p, true, ctx)));
Comment thread
Dav1dde marked this conversation as resolved.
Expand Down
38 changes: 36 additions & 2 deletions tests/integration/test_spans.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

TEST_CONFIG = {
"aggregator": {
"bucket_interval": 1,
"initial_delay": 0,
"shift_key": "none",
}
}
Expand Down Expand Up @@ -1070,6 +1068,42 @@ def summarize_outcomes():
assert span_usage_metric() == 2


def test_discard_transaction(
mini_sentry,
relay_with_processing,
transactions_consumer,
spans_consumer,
outcomes_consumer,
):
transactions_consumer = transactions_consumer()
spans_consumer = spans_consumer()
outcomes_consumer = outcomes_consumer()

project_id = 42
project_config = mini_sentry.add_full_project_config(project_id)
project_config["config"].setdefault("features", []).append(
"projects:discard-transaction"
)

relay = relay_with_processing(options=TEST_CONFIG)

start = datetime.now(timezone.utc)
end = start + timedelta(seconds=1)

relay.send_envelope(project_id, envelope_with_transaction_and_spans(start, end))

# We have one nested span and the transaction itself becomes a span
spans = spans_consumer.get_spans(n=2)
assert len(spans) == 2

outcomes = outcomes_consumer.get_outcomes()
assert [(o["category"], o["outcome"], o["reason"]) for o in outcomes] == [
(9, 1, "discarded"), # TransactionIndexed, Filtered
]

transactions_consumer.assert_empty()


def test_span_filtering_with_generic_inbound_filter(
mini_sentry, relay_with_processing, spans_consumer, outcomes_consumer
):
Expand Down
Loading