You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
1010 B

  1. return if Rails.application.tailwind_watcher?
  2. RailsSemanticLogger::Rack::Logger.logger.level = :info # useful for remaining log like "[Rack::Log] Started..."
  3. SemanticLogger.clear_appenders!
  4. return unless Rails.application.server?
  5. def build_instrumentation_config
  6. {
  7. action_controller: true,
  8. action_view: Live::Constants::ACTION_VIEW
  9. # active_record: Live::Constants::ACTIVE_RECORD
  10. }.map do |key, value|
  11. key if value
  12. end.compact
  13. end
  14. Rails.configuration.after_initialize do
  15. Rails.logger.name = 'rails'
  16. ActiveSupport::Notifications.subscribe('rolling.live_constant') do |event|
  17. constants = event.payload[:changes].map { |change| change[:constant] }
  18. if constants.intersection(%w[ACTIVE_RECORD ACTION_VIEW]).any?
  19. Semantic::Instrumentalizer.activate(*build_instrumentation_config)
  20. end
  21. end
  22. end
  23. Rails.autoloaders.main.on_load('ApplicationController') do
  24. Rails.logger.debug 'Zeitwerk RELOAD!'
  25. Semantic::Instrumentalizer.activate(*build_instrumentation_config)
  26. end