Skip to content

Commit

Permalink
instr(server): Log transactions with attachments (#4397)
Browse files Browse the repository at this point in the history
Get a list of distinct org IDs for transactions with attachments.
  • Loading branch information
jjbayer authored Dec 17, 2024
1 parent 06b174a commit fc69800
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
25 changes: 24 additions & 1 deletion relay-server/src/endpoints/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,12 +416,35 @@ fn emit_envelope_metrics(envelope: &Envelope) {
);
}

// BEGIN temporary
if has_transaction && has_attachment {
metric!(
counter(RelayCounters::TransactionsWithAttachments) += 1,
sdk = client_name.name(),
)
);
relay_log::with_scope(
|scope| {
// Set the organization as user so we can figure out who uses this.
scope.set_user(Some(relay_log::sentry::User {
id: Some(
envelope
.meta()
.get_partial_scoping()
.organization_id
.to_string(),
),
..Default::default()
}));
},
|| {
relay_log::sentry::capture_message(
"transaction with attachment",
relay_log::sentry::Level::Info,
);
},
);
}
// END temporary
}

#[derive(Debug)]
Expand Down
6 changes: 5 additions & 1 deletion tests/integration/fixtures/mini_sentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,11 @@ def store_internal_error_event():
envelope = Envelope.deserialize(flask_request.data)
event = envelope.get_event()

if event is not None and sentry.fail_on_relay_error:
if (
event is not None
and sentry.fail_on_relay_error
and event.get("level") != "info"
):
error = AssertionError("Relay sent us event: " + get_error_message(event))
sentry.test_failures.put(("/api/666/envelope/", error))

Expand Down

0 comments on commit fc69800

Please sign in to comment.