sentry: exclude the debug log from breadcrumbs
The sentry_logger hook turns every DebugLogger line into a
breadcrumb, and breadcrumbs ride the per-request transaction
envelope without passing SentryScrubber — so debug dumps of card
content were reaching Sentry.
Assisted-by: GLM-5.3 via pi
diff --git a/config.ru b/config.ru
index 8e2d59f..15c6682 100644
--- a/config.ru
+++ b/config.ru
@@ -36,6 +36,13 @@ Sentry.init do |sentry|
# locally either way, see ProTacts::UnhandledRequests.
sentry.before_send = ProTacts::SentryScrubber
+ # The debug log is a local-only record of full exchanges, bodies and
+ # all. Sentry's sentry_logger hook would otherwise turn every one of
+ # its lines into a breadcrumb, and breadcrumbs reach Sentry without
+ # passing the scrubber above. Keyed on the progname DebugLogger#write
+ # passes with each line.
+ sentry.exclude_loggers = [ProTacts::DebugLogger::PROGNAME]
+
sentry.traces_sample_rate = 1.0
end
diff --git a/lib/pro_tacts/debug_logger.rb b/lib/pro_tacts/debug_logger.rb
index 2a4b8e0..211ea64 100644
--- a/lib/pro_tacts/debug_logger.rb
+++ b/lib/pro_tacts/debug_logger.rb
@@ -15,6 +15,13 @@ module ProTacts
# @rbs @app: Rack::_App
# @rbs @logger: Logger
+ # Identifies this logger's lines to Sentry's sentry_logger
+ # breadcrumb hook, which keys its exclude list on the progname
+ # (see config.ru). Every line here is a local-only record of a
+ # full exchange — bodies included — so none of it may ride to
+ # Sentry as a breadcrumb, where SentryScrubber would never see it.
+ PROGNAME = "ProTacts::DebugLogger" #: String
+
# Builds the Logger the middleware writes to: appended and unbuffered
# (Logger syncs its own device), one timestamped line per dump. path
# "stderr" writes to the process's stderr.
@@ -125,7 +132,11 @@ module ProTacts
#: (String prefix, String text) -> void
def write(prefix, text)
text.to_s.lines(chomp: true).each do |line|
- @logger.debug("#{prefix} #{line}")
+ # The progname form (block for the message) is what carries
+ # PROGNAME to Logger#add, where Sentry's hook reads it; the
+ # custom formatter ignores it, so the log's format is
+ # unchanged.
+ @logger.debug(PROGNAME) { "#{prefix} #{line}" }
end
end
end