Skip to content

feat(logs): support for capture_* config#1077

Open
solnic wants to merge 5 commits into
masterfrom
feat/logs-capture-config
Open

feat(logs): support for capture_* config#1077
solnic wants to merge 5 commits into
masterfrom
feat/logs-capture-config

Conversation

@solnic

@solnic solnic commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

This adds support for configuring the log handler error capturing - which is different from sending error logs and crashes.

Two new options are added go :logs config:

  • capture_log_messages - toggle capturing on / off
  • capture_level - the log level for capturing (distinct from logs.level config)
  • capture_metadata - which metadata is accepted when capturing log messages
  • capture_excluded_domains - which logging domains must be excluded when capturing log messages

This is the first step towards deprecating the original Sentry.LoggerBackend as Sentry.LoggerHandler is replacing it, handling both structured logging and capturing logs as Sentry events.


Refs #1036

@solnic solnic force-pushed the feat/logs-capture-config branch 2 times, most recently from fe54e9f to d030abf Compare June 15, 2026 12:36
@solnic

solnic commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator Author

@PJUllrich would that be a good solution in your case? 😄

@PJUllrich

Copy link
Copy Markdown
Contributor

@solnic yes, I think so! Thank you! ❤️💚💛💜💙❤️

@solnic solnic force-pushed the feat/logs-capture-config branch from d030abf to e071445 Compare June 24, 2026 08:23
@solnic solnic marked this pull request as ready for review June 26, 2026 09:22
Comment thread lib/sentry/application.ex Outdated
Comment thread lib/sentry/application.ex
capture_log_messages: Config.logs_capture_log_messages?(),
metadata: Config.logs_capture_metadata(),
excluded_domains: Config.logs_capture_excluded_domains()
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Capture level filters crash reports

Medium Severity

The auto-attached handler always sets its level from logs.capture_level, and ErrorBackend drops any log event below that threshold before crash handling runs. That means a capture_level above typical crash severities (e.g. :critical) can suppress crash reporting, even when capture_log_messages is false or the docs describe crashes as always on and capture_level as applying only to captured log messages.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 60941f7. Configure here.

@solnic solnic force-pushed the feat/logs-capture-config branch from 60941f7 to eabaea9 Compare June 26, 2026 13:53

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit eabaea9. Configure here.

Comment thread lib/sentry/application.ex
# settings reach the ErrorBackend, whose options are frozen at attach time and would
# otherwise stay stale across the restart.
auto_logger_handler_registered?() ->
_ = :logger.update_handler_config(:sentry_log_handler, :config, handler_config)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Restart resets handler options

Medium Severity

When the auto :sentry_log_handler survives a :sentry restart, re-sync calls :logger.update_handler_config/3 with only the four capture-related keys. Sentry.LoggerHandler.changing_config/3 validates that map through the full NimbleOptions schema, so omitted options are filled with defaults and overwrite existing handler settings such as :rate_limiting, :sync_threshold, and :tags_from_metadata.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit eabaea9. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants