prometheus-client 1.0.0 → 4.1.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/LICENSE +201 -0
 - data/README.md +147 -63
 - data/lib/prometheus/client/data_stores/README.md +1 -1
 - data/lib/prometheus/client/data_stores/direct_file_store.rb +63 -25
 - data/lib/prometheus/client/histogram.rb +41 -11
 - data/lib/prometheus/client/label_set_validator.rb +10 -4
 - data/lib/prometheus/client/metric.rb +30 -10
 - data/lib/prometheus/client/push.rb +126 -12
 - data/lib/prometheus/client/registry.rb +4 -4
 - data/lib/prometheus/client/summary.rb +17 -3
 - data/lib/prometheus/client/version.rb +1 -1
 - data/lib/prometheus/middleware/collector.rb +12 -4
 - data/lib/prometheus/middleware/exporter.rb +8 -3
 - metadata +10 -10
 
| 
         @@ -67,15 +67,17 @@ module Prometheus 
     | 
|
| 
       67 
67 
     | 
    
         
             
                  end
         
     | 
| 
       68 
68 
     | 
    
         | 
| 
       69 
69 
     | 
    
         
             
                  def record(env, code, duration)
         
     | 
| 
      
 70 
     | 
    
         
            +
                    path = generate_path(env)
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
       70 
72 
     | 
    
         
             
                    counter_labels = {
         
     | 
| 
       71 
73 
     | 
    
         
             
                      code:   code,
         
     | 
| 
       72 
74 
     | 
    
         
             
                      method: env['REQUEST_METHOD'].downcase,
         
     | 
| 
       73 
     | 
    
         
            -
                      path:    
     | 
| 
      
 75 
     | 
    
         
            +
                      path:   path,
         
     | 
| 
       74 
76 
     | 
    
         
             
                    }
         
     | 
| 
       75 
77 
     | 
    
         | 
| 
       76 
78 
     | 
    
         
             
                    duration_labels = {
         
     | 
| 
       77 
79 
     | 
    
         
             
                      method: env['REQUEST_METHOD'].downcase,
         
     | 
| 
       78 
     | 
    
         
            -
                      path:    
     | 
| 
      
 80 
     | 
    
         
            +
                      path:   path,
         
     | 
| 
       79 
81 
     | 
    
         
             
                    }
         
     | 
| 
       80 
82 
     | 
    
         | 
| 
       81 
83 
     | 
    
         
             
                    @requests.increment(labels: counter_labels)
         
     | 
| 
         @@ -85,10 +87,16 @@ module Prometheus 
     | 
|
| 
       85 
87 
     | 
    
         
             
                    nil
         
     | 
| 
       86 
88 
     | 
    
         
             
                  end
         
     | 
| 
       87 
89 
     | 
    
         | 
| 
      
 90 
     | 
    
         
            +
                  def generate_path(env)
         
     | 
| 
      
 91 
     | 
    
         
            +
                    full_path = [env['SCRIPT_NAME'], env['PATH_INFO']].join
         
     | 
| 
      
 92 
     | 
    
         
            +
             
     | 
| 
      
 93 
     | 
    
         
            +
                    strip_ids_from_path(full_path)
         
     | 
| 
      
 94 
     | 
    
         
            +
                  end
         
     | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
       88 
96 
     | 
    
         
             
                  def strip_ids_from_path(path)
         
     | 
| 
       89 
97 
     | 
    
         
             
                    path
         
     | 
