chore: refactor
This commit is contained in:
@@ -15,14 +15,6 @@ Sidekiq.configure_server do |config|
|
||||
config[:skip_default_job_logging] = true
|
||||
config.logger.level = Logger.const_get(ENV.fetch('LOG_LEVEL', 'info').upcase.to_s)
|
||||
end
|
||||
|
||||
# CloudWatch metrics for monitoring
|
||||
if ChatwootApp.chatwoot_cloud? && ENV['ENABLE_SIDEKIQ_CLOUDWATCH'].present?
|
||||
require 'sidekiq/cloudwatchmetrics'
|
||||
config.server_middleware do |chain|
|
||||
chain.add Sidekiq::CloudWatchMetrics::ServerMiddleware
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# https://github.com/ondrejbartas/sidekiq-cron
|
||||
|
||||
@@ -1,37 +1,17 @@
|
||||
if defined?(Sidekiq::CloudWatchMetrics) && ChatwootApp.chatwoot_cloud?
|
||||
Sidekiq::CloudWatchMetrics.configure do |config|
|
||||
# AWS region for CloudWatch
|
||||
config.aws_region = ENV.fetch('AWS_REGION', 'us-east-1')
|
||||
if defined?(Sidekiq::CloudWatchMetrics) && defined?(ChatwootApp) && ChatwootApp.chatwoot_cloud? && ENV['ENABLE_SIDEKIQ_CLOUDWATCH'].present?
|
||||
require 'sidekiq/cloudwatchmetrics'
|
||||
|
||||
# Namespace for metrics in CloudWatch
|
||||
config.namespace = ENV.fetch('SIDEKIQ_CLOUDWATCH_NAMESPACE', 'Chatwoot/Sidekiq')
|
||||
|
||||
# Additional dimensions to add to all metrics
|
||||
config.additional_dimensions = {
|
||||
Environment: Rails.env,
|
||||
Application: 'Chatwoot'
|
||||
}
|
||||
|
||||
# Enable detailed queue metrics
|
||||
config.enable_queue_metrics = true
|
||||
|
||||
# Enable job class metrics
|
||||
config.enable_job_class_metrics = true
|
||||
|
||||
# Publishing interval (in seconds)
|
||||
config.publish_interval = ENV.fetch('SIDEKIQ_CLOUDWATCH_INTERVAL', '60').to_i
|
||||
|
||||
# Enable/disable specific metric types
|
||||
config.enabled_metrics = %w[
|
||||
processed
|
||||
failed
|
||||
busy
|
||||
enqueued
|
||||
scheduled
|
||||
retry_set_size
|
||||
dead_set_size
|
||||
default_queue_latency
|
||||
queues
|
||||
]
|
||||
# Configure AWS region if specified
|
||||
if ENV['AWS_REGION'].present?
|
||||
require 'aws-sdk-cloudwatch'
|
||||
client = Aws::CloudWatch::Client.new(region: ENV['AWS_REGION'])
|
||||
else
|
||||
client = nil # Use default client (EC2 instance role or env credentials)
|
||||
end
|
||||
|
||||
Sidekiq::CloudWatchMetrics.enable!(
|
||||
client: client,
|
||||
namespace: ENV.fetch('SIDEKIQ_CLOUDWATCH_NAMESPACE', 'Chatwoot/Sidekiq'),
|
||||
interval: ENV.fetch('SIDEKIQ_CLOUDWATCH_INTERVAL', '60').to_i
|
||||
)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user