Silence Rails deprecation warnings on production
What does this MR do and why?
This MR silences Rails deprecation warnings on production
for the regular case where logging is not enabled via GITLAB_LOG_DEPRECATIONS=1
. Prior this commit production
used :silence
(changed from :notify
in !92557 (merged)) for deprecation warnings which is a no-op for the non-logging case.
This MR uses silenced = true
which more performant than just setting behavior = :silence
. See #368294 (comment 1032244810)
Logging to log/deprecation_json.log
in production
can be enabled with GITLAB_LOG_DEPRECATIONS=1
.
It also fixes a bug where logging to log/deprecation_json.log
wasn't working for development
by default or even with GITLAB_LOG_DEPRECATIONS=1
set.
See individual commit messages for more details.
Closes #368294 (closed)
See #368379 (closed) for a follow-up to use config.active_support.report_deprecations = false
in Rails 7.
How to set up and validate locally
Development
Run GDK and observe log/deprecation_json.log
to contain entries when, for example, viewing incident issues.
Production
truncate -s0 log/deprecation_json.log
gdk start db
git revert ab474c1d # See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/91833
RAILS_ENV=production GITLAB_LOG_DEPRECATIONS=1 rails server --port 3000
curl http://127.0.0.1:3000/-/offline
tail log/deprecation_json.log
{"severity":"INFO","time":"2022-08-02T20:30:25.059Z","correlation_id":"e4a67ed1-8533-4e89-b9af-5c9a0a67f789","message":"DEPRECATION WARNING: Rendering actions with '.' in the name is deprecated: shared/_logo.svg (called from block in _app_views_pwa_offline_html_haml__2028873475759949455_357240 at /home/peter/devel/gitlab/gdk/gitlab/app/views/pwa/offline.html.haml:2)","source":"rails"}
{"severity":"INFO","time":"2022-08-02T20:30:25.059Z","correlation_id":"e4a67ed1-8533-4e89-b9af-5c9a0a67f789","message":"DEPRECATION WARNING: Rendering actions with '.' in the name is deprecated: shared/_logo.svg (called from block in _app_views_pwa_offline_html_haml__2028873475759949455_357240 at /home/peter/devel/gitlab/gdk/gitlab/app/views/pwa/offline.html.haml:2)","source":"rails"}
{"severity":"INFO","time":"2022-08-02T20:30:25.186Z","correlation_id":"97964e59-3c1c-454a-9a4b-a91918fd61f1","message":"DEPRECATION WARNING: The asset \"no_avatar.png\" is not present in the asset pipeline.\nFalling back to an asset that may be in the public folder.\nThis behavior is deprecated and will be removed.\nTo bypass the asset pipeline and preserve this behavior,\nuse the `skip_pipeline: true` option.\n (called from default_avatar_url at /home/peter/devel/gitlab/gdk/gitlab/lib/gitlab/gon_helper.rb:97)","source":"rails"}
{"severity":"INFO","time":"2022-08-02T20:30:25.187Z","correlation_id":"97964e59-3c1c-454a-9a4b-a91918fd61f1","message":"DEPRECATION WARNING: The asset \"gitlab_logo.png\" is not present in the asset pipeline.\nFalling back to an asset that may be in the public folder.\nThis behavior is deprecated and will be removed.\nTo bypass the asset pipeline and preserve this behavior,\nuse the `skip_pipeline: true` option.\n (called from add_gon_variables at /home/peter/devel/gitlab/gdk/gitlab/lib/gitlab/gon_helper.rb:29)","source":"rails"}
{"severity":"INFO","time":"2022-08-02T20:30:25.187Z","correlation_id":"97964e59-3c1c-454a-9a4b-a91918fd61f1","message":"DEPRECATION WARNING: The asset \"file_icons.svg\" is not present in the asset pipeline.\nFalling back to an asset that may be in the public folder.\nThis behavior is deprecated and will be removed.\nTo bypass the asset pipeline and preserve this behavior,\nuse the `skip_pipeline: true` option.\n (called from sprite_file_icons_path at /home/peter/devel/gitlab/gdk/gitlab/app/helpers/icons_helper.rb:29)","source":"rails"}
{"severity":"INFO","time":"2022-08-02T20:30:25.188Z","correlation_id":"97964e59-3c1c-454a-9a4b-a91918fd61f1","message":"DEPRECATION WARNING: The asset \"emoji_sprites.css\" is not present in the asset pipeline.\nFalling back to an asset that may be in the public folder.\nThis behavior is deprecated and will be removed.\nTo bypass the asset pipeline and preserve this behavior,\nuse the `skip_pipeline: true` option.\n (called from add_gon_variables at /home/peter/devel/gitlab/gdk/gitlab/lib/gitlab/gon_helper.rb:33)","source":"rails"}
{"severity":"INFO","time":"2022-08-02T20:30:25.188Z","correlation_id":"97964e59-3c1c-454a-9a4b-a91918fd61f1","message":"DEPRECATION WARNING: The asset \"lazy_bundles/select2.css\" is not present in the asset pipeline.\nFalling back to an asset that may be in the public folder.\nThis behavior is deprecated and will be removed.\nTo bypass the asset pipeline and preserve this behavior,\nuse the `skip_pipeline: true` option.\n (called from add_gon_variables at /home/peter/devel/gitlab/gdk/gitlab/lib/gitlab/gon_helper.rb:34)","source":"rails"}
...
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.