sidekiq-job-stats 0.1.1 → 0.1.3
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/Gemfile.lock +1 -1
 - data/lib/sidekiq_job_stats/history.rb +2 -2
 - data/lib/sidekiq_job_stats/version.rb +1 -1
 - data/lib/sidekiq_job_stats/web_extension.rb +2 -2
 - data/lib/sidekiq_job_stats.rb +5 -5
 - data/lib/web/views/job_histories.erb +53 -26
 - data/lib/web/views/job_stats.erb +21 -1
 - metadata +3 -3
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 6a9c59fdf15817dade5f214b29918eea19c39f00aa8cbb845d0d9dd3d9ddbf69
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: f9a6a773c72aaa741448634cd1fb32c182c450edc0abd01c903b46493e37a038
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 1f69e4a9832aabcfd8cf0c8ee096f6ee00efb39a897ff9966142088284489f14269cb75402f8dcbf4c8b1ae60b39ae5b4c20ad927658b8b698cabe95f3283d4f
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 70d698eede5595eed2e0e7aab0794e11becc7744359d00c9e84106fae389fb63cddc005e97c32929c63d64107e7e5b4c885c555898a28fe008d5c71af963fe3d
         
     | 
    
        data/Gemfile.lock
    CHANGED
    
    
| 
         @@ -33,11 +33,11 @@ module SidekiqJobStats 
     | 
|
| 
       33 
33 
     | 
    
         
             
                end
         
     | 
| 
       34 
34 
     | 
    
         | 
| 
       35 
35 
     | 
    
         
             
                def push_history(job_data)
         
     | 
| 
       36 
     | 
    
         
            -
                  return if Sidekiq. 
     | 
| 
      
 36 
     | 
    
         
            +
                  return if Sidekiq.job_stats_max_count.zero?
         
     | 
| 
       37 
37 
     | 
    
         | 
| 
       38 
38 
     | 
    
         
             
                  Sidekiq.redis do |conn|
         
     | 
| 
       39 
39 
     | 
    
         
             
                    conn.lpush(job_history_key, job_data.to_json)
         
     | 