| 
       90 
     | 
    
         
            -
                      .gsub(%r{/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}( 
     | 
| 
       91 
     | 
    
         
            -
                      .gsub(%r{/\d+( 
     | 
| 
      
 98 
     | 
    
         
            +
                      .gsub(%r{/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}(?=/|$)}, '/:uuid\\1')
         
     | 
| 
      
 99 
     | 
    
         
            +
                      .gsub(%r{/\d+(?=/|$)}, '/:id\\1')
         
     | 
| 
       92 
100 
     | 
    
         
             
                  end
         
     | 
| 
       93 
101 
     | 
    
         
             
                end
         
     | 
| 
       94 
102 
     | 
    
         
             
              end
         
     | 
| 
         @@ -21,11 +21,12 @@ module Prometheus 
     | 
|
| 
       21 
21 
     | 
    
         
             
                    @app = app
         
     | 
| 
       22 
22 
     | 
    
         
             
                    @registry = options[:registry] || Client.registry
         
     | 
| 
       23 
23 
     | 
    
         
             
                    @path = options[:path] || '/metrics'
         
     | 
| 
      
 24 
     | 
    
         
            +
                    @port = options[:port]
         
     | 
| 
       24 
25 
     | 
    
         
             
                    @acceptable = build_dictionary(FORMATS, FALLBACK)
         
     | 
| 
       25 
26 
     | 
    
         
             
                  end
         
     | 
| 
       26 
27 
     | 
    
         | 
| 
       27 
28 
     | 
    
         
             
                  def call(env)
         
     | 
| 
       28 
     | 
    
         
            -
                    if env['PATH_INFO'] == @path
         
     | 
| 
      
 29 
     | 
    
         
            +
                    if metrics_port?(env['SERVER_PORT']) && env['PATH_INFO'] == @path
         
     | 
| 
       29 
30 
     | 
    
         
             
                      format = negotiate(env, @acceptable)
         
     | 
| 
       30 
31 
     | 
    
         
             
                      format ? respond_with(format) : not_acceptable(FORMATS)
         
     | 
| 
       31 
32 
     | 
    
         
             
                    else
         
     | 
| 
         @@ -65,7 +66,7 @@ module Prometheus 
     | 
|
| 
       65 
66 
     | 
    
         
             
                  def respond_with(format)
         
     | 
| 
       66 
67 
     | 
    
         
             
                    [
         
     | 
| 
       67 
68 
     | 
    
         
             
                      200,
         
     | 
| 
       68 
     | 
    
         
            -
                      { ' 
     | 
| 
      
 69 
     | 
    
         
            +
                      { 'content-type' => format::CONTENT_TYPE },
         
     | 
| 
       69 
70 
     | 
    
         
             
                      [format.marshal(@registry)],
         
     | 
| 
       70 
71 
     | 
    
         
             
                    ]
         
     | 
| 
       71 
72 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -75,7 +76,7 @@ module Prometheus 
     | 
|
| 
       75 
76 
     | 
    
         | 
| 
       76 
77 
     | 
    
         
             
                    [
         
     | 
| 
       77 
78 
     | 
    
         
             
                      406,
         
     | 
| 
       78 
     | 
    
         
            -
                      { ' 
     | 
| 
      
 79 
     | 
    
         
            +
                      { 'content-type' => 'text/plain' },
         
     | 
| 
       79 
80 
     | 
    
         
             
                      ["Supported media types: #{types.join(', ')}"],
         
     | 
| 
       80 
81 
     | 
    
         
             
                    ]
         
     | 
| 
       81 
82 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -86,6 +87,10 @@ module Prometheus 
     | 
|
| 
       86 
87 
     | 
    
         
             
                      memo[format::MEDIA_TYPE] = format
         
     | 
| 
       87 
88 
     | 
    
         
             
                    end
         
     | 
| 
       88 
89 
     | 
    
         
             
                  end
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
                  def metrics_port?(request_port)
         
     | 
| 
      
 92 
     | 
    
         
            +
                    @port.nil? || @port.to_s == request_port
         
     | 
| 
      
 93 
     | 
    
         
            +
                  end
         
     | 
| 
       89 
94 
     | 
    
         
             
                end
         
     | 
| 
       90 
95 
     | 
    
         
             
              end
         
     | 
| 
       91 
96 
     | 
    
         
             
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,16 +1,16 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: prometheus-client
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 1.0 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 4.1.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Ben Kochie
         
     | 
| 
       8 
8 
     | 
    
         
             
            - Chris Sinjakli
         
     | 
| 
       9 
9 
     | 
    
         
             
            - Daniel Magliola
         
     | 
| 
       10 
     | 
    
         
            -
            autorequire: 
     | 
| 
      
 10 
     | 
    
         
            +
            autorequire:
         
     | 
| 
       11 
11 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       12 
12 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       13 
     | 
    
         
            -
            date:  
     | 
| 
      
 13 
     | 
    
         
            +
            date: 2023-03-20 00:00:00.000000000 Z
         
     | 
| 
       14 
14 
     | 
    
         
             
            dependencies:
         
     | 
| 
       15 
15 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       16 
16 
     | 
    
         
             
              name: benchmark-ips
         
     | 
| 
         @@ -40,15 +40,16 @@ dependencies: 
     | 
|
| 
       40 
40 
     | 
    
         
             
                - - ">="
         
     | 
| 
       41 
41 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       42 
42 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       43 
     | 
    
         
            -
            description: 
     | 
| 
      
 43 
     | 
    
         
            +
            description:
         
     | 
| 
       44 
44 
     | 
    
         
             
            email:
         
     | 
| 
       45 
45 
     | 
    
         
             
            - superq@gmail.com
         
     | 
| 
       46 
     | 
    
         
            -
            - chris@ 
     | 
| 
      
 46 
     | 
    
         
            +
            - chris@sinjakli.co.uk
         
     | 
| 
       47 
47 
     | 
    
         
             
            - dmagliola@crystalgears.com
         
     | 
| 
       48 
48 
     | 
    
         
             
            executables: []
         
     | 
| 
       49 
49 
     | 
    
         
             
            extensions: []
         
     | 
| 
       50 
50 
     | 
    
         
             
            extra_rdoc_files: []
         
     | 
| 
       51 
51 
     | 
    
         
             
            files:
         
     | 
| 
      
 52 
     | 
    
         
            +
            - LICENSE
         
     | 
| 
       52 
53 
     | 
    
         
             
            - README.md
         
     | 
| 
       53 
54 
     | 
    
         
             
            - lib/prometheus.rb
         
     | 
| 
       54 
55 
     | 
    
         
             
            - lib/prometheus/client.rb
         
     | 
| 
         @@ -71,9 +72,9 @@ files: 
     | 
|
| 
       71 
72 
     | 
    
         
             
            - lib/prometheus/middleware/exporter.rb
         
     | 
| 
       72 
73 
     | 
    
         
             
            homepage: https://github.com/prometheus/client_ruby
         
     | 
| 
       73 
74 
     | 
    
         
             
            licenses:
         
     | 
| 
       74 
     | 
    
         
            -
            - Apache 
     | 
| 
      
 75 
     | 
    
         
            +
            - Apache-2.0
         
     | 
| 
       75 
76 
     | 
    
         
             
            metadata: {}
         
     | 
| 
       76 
     | 
    
         
            -
            post_install_message: 
     | 
| 
      
 77 
     | 
    
         
            +
            post_install_message:
         
     | 
| 
       77 
78 
     | 
    
         
             
            rdoc_options: []
         
     | 
| 
       78 
79 
     | 
    
         
             
            require_paths:
         
     | 
| 
       79 
80 
     | 
    
         
             
            - lib
         
     | 
| 
         @@ -88,9 +89,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       88 
89 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       89 
90 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       90 
91 
     | 
    
         
             
            requirements: []
         
     | 
| 
       91 
     | 
    
         
            -
             
     | 
| 
       92 
     | 
    
         
            -
             
     | 
| 
       93 
     | 
    
         
            -
            signing_key: 
         
     | 
| 
      
 92 
     | 
    
         
            +
            rubygems_version: 3.3.26
         
     | 
| 
      
 93 
     | 
    
         
            +
            signing_key:
         
     | 
| 
       94 
94 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       95 
95 
     | 
    
         
             
            summary: A suite of instrumentation metric primitivesthat can be exposed through a
         
     | 
| 
       96 
96 
     | 
    
         
             
              web services interface.
         
     |