Browse Source

puma OK, but no log.debug in syslog

main
pvincent 3 months ago
parent
commit
1ae22612f7
  1. 5
      app/controllers/scores_controller.rb
  2. 12
      config/initializers/instrumentalizing.rb
  3. 49
      config/puma.rb
  4. 1
      lib/semantic/instrumentalizer.rb

5
app/controllers/scores_controller.rb

@ -8,9 +8,12 @@ class ScoresController < ApplicationController
logger.info('inside controller2')
logger.info("multiline1\nmultiline2\nmultiline3")
logger.info('this is an info')
logger.debug('this is a debug')
logger.warn('this is a warning')
logger.error('this is an error')
# logger.fatal('this is a fatal')
logger.fatal('this is a fatal')
@q = Score.all.ransack(q_params)
@pagy, @scores = pagy(@q.result)
end

12
config/initializers/instrumentalizing.rb

@ -14,23 +14,17 @@ def build_instrumentation_config
end
Rails.configuration.after_initialize do
SemanticLogger.clear_appenders!
RailsSemanticLogger::Rack::Logger.logger.level = :info # useful for remaining log like "[Rack::Log] Started..."
Rails.logger.name = 'rails'
if Rails.env.production?
SemanticLogger.add_appender(
appender: :syslog,
formatter: Rails.application.config.x.semantic.formatter.constantize.new
)
Rails.logger.info('adding instrumentations...')
formatter = Rails.application.config.x.semantic.formatter.constantize.new
SemanticLogger.add_appender(appender: :syslog, formatter:)
Semantic::Instrumentalizer.activate(*build_instrumentation_config)
Rails.logger.info('adding instrumentations...DONE', build_instrumentation_config)
else
SemanticLogger.clear_appenders!
SemanticLogger.add_appender(
io: $stdout,
formatter: Rails.application.config.x.semantic.formatter.constantize.new

49
config/puma.rb

@ -2,38 +2,37 @@
# are invoked here are part of Puma's configuration DSL. For more information
# about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html.
# Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers: a minimum and maximum.
# Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum; this matches the default thread size of Active Record.
max_threads_count = ENV.fetch('RAILS_MAX_THREADS', 5)
min_threads_count = ENV.fetch('RAILS_MIN_THREADS') { max_threads_count }
threads min_threads_count, max_threads_count
# Specifies that the worker count should equal the number of processors in production.
if ENV['RAILS_ENV'] == 'production'
require 'concurrent-ruby'
worker_count = Integer(ENV.fetch('WEB_CONCURRENCY') { Concurrent.physical_processor_count })
workers worker_count if worker_count > 1
end
# Specifies the `worker_timeout` threshold that Puma will use to wait before
# terminating a worker in development environments.
worker_timeout 3600 if ENV.fetch('RAILS_ENV', 'development') == 'development'
# Puma starts a configurable number of processes (workers) and each process
# serves each request in a thread from an internal thread pool.
#
# The ideal number of threads per worker depends both on how much time the
# application spends waiting for IO operations and on how much you wish to
# to prioritize throughput over latency.
#
# As a rule of thumb, increasing the number of threads will increase how much
# traffic a given process can handle (throughput), but due to CRuby's
# Global VM Lock (GVL) it has diminishing returns and will degrade the
# response time (latency) of the application.
#
# The default is set to 3 threads as it's deemed a decent compromise between
# throughput and latency for the average Rails application.
#
# Any libraries that use a connection pool or another resource pool should
# be configured to provide at least as many connections as the number of
# threads. This includes Active Record's `pool` parameter in `database.yml`.
threads_count = ENV.fetch('RAILS_MAX_THREADS', 3)
threads threads_count, threads_count
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
port ENV.fetch('PORT', 3000)
# Specifies the `environment` that Puma will run in.
environment ENV.fetch('RAILS_ENV') { 'development' }
# Specifies the `pidfile` that Puma will use.
pidfile ENV.fetch('PIDFILE') { 'tmp/pids/server.pid' }
# Allow puma to be restarted by `bin/rails restart` command.
plugin :tmp_restart
# Specify the PID file. Defaults to tmp/pids/server.pid in development.
# In other environments, only set the PID file if requested.
pidfile ENV['PIDFILE'] if ENV['PIDFILE']
on_booted do
# puts '********************* PUMA: booted **********************'

1
lib/semantic/instrumentalizer.rb

@ -60,6 +60,7 @@ module Semantic
end
global_subscribers << subscriber
end
# logger.info("event_group #{event_group} is enabled!")
end
def build_log_subscriber_from(event_group)

Loading…
Cancel
Save