prometheus-client-forty_two 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bc067c4e5cb499b06381dada99d0842962c36fd8
4
- data.tar.gz: 7f90d73d1b28855a5fee646516083cb0058b3a2c
3
+ metadata.gz: 6c4bc147bee233e29db294634058d41c43bfb2f5
4
+ data.tar.gz: d4e9b265fdb84f084ac67ebbd501d704e32d8d6a
5
5
  SHA512:
6
- metadata.gz: 2e1d67d3105b916709b76117facb652e95de5899dbd7fb5cbfc95433997e1263890b26143da4cad29de168550b940ba0479a679b88f926638c50f9d4a779eeca
7
- data.tar.gz: eca8947fa25b3358c38425e42c36357319ab409a1edef2d3f024957f47b53a3d3487c0d1cc1c3e4e452faf2dc5f7e0c8cb805e07139292f301a16ada827fd1d3
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 @static_files.include?(env['PATH_INFO'])
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)
@@ -1,5 +1,5 @@
1
1
  module Prometheus
2
2
  module FortyTwo
3
- VERSION = '0.1.1'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
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.1.1
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-01-29 00:00:00.000000000 Z
11
+ date: 2021-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prometheus-client