Skip to content

Commit 431f58b

Browse files
authored
ref(relay): Reduce warnings, emit warnings to Sentry (#4753)
Warnings generated based on invalid user input are useless, we cannot control it and they are usually not actionable. All warnings that are outside the path of user input are kept. Also promotes these warnings to Sentry issues, so they become actionable.
1 parent ab28ea7 commit 431f58b

File tree

9 files changed

+25
-12
lines changed

9 files changed

+25
-12
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
- Allow environment references in Relay configuration. ([#4750](https://github.com/getsentry/relay/pull/4750))
88

9+
**Internal**:
10+
11+
- Reduce warning logs, emit warnings to the configured Sentry instance. ([#4753](https://github.com/getsentry/relay/pull/4753))
12+
913
## 25.5.0
1014

1115
**Features**:

relay-log/src/setup.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use std::str::FromStr;
77
use std::sync::Arc;
88

99
use relay_common::impl_str_serde;
10+
use sentry::integrations::tracing::EventFilter;
1011
use sentry::types::Dsn;
1112
use sentry::{TracesSampler, TransactionContext};
1213
use serde::{Deserialize, Serialize};
@@ -327,7 +328,15 @@ pub unsafe fn init(config: &LogConfig, sentry: &SentryConfig) {
327328

328329
tracing_subscriber::registry()
329330
.with(format.with_filter(config.level_filter()))
330-
.with(sentry::integrations::tracing::layer())
331+
.with(
332+
// Same as the default filter, except it converts warnings into events instead of breadcrumbs.
333+
sentry::integrations::tracing::layer().event_filter(|md| match *md.level() {
334+
tracing::Level::ERROR => EventFilter::Exception,
335+
tracing::Level::WARN => EventFilter::Event,
336+
tracing::Level::INFO => EventFilter::Breadcrumb,
337+
tracing::Level::DEBUG | tracing::Level::TRACE => EventFilter::Ignore,
338+
}),
339+
)
331340
.with(match env::var(EnvFilter::DEFAULT_ENV) {
332341
Ok(value) => EnvFilter::new(value),
333342
Err(_) => get_default_filters(),

relay-pii/src/attachments.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ trait StringMods: AsRef<[u8]> {
177177
Redaction::Replace(replace) => {
178178
self.swap_content(replace.text.as_str(), PADDING);
179179
}
180-
Redaction::Other => relay_log::warn!("Incoming redaction is not supported"),
180+
Redaction::Other => relay_log::debug!("Incoming redaction is not supported"),
181181
}
182182
}
183183
}

relay-pii/src/processor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ fn insert_replacement_chunks(rule: &RuleRef, text: &str, output: &mut Vec<Chunk<
568568
text: Cow::Owned(replace.text.clone()),
569569
});
570570
}
571-
Redaction::Other => relay_log::warn!("Incoming redaction is not supported"),
571+
Redaction::Other => relay_log::debug!("Incoming redaction is not supported"),
572572
}
573573
}
574574

relay-profiling/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ pub fn parse_metadata(payload: &[u8], project_id: ProjectId) -> Result<ProfileId
176176
let profile = match minimal_profile_from_json(payload) {
177177
Ok(profile) => profile,
178178
Err(err) => {
179-
relay_log::warn!(
179+
relay_log::debug!(
180180
error = &err as &dyn Error,
181181
from = "minimal",
182182
project_id = project_id.value(),
@@ -190,7 +190,7 @@ pub fn parse_metadata(payload: &[u8], project_id: ProjectId) -> Result<ProfileId
190190
let _: sample::v1::ProfileMetadata = match serde_path_to_error::deserialize(d) {
191191
Ok(profile) => profile,
192192
Err(err) => {
193-
relay_log::warn!(
193+
relay_log::debug!(
194194
error = &err as &dyn Error,
195195
from = "metadata",
196196
platform = profile.platform,
@@ -235,7 +235,7 @@ pub fn expand_profile(
235235
let profile = match minimal_profile_from_json(payload) {
236236
Ok(profile) => profile,
237237
Err(err) => {
238-
relay_log::warn!(
238+
relay_log::debug!(
239239
error = &err as &dyn Error,
240240
from = "minimal",
241241
platform = event.platform.as_str(),
@@ -273,7 +273,7 @@ pub fn expand_profile(
273273
Ok(payload) => Ok((profile.event_id, payload)),
274274
Err(err) => match err {
275275
ProfileError::InvalidJson(err) => {
276-
relay_log::warn!(
276+
relay_log::debug!(
277277
error = &err as &dyn Error,
278278
from = "parsing",
279279
platform = profile.platform,

relay-server/src/services/processor/attachment.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ fn scrub_minidump(item: &mut crate::envelope::Item, config: &relay_pii::PiiConfi
106106
timer(RelayTimers::MinidumpScrubbing) = start.elapsed(),
107107
status = "error"
108108
);
109-
relay_log::warn!(
109+
relay_log::debug!(
110110
error = &scrub_error as &dyn Error,
111111
"failed to scrub minidump",
112112
);
@@ -143,7 +143,7 @@ fn scrub_view_hierarchy(item: &mut crate::envelope::Item, config: &relay_pii::Pi
143143
item.set_payload(content_type, output);
144144
}
145145
Err(e) => {
146-
relay_log::warn!(error = &e as &dyn Error, "failed to scrub view hierarchy",);
146+
relay_log::debug!(error = &e as &dyn Error, "failed to scrub view hierarchy",);
147147
metric!(
148148
timer(RelayTimers::ViewHierarchyScrubbing) = start.elapsed(),
149149
status = "error"

relay-server/src/services/processor/replay.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ fn handle_replay_event_item(
168168
}
169169
}
170170
Err(error) => {
171-
relay_log::warn!(
171+
relay_log::debug!(
172172
error = &error as &dyn Error,
173173
event_id = ?config.event_id,
174174
project_id = config.project_id.map(|v| v.value()),

relay-server/src/services/store.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ impl StoreService {
776776

777777
// If the recording payload can not fit in to the message do not produce and quit early.
778778
if payload_size >= max_payload_size {
779-
relay_log::warn!("replay_recording over maximum size.");
779+
relay_log::debug!("replay_recording over maximum size.");
780780
self.outcome_aggregator.send(TrackOutcome {
781781
category: DataCategory::Replay,
782782
event_id,

tests/integration/fixtures/mini_sentry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ def store_internal_error_event():
308308
if (
309309
event is not None
310310
and sentry.fail_on_relay_error
311-
and event.get("level") != "info"
311+
and event.get("level") not in ("info", "warning")
312312
):
313313
error = AssertionError("Relay sent us event: " + get_error_message(event))
314314
sentry.test_failures.put(("/api/666/envelope/", error))

0 commit comments

Comments
 (0)