Skip to content

Replace logger with sdk_logger #2621

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
May 12, 2025
Merged

Conversation

solnic
Copy link
Collaborator

@solnic solnic commented May 7, 2025

This is in preparation for #2604 - we have an internal Sentry.logger used for warn/error/debug logging with the SDK but with Structured Logging feature we're introducing a public-facing Sentry.logger API, so our internal one needs to be renamed.

@solnic solnic force-pushed the 2604-rename-logger-to-sdk_logger branch from b88e62b to b384b24 Compare May 7, 2025 08:50
@solnic solnic marked this pull request as ready for review May 7, 2025 08:50
@solnic solnic requested a review from sl0thentr0py May 7, 2025 08:51
@solnic solnic force-pushed the 2604-rename-logger-to-sdk_logger branch from b384b24 to 99870e5 Compare May 7, 2025 12:03
@solnic solnic mentioned this pull request May 7, 2025
@solnic solnic requested a review from st0012 May 7, 2025 12:07
@@ -615,11 +624,6 @@ def sys_command(command)
result.strip
end

# @!visibility private
def logger
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not blocking: Although we marked it as private in docs, it's still very accessible to users. So I'd suggest keeping it like:

def logger
  print_deprecation_message_to_ask_users_not_to_use_it
  configuration.sdk_logger
end

Then at least some users of it can have time to move off of it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@st0012 so, this is tricky - in #2600 we're adding Sentry.logger interface, so it is not going to be deprecated, but it will be enabled conditionally based on config._experiments[:enable_logs]. What we could do is printing deprecation message only if enabled_logs is not true - WDYT? The message would say something like "Starting with 5.{version_where_we_enable_logging_by_default} Sentry.logger will become public API for structured logging feature"

Copy link
Member

Choose a reason for hiding this comment

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

sorry late to the convo, we can also go for Sentry::Logger with module level methods instead of Sentry.logger if we want to keep the old one unchanged..

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@sl0thentr0py I think there's no way around that - IF there are people who use Sentry.logger, then we gotta let them know via deprecation warning that this logger is changing its purpose. I'm not sure how changing to Sentry::Logger class methods would help?

Copy link
Member

Choose a reason for hiding this comment

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

we still deprecate but all the new stuff would go to Sentry:: Logger and Sentry.logger would stay what it was for now till next major

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@sl0thentr0py oh I see. So instead of config.sdk_logger we switch to global Sentry::Logger and deprecate original config.logger behavior. Yeah this makes perfect sense. It would simplify LoggingHelper and a bunch of constructors. One question though - in sentry-rails we actually set the logger to a duped Rails.logger, what would happen with this if we want to switch to Sentry::Logger and remove configurable logger?

Copy link
Member

@sl0thentr0py sl0thentr0py May 9, 2025

Choose a reason for hiding this comment

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

ok let me be clearer,

about the internal SDK logging:

  • config.logger stays but deprecated
  • config.sdk_logger comes and replaces config.logger

--

Now, everything about the new Sentry Logging Feature goes under a completely new namespace Sentry::Logging.do_something (not Sentry::Logger since that's also taken) and NOT Sentry.logger.do_something

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Now, everything about the new Sentry Logging Feature goes under a completely new namespace Sentry::Logging.do_something (not Sentry::Logger since that's also taken) and NOT Sentry.logger.do_something

I don't think it's a good idea as it would diverge from the naming convention from other SDKs where we already have Sentry.logger - also, it's just much nicer and intuitive vs Sentry::Logging.

What would be the benefit of going with Sentry::Logging? The way I see it is that we just need to deal with the deprecation cycle of config.logger / Sentry.logger being used as an internal logging facility and eventually replace it with the new logging stuff.

Please remember that initially we are going to release new logging with _experiments[:enable_logger] config option, so the users will have to make a deliberate choice to enable it and we can simply add docs/release notes + maybe even extra warning on init, that say that when this is enabled, then config.logger / Sentry.logger is no longer the same thing and if the user relies on it, then they should basically stop doing that as it was always meant to be used solely as an internal SDK logger.

Copy link
Member

Choose a reason for hiding this comment

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

resolved in slack, we will show deprecation and do the switch based on the config

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@st0012 @sl0thentr0py I re-added Sentry.logger method via cb55544 and it has a deprecation warning now:

Screenshot 2025-05-12 at 15 03 36

@solnic solnic force-pushed the 2604-rename-logger-to-sdk_logger branch from 99870e5 to 3fe77a6 Compare May 8, 2025 07:50
@solnic solnic requested a review from st0012 May 8, 2025 09:30
@solnic solnic requested a review from sl0thentr0py May 12, 2025 13:32
@solnic solnic merged commit 63b5162 into master May 12, 2025
135 of 136 checks passed
@solnic solnic deleted the 2604-rename-logger-to-sdk_logger branch May 12, 2025 14:03
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.

4 participants