prometheus-client-forty_two 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/prometheus/forty_two/collector.rb +25 -1
- data/lib/prometheus/forty_two/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c4bc147bee233e29db294634058d41c43bfb2f5
|
4
|
+
data.tar.gz: d4e9b265fdb84f084ac67ebbd501d704e32d8d6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bdf083ed635a9fc8a27668083bf8caf8fae6052957ea2be430fbc772e18bbae5b3b543351bc0883a8607bf614a9a4d2f8ce771d8206569fafaea2e944e9ee38
|
7
|
+
data.tar.gz: fad11cd1f7643b1309bc974f559ccba1809b495aee74fd29c698d15c0d79c0c562a7d2e78b7cef24f910efe49da6117e71ff93492772f4a54b25d0adb87ec5c7
|
@@ -48,16 +48,30 @@ module Prometheus
|
|
48
48
|
# )
|
49
49
|
#
|
50
50
|
# # all routes pointing to /public will be ignored
|
51
|
+
#
|
52
|
+
#
|
53
|
+
# Some of your app routes might not be relevant to your stats either
|
54
|
+
# (ie. /metrics, or /assets/**/* paths). Set the `:irrelevant_paths`
|
55
|
+
# option to provide a method that will match paths you want to ignore.
|
56
|
+
#
|
57
|
+
# use(
|
58
|
+
# Prometheus::Client::FortyTwo::Middleware::Collector,
|
59
|
+
# irrelevant_paths: labmda { |path|
|
60
|
+
# path == '/metrics' ||
|
61
|
+
# path =~ %r{\A/assets/}
|
62
|
+
# }
|
63
|
+
# )
|
51
64
|
class Collector < Prometheus::Middleware::Collector
|
52
65
|
def initialize(app, options = {})
|
53
66
|
super
|
54
67
|
|
55
68
|
@static_files = self.class.find_static_files(options[:static_files_path])
|
69
|
+
@irrelevant_paths = options[:irrelevant_paths] || ->(_path) { false }
|
56
70
|
@specific_id_stripper = options[:specific_id_stripper] || ->(path) { path }
|
57
71
|
end
|
58
72
|
|
59
73
|
def call(env)
|
60
|
-
return @app.call(env) if
|
74
|
+
return @app.call(env) if ignore_path?(env['PATH_INFO'])
|
61
75
|
|
62
76
|
super
|
63
77
|
end
|
@@ -73,6 +87,16 @@ module Prometheus
|
|
73
87
|
end
|
74
88
|
end
|
75
89
|
|
90
|
+
def ignore_path?(path)
|
91
|
+
@static_files.include?(path) || irrelevant_path?(path)
|
92
|
+
end
|
93
|
+
|
94
|
+
def irrelevant_path?(path)
|
95
|
+
@irrelevant_paths.call(path)
|
96
|
+
rescue StandardError
|
97
|
+
false
|
98
|
+
end
|
99
|
+
|
76
100
|
class << self
|
77
101
|
def find_static_files(path)
|
78
102
|
find_static_files!(path)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prometheus-client-forty_two
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michel Belleville
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: prometheus-client
|