| 
       40 
     | 
    
         
            -
                    conn.ltrim(job_history_key, 0, Sidekiq. 
     | 
| 
      
 40 
     | 
    
         
            +
                    conn.ltrim(job_history_key, 0, Sidekiq.job_stats_max_count)
         
     | 
| 
       41 
41 
     | 
    
         
             
                  end
         
     | 
| 
       42 
42 
     | 
    
         
             
                end
         
     | 
| 
       43 
43 
     | 
    
         
             
              end
         
     | 
| 
         @@ -9,13 +9,13 @@ module SidekiqJobStats 
     | 
|
| 
       9 
9 
     | 
    
         
             
                def self.registered(app)
         
     | 
| 
       10 
10 
     | 
    
         
             
                  app.helpers Helpers::Stats
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
                  app.get '/ 
     | 
| 
      
 12 
     | 
    
         
            +
                  app.get '/job_stats' do
         
     | 
| 
       13 
13 
     | 
    
         
             
                    @jobs = SidekiqJobStats::Statistic.find_all.sort
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
15 
     | 
    
         
             
                    render(:erb, File.read("#{ROOT}/views/job_stats.erb"))
         
     | 
| 
       16 
16 
     | 
    
         
             
                  end
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
       18 
     | 
    
         
            -
                  app.get '/ 
     | 
| 
      
 18 
     | 
    
         
            +
                  app.get '/job_stats/job_history/:job_class' do
         
     | 
| 
       19 
19 
     | 
    
         
             
                    @job_class = SidekiqJobStats::Statistic.find_all.find { |j| j.job_class.to_s == params[:job_class] }
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
21 
     | 
    
         
             
                    @start = 0
         
     | 
    
        data/lib/sidekiq_job_stats.rb
    CHANGED
    
    | 
         @@ -10,14 +10,14 @@ require_relative "sidekiq_job_stats/history" 
     | 
|
| 
       10 
10 
     | 
    
         
             
            require 'sidekiq/web'
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
12 
     | 
    
         
             
            module Sidekiq
         
     | 
| 
       13 
     | 
    
         
            -
              def self. 
     | 
| 
       14 
     | 
    
         
            -
                @ 
     | 
| 
      
 13 
     | 
    
         
            +
              def self.job_stats_max_count=(value)
         
     | 
| 
      
 14 
     | 
    
         
            +
                @job_stats_max_count = value
         
     | 
| 
       15 
15 
     | 
    
         
             
              end
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
              def self. 
     | 
| 
       18 
     | 
    
         
            -
                @ 
     | 
| 
      
 17 
     | 
    
         
            +
              def self.job_stats_max_count
         
     | 
| 
      
 18 
     | 
    
         
            +
                @job_stats_max_count || 1000
         
     | 
| 
       19 
19 
     | 
    
         
             
              end
         
     | 
| 
       20 
20 
     | 
    
         
             
            end
         
     | 
| 
       21 
21 
     | 
    
         | 
| 
       22 
22 
     | 
    
         
             
            Sidekiq::Web.register(SidekiqJobStats::WebExtension)
         
     | 
| 
       23 
     | 
    
         
            -
            Sidekiq::Web.tabs[' 
     | 
| 
      
 23 
     | 
    
         
            +
            Sidekiq::Web.tabs['Job stats'] = 'job_stats'
         
     | 
| 
         @@ -1,3 +1,24 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <style>
         
     | 
| 
      
 2 
     | 
    
         
            +
                table {
         
     | 
| 
      
 3 
     | 
    
         
            +
                    text-align: left;
         
     | 
| 
      
 4 
     | 
    
         
            +
                    position: relative;
         
     | 
| 
      
 5 
     | 
    
         
            +
                    border-collapse: separate;
         
     | 
| 
      
 6 
     | 
    
         
            +
                    border-spacing: 0;
         
     | 
| 
      
 7 
     | 
    
         
            +
                }
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                th {
         
     | 
| 
      
 10 
     | 
    
         
            +
                    position: sticky;
         
     | 
| 
      
 11 
     | 
    
         
            +
                    top: 0;
         
     | 
| 
      
 12 
     | 
    
         
            +
                    background-color: #F9F8F8;
         
     | 
| 
      
 13 
     | 
    
         
            +
                    border-bottom: 1px solid #EB9486;
         
     | 
| 
      
 14 
     | 
    
         
            +
                }
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                .fixTableHead {
         
     | 
| 
      
 17 
     | 
    
         
            +
                    max-height: 500px;
         
     | 
| 
      
 18 
     | 
    
         
            +
                    overflow: auto;
         
     | 
| 
      
 19 
     | 
    
         
            +
                }
         
     | 
| 
      
 20 
     | 
    
         
            +
            </style>
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
       1 
22 
     | 
    
         
             
            <h1>Sidekiq Job Histories</h1>
         
     | 
| 
       2 
23 
     | 
    
         | 
| 
       3 
24 
     | 
    
         
             
            <p class="intro">
         
     | 
| 
         @@ -5,38 +26,44 @@ 
     | 
|
| 
       5 
26 
     | 
    
         
             
            </p>
         
     | 
| 
       6 
27 
     | 
    
         
             
            <h2><%= @job_class.job_class.to_s %></h2>
         
     | 
| 
       7 
28 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
            < 
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
                   
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
                     
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
      
 29 
     | 
    
         
            +
            <div class="fixTableHead">
         
     | 
| 
      
 30 
     | 
    
         
            +
                <table class="table table-hover table-bordered table-striped">
         
     | 
| 
      
 31 
     | 
    
         
            +
                  <thead>
         
     | 
| 
      
 32 
     | 
    
         
            +
                    <tr>
         
     | 
| 
      
 33 
     | 
    
         
            +
                      <th class="header">Enqueued time</th>
         
     | 
| 
      
 34 
     | 
    
         
            +
                      <th class="header">Started at</th>
         
     | 
| 
      
 35 
     | 
    
         
            +
                      <th class="header">Finished at</th>
         
     | 
| 
      
 36 
     | 
    
         
            +
                      <th class="header">Duration</th>
         
     | 
| 
      
 37 
     | 
    
         
            +
                      <th class="header">Arguments</th>
         
     | 
| 
      
 38 
     | 
    
         
            +
                      <th class="header">Success</th>
         
     | 
| 
      
 39 
     | 
    
         
            +
                      <th class="header">Exception</th>
         
     | 
| 
      
 40 
     | 
    
         
            +
                    </tr>
         
     | 
| 
      
 41 
     | 
    
         
            +
                  </thead>
         
     | 
| 
      
 42 
     | 
    
         
            +
                  <tbody>
         
     | 
| 
      
 43 
     | 
    
         
            +
                  <% @histories.each do |history| %>
         
     | 
| 
      
 44 
     | 
    
         
            +
                    <% if history.is_a? Hash %>
         
     | 
| 
      
 45 
     | 
    
         
            +
                      <tr>
         
     | 
| 
      
 46 
     | 
    
         
            +
                        <td><span class="time"><%= Time.at(history["enqueued_at"]) %></span></td>
         
     | 
| 
      
 47 
     | 
    
         
            +
                        <td><span class="time"><%= history["started_at"] %></span></td>
         
     | 
| 
      
 48 
     | 
    
         
            +
                        <td><span class="time"><%= history["finished_at"]%></span></td>
         
     | 
| 
      
 49 
     | 
    
         
            +
                        <td><%= history["duration"] %>s</td>
         
     | 
| 
      
 50 
     | 
    
         
            +
                        <td><%= history["payload"] %></td>
         
     | 
| 
      
 51 
     | 
    
         
            +
                        <td><%= history["status"] %></td>
         
     | 
| 
      
 52 
     | 
    
         
            +
                        <td><%= history["exception"] if history["exception"] %></td>
         
     | 
| 
      
 53 
     | 
    
         
            +
                      </tr>
         
     | 
| 
      
 54 
     | 
    
         
            +
                    <% end %>
         
     | 
| 
      
 55 
     | 
    
         
            +
                  <% end %>
         
     | 
| 
      
 56 
     | 
    
         
            +
                  </tbody>
         
     | 
| 
      
 57 
     | 
    
         
            +
                </table>
         
     | 
| 
      
 58 
     | 
    
         
            +
            </div>
         
     | 
| 
       32 
59 
     | 
    
         | 
| 
       33 
60 
     | 
    
         
             
            <%if @start > 0 || @start + @limit <= @size %>
         
     | 
| 
       34 
61 
     | 
    
         
             
              <p class='pagination'>
         
     | 
| 
       35 
62 
     | 
    
         
             
                <% if @start - @limit >= 0 %>
         
     | 
| 
       36 
     | 
    
         
            -
                  <a href="<%=  
     | 
| 
      
 63 
     | 
    
         
            +
                  <a href="<%= root_path %><%= request.path_info %>?start=<%= [0, @start - @limit].max %>&limit=<%= @limit %>" class='less'>« less</a>
         
     | 
| 
       37 
64 
     | 
    
         
             
                <% end %>
         
     | 
| 
       38 
65 
     | 
    
         
             
                <% if @start + @limit <= @size %>
         
     | 
| 
       39 
     | 
    
         
            -
                  <a href="<%=  
     | 
| 
      
 66 
     | 
    
         
            +
                  <a href="<%= root_path %><%= request.path_info %>?start=<%= @start + @limit %>&limit=<%= @limit %>" class='more'>more »</a>
         
     | 
| 
       40 
67 
     | 
    
         
             
                <% end %>
         
     | 
| 
       41 
68 
     | 
    
         
             
              </p>
         
     | 
| 
       42 
69 
     | 
    
         
             
            <%end%>
         
     | 
    
        data/lib/web/views/job_stats.erb
    CHANGED
    
    | 
         @@ -1,3 +1,23 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <style>
         
     | 
| 
      
 2 
     | 
    
         
            +
                table {
         
     | 
| 
      
 3 
     | 
    
         
            +
                    text-align: left;
         
     | 
| 
      
 4 
     | 
    
         
            +
                    position: relative;
         
     | 
| 
      
 5 
     | 
    
         
            +
                    border-collapse: separate;
         
     | 
| 
      
 6 
     | 
    
         
            +
                    border-spacing: 0;
         
     | 
| 
      
 7 
     | 
    
         
            +
                }
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                th {
         
     | 
| 
      
 10 
     | 
    
         
            +
                    position: sticky;
         
     | 
| 
      
 11 
     | 
    
         
            +
                    top: 0;
         
     | 
| 
      
 12 
     | 
    
         
            +
                    background-color: #F9F8F8;
         
     | 
| 
      
 13 
     | 
    
         
            +
                    border-bottom: 1px solid #EB9486;
         
     | 
| 
      
 14 
     | 
    
         
            +
                }
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                .fixTableHead {
         
     | 
| 
      
 17 
     | 
    
         
            +
                    max-height: 500px;
         
     | 
| 
      
 18 
     | 
    
         
            +
                    overflow: auto;
         
     | 
| 
      
 19 
     | 
    
         
            +
                }
         
     | 
| 
      
 20 
     | 
    
         
            +
            </style>
         
     | 
| 
       1 
21 
     | 
    
         | 
| 
       2 
22 
     | 
    
         
             
            <h1>Sidekiq Job Stats</h1>
         
     | 
| 
       3 
23 
     | 
    
         | 
| 
         @@ -28,7 +48,7 @@ 
     | 
|
| 
       28 
48 
     | 
    
         
             
                  <tr>
         
     | 
| 
       29 
49 
     | 
    
         
             
                    <td>
         
     | 
| 
       30 
50 
     | 
    
         
             
                      <%= job.name %>
         
     | 
| 
       31 
     | 
    
         
            -
                      <a href='<%= "/ 
     | 
| 
      
 51 
     | 
    
         
            +
                      <a href='<%= "#{root_path}job_stats/job_history/#{job.name}" %>'>[history]</a>
         
     | 
| 
       32 
52 
     | 
    
         
             
                    </td>
         
     | 
| 
       33 
53 
     | 
    
         
             
                    <%= display_stat(job, :jobs_enqueued, :number_display) %>
         
     | 
| 
       34 
54 
     | 
    
         
             
                    <%= display_stat(job, :jobs_performed_day, :number_display) %>
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: sidekiq-job-stats
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.3
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - isliusar
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2024- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2024-12-10 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: sidekiq
         
     | 
| 
         @@ -90,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       90 
90 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       91 
91 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       92 
92 
     | 
    
         
             
            requirements: []
         
     | 
| 
       93 
     | 
    
         
            -
            rubygems_version: 3. 
     | 
| 
      
 93 
     | 
    
         
            +
            rubygems_version: 3.5.11
         
     | 
| 
       94 
94 
     | 
    
         
             
            signing_key:
         
     | 
| 
       95 
95 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       96 
96 
     | 
    
         
             
            summary: Tracks jobs performed, failed, and the duration of the last 100 jobs for
         
     |