Skip to content

Commit

Permalink
Remove support for Logs feature (#171)
Browse files Browse the repository at this point in the history
* Remove support for Logs feature once Sidekiq does not support logging for files anymore

* Add new entry to CHANGELOG.md
  • Loading branch information
wenderjean authored Oct 27, 2021
1 parent 1905002 commit 8fdbc8f
Show file tree
Hide file tree
Showing 19 changed files with 39 additions and 235 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## HEAD

## v2.0.0

#### BREAK
* 27.10.2021: Remove support for Logs feature (#171) *Wender Freese*

## v1.5.1

* 06.02.2021: Generate new TAG to fix "version.rb" not updated in the previous one (#170) *Wender Freese*
Expand Down
47 changes: 29 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
# Sidekiq statistic

[![Build Status](https://travis-ci.org/davydovanton/sidekiq-statistic.svg)](https://travis-ci.org/davydovanton/sidekiq-statistic) [![Code Climate](https://codeclimate.com/github/davydovanton/sidekiq-history/badges/gpa.svg)](https://codeclimate.com/github/davydovanton/sidekiq-history) [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/davydovanton/sidekiq-history?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
# Sidekiq::Statistic

Improved display of statistics for your sidekiq workers and jobs.
[![Build Status](https://travis-ci.org/davydovanton/sidekiq-statistic.svg)](https://travis-ci.org/davydovanton/sidekiq-statistic) [![Code Climate](https://codeclimate.com/github/davydovanton/sidekiq-history/badges/gpa.svg)](https://codeclimate.com/github/davydovanton/sidekiq-history) [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/davydovanton/sidekiq-history?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)

**This gem work only with sidekiq version more than [3.3.4](https://github.com/mperham/sidekiq/releases/tag/v3.3.4)**
Improved display of statistics for your Sidekiq workers and jobs.

## Screenshots
Also you can check <a href="https://sidekiq-history-gem.herokuapp.com/sidekiq/statistic" target="_blank">heroku application</a> with rails app with this sidekiq plugin

### Index page:
![sidekiq-history_index](https://user-images.githubusercontent.com/15057257/66249364-74645d80-e708-11e9-8f06-a9a224be4e37.png)

### Worker page with table (per day):
![sidekiq-history_worker](https://cloud.githubusercontent.com/assets/1147484/8071171/1706924a-0f10-11e5-9ddc-8aeeb7f5c794.png)

### Worker page with log:
![screenshot 2015-06-10 01 27 50](https://cloud.githubusercontent.com/assets/1147484/8071166/0edd7688-0f10-11e5-9841-0572ab5704e3.jpg)

## Installation
Add this line to your application's Gemfile:

Expand All @@ -28,11 +23,19 @@ And then execute:
$ bundle

## Usage
Open Statistic tab on your sidekiq page.

### Not rails application
Read [sidekiq documentation](https://github.com/mperham/sidekiq/wiki/Monitoring#standalone).
After that add `require 'sidekiq-statistic'` to you `config.ru`. For example:
### Using Rails

Read [Sidekiq documentation](https://github.com/mperham/sidekiq/wiki/Monitoring#rails) to configure Sidekiq Web UI in your `routes.rb`.

When Sidekiq Web UI is active you're going be able to see the option `Statistic` on the menu.

### Using a standalone application

Read [Sidekiq documentation](https://github.com/mperham/sidekiq/wiki/Monitoring#standalone) to configure Sidekiq in your Rack server.

Next add `require 'sidekiq-statistic'` to your `config.ru`.

``` ruby
# config.ru
require 'sidekiq/web'
Expand All @@ -43,18 +46,26 @@ run Sidekiq::Web
```

## Configuration
Sidekiq statistic gem have `log_file` and `last_log_lines` options.
`log_file` option lets you specify a custom path to sidekiq log file. By default this option equal `log/sidekiq.log`
`last_log lines` option lets you specify a custom count of last logger file lines which will be displayed. By default this option equal 1000.

The Statistic configuration is an initializer that GEM uses to configure itself. The option `max_timelist_length`
is used to avoid memory leak, in practice, whenever the cache size reaches that number, the GEM is going
to remove 25% of the key values, avoiding inflating memory.

``` ruby
Sidekiq::Statistic.configure do |config|
config.log_file = 'test/helpers/logfile.log'
config.last_log_lines = 10_000
config.max_timelist_length = 500_000
config.max_timelist_length = 250_000
end
```

## Supported Sidekiq versions

Statistic support the following Sidekiq versions:

- Sidekiq 6.
- Sidekiq 5.
- Sidekiq 4.
- Sidekiq 3.5.

## JSON API
### /api/statistic.json
Returns statistic for each worker.
Expand Down
1 change: 0 additions & 1 deletion lib/sidekiq/statistic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

require 'sidekiq/api'
require 'sidekiq/statistic/configuration'
require 'sidekiq/statistic/log_parser'
require 'sidekiq/statistic/statistic/metric'
require 'sidekiq/statistic/statistic/metrics/cache_keys'
require 'sidekiq/statistic/statistic/metrics/store'
Expand Down
4 changes: 1 addition & 3 deletions lib/sidekiq/statistic/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
module Sidekiq
module Statistic
class Configuration
attr_accessor :log_file, :last_log_lines, :max_timelist_length
attr_accessor :max_timelist_length

def initialize
@log_file = 'log/sidekiq.log'
@last_log_lines = 1_000
@max_timelist_length = 250_000
end
end
Expand Down
3 changes: 0 additions & 3 deletions lib/sidekiq/statistic/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,5 @@ de: # <---- change this to your locale code
LastJobStatus: Letzter Job Status
WorkerInformation: '%{worker} Information'
InformationTable: Info-Tabelle
WorkerLog: Arbeiter-Log
WorkerTablePerDay: Arbeiter-Tabelle (pro Tag)
LastRun: Letzte Ausführung
EmptyLogs: Keine Ergebnisse
SearchLogs: Suchen Sie in der Protokolldatei
3 changes: 0 additions & 3 deletions lib/sidekiq/statistic/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,5 @@ en: # <---- change this to your locale code
LastJobStatus: Last Job Status
WorkerInformation: '%{worker} information'
InformationTable: Information table
WorkerLog: Worker log
WorkerTablePerDay: Worker table (per day)
LastRun: Last run
EmptyLogs: No results
SearchLogs: Search in log file
3 changes: 0 additions & 3 deletions lib/sidekiq/statistic/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,5 @@ es: # <---- change this to your locale code
LastJobStatus: Status del último trabajo
WorkerInformation: 'Información del %{worker}'
InformationTable: Tabla de información
WorkerLog: Log de Worker
WorkerTablePerDay: Tabla de Worker (por día)
LastRun: Última ejecución
EmptyLogs: No hay resultados
SearchLogs: Buscar en archivo de log
3 changes: 0 additions & 3 deletions lib/sidekiq/statistic/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,5 @@ fr: # <---- change this to your locale code
LastJobStatus: Dernier statut job
WorkerInformation: '%{worker} information'
InformationTable: Information table
WorkerLog: Journaux Worker
WorkerTablePerDay: Worker Table (par jour)
LastRun: Dernier Exécution
EmptyLogs: Jornaux Vides
SearchLogs: Journaux de recherche
3 changes: 0 additions & 3 deletions lib/sidekiq/statistic/locales/it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,5 @@ it: # <---- change this to your locale code
LastJobStatus: Stato Ultimo Job
WorkerInformation: 'Informazioni %{worker}'
InformationTable: Tabella Informazioni
WorkerLog: Worker log
WorkerTablePerDay: Tabella Worker (per giorno)
LastRun: Ultima Esecuzione
EmptyLogs: Nessun Risultato
SearchLogs: Cerca nel file di registro
3 changes: 0 additions & 3 deletions lib/sidekiq/statistic/locales/jp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,5 @@ jp: # <---- change this to your locale code
LastJobStatus: 最後の状態
WorkerInformation: '%{worker}の情報'
InformationTable: 情報表
WorkerLog: ワーカーログ
WorkerTablePerDay: ワーカー表 (日)
LastRun: 最後の実行
EmptyLogs: データがありません
SearchLogs: ログファイルにて検索
3 changes: 0 additions & 3 deletions lib/sidekiq/statistic/locales/pl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,5 @@ pl: # <---- change this to your locale code
LastJobStatus: Status ostatniego joba
WorkerInformation: 'Informacja o %{worker}'
InformationTable: Tablica informacyjna
WorkerLog: Worker log
WorkerTablePerDay: Lista Workeròw (dziennie)
LastRun: Ostatnie użycie
EmptyLogs: Brak logòw
SearchLogs: Szukać w logach
3 changes: 0 additions & 3 deletions lib/sidekiq/statistic/locales/pt-br.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@ pt-br: # <---- change this to your locale code
LastJobStatus: Status da última execução
WorkerInformation: 'Informações do %{worker}'
InformationTable: Tabela de informação
WorkerLog: Log do Worker
WorkerTablePerDay: Tabela do Worker (por dia)
LastRun: Última execução
EmptyLogs: Nenhum resultado
SearchLogs: Pesquisar no arquivo de logs
date:
formats:
default: "%d/%m/%Y"
Expand Down
3 changes: 0 additions & 3 deletions lib/sidekiq/statistic/locales/ru.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,5 @@ ru: # <---- change this to your locale code
LastJobStatus: Статус последнего джоба
WorkerInformation: 'Информация о %{worker}'
InformationTable: Таблица с информацией
WorkerLog: Лог воркера
WorkerTablePerDay: Таблица воркера (по дням)
LastRun: Последний запуск
EmptyLogs: Нет результатов
SearchLogs: Поиск в лог-файле
3 changes: 0 additions & 3 deletions lib/sidekiq/statistic/locales/uk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,5 @@ uk: # <---- change this to your locale code
LastJobStatus: Стан останнього обробника
WorkerInformation: 'Інформація про %{worker}'
InformationTable: Таблиця з інформацією
WorkerLog: Журнал обробника
WorkerTablePerDay: Таблиця обробника (по днях)
LastRun: Останній запуск
EmptyLogs: немає результатів
SearchLogs: Пошук у файлі журналу
86 changes: 0 additions & 86 deletions lib/sidekiq/statistic/log_parser.rb

This file was deleted.

19 changes: 3 additions & 16 deletions lib/sidekiq/statistic/views/worker.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
<h2><%= t('WorkerInformation', worker: @name) %></h2>

<ul class="nav nav-tabs">
<li class="active"><a href="#" class="statistic__tab" data-target=".statistic__table"><%= t('InformationTable') %></a></li>
<li><a href="#" class="statistic__tab" data-target=".statistic__log"><%= t('WorkerLog') %></a></li>
<li class="active">
<a href="#" class="statistic__tab" data-target=".statistic__table"><%= t('InformationTable') %></a>
</li>
</ul>

<div class="statistic__container live-reload">
Expand Down Expand Up @@ -60,19 +61,5 @@
<% end %>
</table>
</div>

<div class="statistic__log">
<input type="text" class="border-radius" placeholder="<%= t('SearchLogs') %>" />

<% if @worker_log.empty? %>
<%= t('EmptyLogs') %>
<br/>
<small><%= Sidekiq::Statistic.configuration.log_file %></small>
<% else %>
<% @worker_log.each do |line| %>
<p class="statistic__i"><%= line %></p>
<% end %>
<% end %>
</div>
</div>
</div>
1 change: 0 additions & 1 deletion lib/sidekiq/statistic/web_extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ def self.registered(app)

@worker_statistic = Workers.new(*calculate_date_range(params))
.display_per_day(@name)
@worker_log = LogParser.new(@name).parse

render(:erb, Views.require_assets('worker.erb').first)
end
Expand Down
17 changes: 1 addition & 16 deletions test/test_sidekiq/configuration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,8 @@
module Sidekiq
module Statistic
describe 'Configuration' do
describe '#log_file' do
it "default value is 'log/sidekiq.log'" do
log_file = Configuration.new.log_file
assert_equal 'log/sidekiq.log', log_file
end
end

describe '#log_file=' do
it 'can set value' do
config = Configuration.new
config.log_file = 'test/sidekiq.log'
assert_equal 'test/sidekiq.log', config.log_file
end
end

describe '#max_timelist_length=' do
it 'can set value' do
it 'assigns correct value' do
config = Configuration.new
config.max_timelist_length = 12345
assert_equal 12345, config.max_timelist_length
Expand Down
Loading

0 comments on commit 8fdbc8f

Please sign in to comment.