govuk_app_config 9.1.0 → 9.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +1 -1
- data/CHANGELOG.md +8 -0
- data/govuk_app_config.gemspec +1 -1
- data/lib/govuk_app_config/govuk_prometheus_exporter.rb +50 -6
- data/lib/govuk_app_config/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91aa874fe05081ba23cdf6d37cb9046b357fe1d20d79ec3c336877a3e75e2edc
|
4
|
+
data.tar.gz: eff73c0ebf947cd2adb0c8bd37599c5bae85497db9c3942621b2178465c586de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fcf73e2e1bcf53b466918e89fd23b2083e02dc7d9e8dd4333021db40f46a3d9774d52079c443d204bc00b0d09547e5be83c0f824611f532fc90a786f07cfe8f4
|
7
|
+
data.tar.gz: b0ffcd15e23557623c9749eb925ec52ffa867558769da1cb13cd9d52e275e1201576c5c1d040ce9d90b80af5a7848452bd43ffe8d59d328bfdbed4029781f4b4
|
data/.github/workflows/ci.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
# 9.3.0
|
2
|
+
|
3
|
+
* Get prometheus labels from controller, not params ([#320](https://github.com/alphagov/govuk_app_config/pull/320))
|
4
|
+
|
5
|
+
# 9.2.0
|
6
|
+
|
7
|
+
* Default to Prometheus histograms, not summaries ([#318](https://github.com/alphagov/govuk_app_config/pull/318))
|
8
|
+
|
1
9
|
# 9.1.0
|
2
10
|
|
3
11
|
* GovukAppConfig silences OpenTelemetry log output when running a rake task ([#311](https://github.com/alphagov/govuk_app_config/pull/311))
|
data/govuk_app_config.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
|
23
23
|
spec.add_dependency "logstasher", "~> 2.1"
|
24
24
|
spec.add_dependency "opentelemetry-exporter-otlp", ">= 0.25", "< 0.27"
|
25
|
-
spec.add_dependency "opentelemetry-instrumentation-all", ">= 0.39.1", "< 0.
|
25
|
+
spec.add_dependency "opentelemetry-instrumentation-all", ">= 0.39.1", "< 0.51.0"
|
26
26
|
spec.add_dependency "opentelemetry-sdk", "~> 1.2"
|
27
27
|
spec.add_dependency "plek", ">= 4", "< 6"
|
28
28
|
spec.add_dependency "prometheus_exporter", "~> 2.0"
|
@@ -1,4 +1,46 @@
|
|
1
|
+
require "prometheus_exporter"
|
2
|
+
require "prometheus_exporter/metric"
|
3
|
+
require "prometheus_exporter/server"
|
4
|
+
require "prometheus_exporter/middleware"
|
5
|
+
|
1
6
|
module GovukPrometheusExporter
|
7
|
+
#
|
8
|
+
# See https://github.com/discourse/prometheus_exporter/pull/293
|
9
|
+
#
|
10
|
+
# RailsMiddleware can be removed and replaced with the default middleware if
|
11
|
+
# that PR is merged / released
|
12
|
+
#
|
13
|
+
class RailsMiddleware < PrometheusExporter::Middleware
|
14
|
+
def default_labels(env, _result)
|
15
|
+
controller_instance = env["action_controller.instance"]
|
16
|
+
action = controller = nil
|
17
|
+
if controller_instance
|
18
|
+
action = controller_instance.action_name
|
19
|
+
controller = controller_instance.controller_name
|
20
|
+
elsif (cors = env["rack.cors"]) && cors.respond_to?(:preflight?) && cors.preflight?
|
21
|
+
# if the Rack CORS Middleware identifies the request as a preflight request,
|
22
|
+
# the stack doesn't get to the point where controllers/actions are defined
|
23
|
+
action = "preflight"
|
24
|
+
controller = "preflight"
|
25
|
+
end
|
26
|
+
{
|
27
|
+
action: action || "other",
|
28
|
+
controller: controller || "other",
|
29
|
+
}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class SinatraMiddleware < PrometheusExporter::Middleware
|
34
|
+
def default_labels(_env, _result)
|
35
|
+
# The default prometheus exporter middleware uses the controller and
|
36
|
+
# action as labels. These aren't meaningful in Sinatra applications, and
|
37
|
+
# other options (such as request.path_info) have potentially very high
|
38
|
+
# cardinality. For now, just accept that we can't be more specific than
|
39
|
+
# the application / pod and don't provide any other labels
|
40
|
+
{}
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
2
44
|
def self.should_configure
|
3
45
|
# Allow us to force the Prometheus Exporter for persistent Rake tasks...
|
4
46
|
if ENV["GOVUK_PROMETHEUS_EXPORTER"] == "force"
|
@@ -11,12 +53,14 @@ module GovukPrometheusExporter
|
|
11
53
|
end
|
12
54
|
end
|
13
55
|
|
14
|
-
def self.configure(collectors: [])
|
56
|
+
def self.configure(collectors: [], default_aggregation: PrometheusExporter::Metric::Histogram)
|
15
57
|
return unless should_configure
|
16
58
|
|
17
|
-
|
18
|
-
|
19
|
-
|
59
|
+
# PrometheusExporter::Metric::Histogram.DEFAULT_BUCKETS tops out at 10 but
|
60
|
+
# we have a few controller actions which are slower than this, so we add a
|
61
|
+
# few extra buckets for slower requests
|
62
|
+
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
|
63
|
+
PrometheusExporter::Metric::Base.default_aggregation = default_aggregation
|
20
64
|
|
21
65
|
if defined?(Sidekiq)
|
22
66
|
Sidekiq.configure_server do |config|
|
@@ -43,11 +87,11 @@ module GovukPrometheusExporter
|
|
43
87
|
server.start
|
44
88
|
|
45
89
|
if defined?(Rails)
|
46
|
-
Rails.application.middleware.unshift
|
90
|
+
Rails.application.middleware.unshift RailsMiddleware, instrument: :prepend
|
47
91
|
end
|
48
92
|
|
49
93
|
if defined?(Sinatra)
|
50
|
-
Sinatra.use
|
94
|
+
Sinatra.use SinatraMiddleware
|
51
95
|
end
|
52
96
|
rescue Errno::EADDRINUSE
|
53
97
|
warn "Could not start Prometheus metrics server as address already in use."
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govuk_app_config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 9.
|
4
|
+
version: 9.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GOV.UK Dev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logstasher
|
@@ -53,7 +53,7 @@ dependencies:
|
|
53
53
|
version: 0.39.1
|
54
54
|
- - "<"
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version: 0.
|
56
|
+
version: 0.51.0
|
57
57
|
type: :runtime
|
58
58
|
prerelease: false
|
59
59
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -63,7 +63,7 @@ dependencies:
|
|
63
63
|
version: 0.39.1
|
64
64
|
- - "<"
|
65
65
|
- !ruby/object:Gem::Version
|
66
|
-
version: 0.
|
66
|
+
version: 0.51.0
|
67
67
|
- !ruby/object:Gem::Dependency
|
68
68
|
name: opentelemetry-sdk
|
69
69
|
requirement: !ruby/object:Gem::Requirement
|
@@ -375,7 +375,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
375
375
|
- !ruby/object:Gem::Version
|
376
376
|
version: '0'
|
377
377
|
requirements: []
|
378
|
-
rubygems_version: 3.4.
|
378
|
+
rubygems_version: 3.4.20
|
379
379
|
signing_key:
|
380
380
|
specification_version: 4
|
381
381
|
summary: Base configuration for GOV.UK applications
|