2024-11-20 16:00:24 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2025-09-29 16:27:07 -04:00
|
|
|
# Initialize Prometheus exporter for web processes, but exclude console, rake tasks, and tests
|
|
|
|
|
should_initialize = DawarichSettings.prometheus_exporter_enabled? &&
|
|
|
|
|
!Rails.env.test? &&
|
|
|
|
|
!defined?(Rails::Console) &&
|
|
|
|
|
!File.basename($PROGRAM_NAME).include?('rake')
|
|
|
|
|
|
|
|
|
|
if should_initialize
|
2024-11-20 06:02:31 -05:00
|
|
|
require 'prometheus_exporter/middleware'
|
2024-11-20 11:16:26 -05:00
|
|
|
require 'prometheus_exporter/instrumentation'
|
2024-11-20 06:02:31 -05:00
|
|
|
|
|
|
|
|
# This reports stats per request like HTTP status and timings
|
|
|
|
|
Rails.application.middleware.unshift PrometheusExporter::Middleware
|
|
|
|
|
|
2024-12-04 09:00:28 -05:00
|
|
|
# This reports basic process stats like RSS and GC info
|
2024-11-20 16:00:24 -05:00
|
|
|
PrometheusExporter::Instrumentation::Process.start(type: 'web')
|
|
|
|
|
|
|
|
|
|
# Add ActiveRecord instrumentation
|
|
|
|
|
PrometheusExporter::Instrumentation::ActiveRecord.start
|
2024-11-20 06:02:31 -05:00
|
|
|
end
|