diff --git a/Gemfile b/Gemfile index 9296044c0..566fc6326 100644 --- a/Gemfile +++ b/Gemfile @@ -48,6 +48,7 @@ gem "yabeda-puma-plugin" gem "yabeda-rails" gem "webrick" # required for yabeda-prometheus metrics server gem "prometheus-client-mmap", "~> 1.1" +gem "autotuner" # AI gem "ruby_llm", git: "https://github.com/crmne/ruby_llm.git" diff --git a/Gemfile.lock b/Gemfile.lock index 43573d68c..40533f653 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -170,6 +170,7 @@ GEM anyway_config (2.7.2) ruby-next-core (~> 1.0) ast (2.4.3) + autotuner (1.0.2) aws-eventstream (1.4.0) aws-partitions (1.1170.0) aws-sdk-core (3.233.0) @@ -606,6 +607,7 @@ PLATFORMS DEPENDENCIES activerecord-tenanted activeresource + autotuner aws-sdk-s3 bcrypt (~> 3.1.7) bootsnap diff --git a/config.ru b/config.ru index ad1fbf295..1f2743ba3 100644 --- a/config.ru +++ b/config.ru @@ -2,5 +2,7 @@ require_relative 'config/environment' +use Autotuner::RackPlugin + run Rails.application Rails.application.load_server diff --git a/config/initializers/autotuner.rb b/config/initializers/autotuner.rb new file mode 100644 index 000000000..84b4de8de --- /dev/null +++ b/config/initializers/autotuner.rb @@ -0,0 +1,24 @@ +# Enable autotuner. Alternatively, call Autotuner.sample_ratio= with a value +# between 0 and 1.0 to sample on a portion of instances. +Autotuner.enabled = true + +# This callback is called whenever a suggestion is provided by this gem. +# You can output this report to your logging pipeline, stdout, a file, +# or somewhere else! +Autotuner.reporter = proc do |report| + Rails.logger.info "GCAUTOTUNE: #{report}" + Sentry.capture_message "Autotuner suggestion", level: :info, extra: { report: report.to_s } +end + +# # This (optional) callback is called to provide metrics that can give you +# # insights about the performance of your app. It's recommended to send this +# # data to your observability service (e.g. Datadog, Prometheus, New Relic, etc). +# # Use a metric type that would allow you to calculate the average and percentiles. +# # On Datadog this would be the distribution type. On Prometheus this would be +# # the histogram type. +# Autotuner.metrics_reporter = proc do |metrics| +# # stats is a hash of metric name (string) to integer value. +# metrics.each do |key, val| +# StatsD.gauge(key, val) +# end +# end