Skip to content

Commit

Permalink
Merge pull request #318 from alphagov/switch-default-aggregation
Browse files Browse the repository at this point in the history
Default to Prometheus histograms, not summaries
  • Loading branch information
richardTowers committed Sep 14, 2023
2 parents b9ec948 + d13c747 commit eec4ec5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Next

* Default to Prometheus histograms, not summaries ([#318](https://github.com/alphagov/govuk_app_config/pull/318))

# 9.1.0

* GovukAppConfig silences OpenTelemetry log output when running a rake task ([#311](https://github.com/alphagov/govuk_app_config/pull/311))
Expand Down
15 changes: 11 additions & 4 deletions lib/govuk_app_config/govuk_prometheus_exporter.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
require "prometheus_exporter"
require "prometheus_exporter/metric"
require "prometheus_exporter/server"
require "prometheus_exporter/middleware"

module GovukPrometheusExporter
def self.should_configure
# Allow us to force the Prometheus Exporter for persistent Rake tasks...
Expand All @@ -11,12 +16,14 @@ def self.should_configure
end
end

def self.configure(collectors: [])
def self.configure(collectors: [], default_aggregation: PrometheusExporter::Metric::Histogram)
return unless should_configure

require "prometheus_exporter"
require "prometheus_exporter/server"
require "prometheus_exporter/middleware"
# PrometheusExporter::Metric::Histogram.DEFAULT_BUCKETS tops out at 10 but
# we have a few controller actions which are slower than this, so we add a
# few extra buckets for slower requests
PrometheusExporter::Metric::Histogram.default_buckets = [0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10, 15, 25, 50].freeze
PrometheusExporter::Metric::Base.default_aggregation = default_aggregation

if defined?(Sidekiq)
Sidekiq.configure_server do |config|
Expand Down

0 comments on commit eec4ec5

Please sign in to comment.