sidekiq 6.5.12 → 7.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changes.md +303 -20
- data/README.md +43 -35
- data/bin/multi_queue_bench +271 -0
- data/bin/sidekiq +3 -8
- data/bin/sidekiqload +204 -118
- data/bin/sidekiqmon +3 -0
- data/lib/active_job/queue_adapters/sidekiq_adapter.rb +88 -0
- data/lib/generators/sidekiq/job_generator.rb +2 -0
- data/lib/sidekiq/api.rb +196 -138
- data/lib/sidekiq/capsule.rb +132 -0
- data/lib/sidekiq/cli.rb +60 -75
- data/lib/sidekiq/client.rb +87 -38
- data/lib/sidekiq/component.rb +4 -1
- data/lib/sidekiq/config.rb +305 -0
- data/lib/sidekiq/deploy.rb +64 -0
- data/lib/sidekiq/embedded.rb +63 -0
- data/lib/sidekiq/fetch.rb +11 -14
- data/lib/sidekiq/iterable_job.rb +55 -0
- data/lib/sidekiq/job/interrupt_handler.rb +24 -0
- data/lib/sidekiq/job/iterable/active_record_enumerator.rb +53 -0
- data/lib/sidekiq/job/iterable/csv_enumerator.rb +47 -0
- data/lib/sidekiq/job/iterable/enumerators.rb +135 -0
- data/lib/sidekiq/job/iterable.rb +294 -0
- data/lib/sidekiq/job.rb +382 -10
- data/lib/sidekiq/job_logger.rb +23 -12
- data/lib/sidekiq/job_retry.rb +42 -19
- data/lib/sidekiq/job_util.rb +53 -15
- data/lib/sidekiq/launcher.rb +71 -65
- data/lib/sidekiq/logger.rb +2 -27
- data/lib/sidekiq/manager.rb +9 -11
- data/lib/sidekiq/metrics/query.rb +9 -4
- data/lib/sidekiq/metrics/shared.rb +21 -9
- data/lib/sidekiq/metrics/tracking.rb +40 -26
- data/lib/sidekiq/middleware/chain.rb +19 -18
- data/lib/sidekiq/middleware/current_attributes.rb +70 -20
- data/lib/sidekiq/middleware/modules.rb +2 -0
- data/lib/sidekiq/monitor.rb +18 -4
- data/lib/sidekiq/paginator.rb +2 -2
- data/lib/sidekiq/processor.rb +62 -57
- data/lib/sidekiq/rails.rb +21 -10
- data/lib/sidekiq/redis_client_adapter.rb +31 -71
- data/lib/sidekiq/redis_connection.rb +44 -115
- data/lib/sidekiq/ring_buffer.rb +2 -0
- data/lib/sidekiq/scheduled.rb +22 -23
- data/lib/sidekiq/systemd.rb +2 -0
- data/lib/sidekiq/testing.rb +37 -46
- data/lib/sidekiq/transaction_aware_client.rb +11 -5
- data/lib/sidekiq/version.rb +6 -1
- data/lib/sidekiq/web/action.rb +15 -5
- data/lib/sidekiq/web/application.rb +89 -17
- data/lib/sidekiq/web/csrf_protection.rb +10 -7
- data/lib/sidekiq/web/helpers.rb +102 -42
- data/lib/sidekiq/web/router.rb +5 -2
- data/lib/sidekiq/web.rb +65 -17
- data/lib/sidekiq/worker_compatibility_alias.rb +13 -0
- data/lib/sidekiq.rb +78 -274
- data/sidekiq.gemspec +12 -10
- data/web/assets/javascripts/application.js +44 -0
- data/web/assets/javascripts/base-charts.js +106 -0
- data/web/assets/javascripts/dashboard-charts.js +192 -0
- data/web/assets/javascripts/dashboard.js +11 -233
- data/web/assets/javascripts/metrics.js +151 -115
- data/web/assets/stylesheets/application-dark.css +4 -0
- data/web/assets/stylesheets/application-rtl.css +10 -89
- data/web/assets/stylesheets/application.css +53 -298
- data/web/locales/ar.yml +70 -70
- data/web/locales/cs.yml +62 -62
- data/web/locales/da.yml +60 -53
- data/web/locales/de.yml +65 -65
- data/web/locales/el.yml +2 -7
- data/web/locales/en.yml +78 -71
- data/web/locales/es.yml +68 -68
- data/web/locales/fa.yml +65 -65
- data/web/locales/fr.yml +80 -67
- data/web/locales/gd.yml +98 -0
- data/web/locales/he.yml +65 -64
- data/web/locales/hi.yml +59 -59
- data/web/locales/it.yml +53 -53
- data/web/locales/ja.yml +67 -70
- data/web/locales/ko.yml +52 -52
- data/web/locales/lt.yml +66 -66
- data/web/locales/nb.yml +61 -61
- data/web/locales/nl.yml +52 -52
- data/web/locales/pl.yml +45 -45
- data/web/locales/pt-br.yml +78 -69
- data/web/locales/pt.yml +51 -51
- data/web/locales/ru.yml +67 -66
- data/web/locales/sv.yml +53 -53
- data/web/locales/ta.yml +60 -60
- data/web/locales/tr.yml +100 -0
- data/web/locales/uk.yml +85 -61
- data/web/locales/ur.yml +64 -64
- data/web/locales/vi.yml +67 -67
- data/web/locales/zh-cn.yml +20 -19
- data/web/locales/zh-tw.yml +10 -2
- data/web/views/_footer.erb +17 -2
- data/web/views/_job_info.erb +18 -2
- data/web/views/_metrics_period_select.erb +12 -0
- data/web/views/_paging.erb +2 -0
- data/web/views/_poll_link.erb +1 -1
- data/web/views/_summary.erb +7 -7
- data/web/views/busy.erb +46 -35
- data/web/views/dashboard.erb +28 -7
- data/web/views/filtering.erb +7 -0
- data/web/views/layout.erb +6 -6
- data/web/views/metrics.erb +48 -26
- data/web/views/metrics_for_job.erb +43 -71
- data/web/views/morgue.erb +5 -9
- data/web/views/queue.erb +10 -14
- data/web/views/queues.erb +9 -3
- data/web/views/retries.erb +5 -9
- data/web/views/scheduled.erb +12 -13
- metadata +53 -39
- data/lib/sidekiq/delay.rb +0 -43
- data/lib/sidekiq/extensions/action_mailer.rb +0 -48
- data/lib/sidekiq/extensions/active_record.rb +0 -43
- data/lib/sidekiq/extensions/class_methods.rb +0 -43
- data/lib/sidekiq/extensions/generic_proxy.rb +0 -33
- data/lib/sidekiq/metrics/deploy.rb +0 -47
- data/lib/sidekiq/worker.rb +0 -370
- data/web/assets/javascripts/graph.js +0 -16
- /data/{LICENSE → LICENSE.txt} +0 -0
@@ -0,0 +1,106 @@
|
|
1
|
+
if (window.matchMedia("(prefers-color-scheme: dark)").matches) {
|
2
|
+
Chart.defaults.borderColor = "#333";
|
3
|
+
Chart.defaults.color = "#aaa";
|
4
|
+
}
|
5
|
+
|
6
|
+
class Colors {
|
7
|
+
constructor() {
|
8
|
+
this.assignments = {};
|
9
|
+
this.success = "#006f68";
|
10
|
+
this.failure = "#af0014";
|
11
|
+
this.fallback = "#999";
|
12
|
+
this.primary = "#537bc4";
|
13
|
+
this.available = [
|
14
|
+
// Colors taken from https://www.chartjs.org/docs/latest/samples/utils.html
|
15
|
+
"#537bc4",
|
16
|
+
"#4dc9f6",
|
17
|
+
"#f67019",
|
18
|
+
"#f53794",
|
19
|
+
"#acc236",
|
20
|
+
"#166a8f",
|
21
|
+
"#00a950",
|
22
|
+
"#58595b",
|
23
|
+
"#8549ba",
|
24
|
+
"#991b1b",
|
25
|
+
];
|
26
|
+
}
|
27
|
+
|
28
|
+
checkOut(assignee) {
|
29
|
+
const color =
|
30
|
+
this.assignments[assignee] || this.available.shift() || this.fallback;
|
31
|
+
this.assignments[assignee] = color;
|
32
|
+
return color;
|
33
|
+
}
|
34
|
+
|
35
|
+
checkIn(assignee) {
|
36
|
+
const color = this.assignments[assignee];
|
37
|
+
delete this.assignments[assignee];
|
38
|
+
|
39
|
+
if (color && color != this.fallback) {
|
40
|
+
this.available.unshift(color);
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
class BaseChart {
|
46
|
+
constructor(el, options) {
|
47
|
+
this.el = el;
|
48
|
+
this.options = options;
|
49
|
+
this.colors = new Colors();
|
50
|
+
}
|
51
|
+
|
52
|
+
init() {
|
53
|
+
this.chart = new Chart(this.el, {
|
54
|
+
type: this.options.chartType,
|
55
|
+
data: { labels: this.options.labels, datasets: this.datasets },
|
56
|
+
options: this.chartOptions,
|
57
|
+
});
|
58
|
+
}
|
59
|
+
|
60
|
+
update() {
|
61
|
+
this.chart.options = this.chartOptions;
|
62
|
+
this.chart.update();
|
63
|
+
}
|
64
|
+
|
65
|
+
get chartOptions() {
|
66
|
+
let chartOptions = {
|
67
|
+
interaction: {
|
68
|
+
mode: "nearest",
|
69
|
+
axis: "x",
|
70
|
+
intersect: false,
|
71
|
+
},
|
72
|
+
scales: {
|
73
|
+
x: {
|
74
|
+
ticks: {
|
75
|
+
autoSkipPadding: 10,
|
76
|
+
},
|
77
|
+
},
|
78
|
+
},
|
79
|
+
plugins: {
|
80
|
+
legend: {
|
81
|
+
display: false,
|
82
|
+
},
|
83
|
+
annotation: {
|
84
|
+
annotations: {},
|
85
|
+
},
|
86
|
+
tooltip: {
|
87
|
+
animation: false,
|
88
|
+
},
|
89
|
+
},
|
90
|
+
};
|
91
|
+
|
92
|
+
if (this.options.marks) {
|
93
|
+
this.options.marks.forEach(([bucket, label], i) => {
|
94
|
+
chartOptions.plugins.annotation.annotations[`deploy-${i}`] = {
|
95
|
+
type: "line",
|
96
|
+
xMin: bucket,
|
97
|
+
xMax: bucket,
|
98
|
+
borderColor: "rgba(220, 38, 38, 0.4)",
|
99
|
+
borderWidth: 2,
|
100
|
+
};
|
101
|
+
});
|
102
|
+
}
|
103
|
+
|
104
|
+
return chartOptions;
|
105
|
+
}
|
106
|
+
}
|
@@ -0,0 +1,192 @@
|
|
1
|
+
class DashboardChart extends BaseChart {
|
2
|
+
constructor(el, options) {
|
3
|
+
super(el, { ...options, chartType: "line" });
|
4
|
+
this.init();
|
5
|
+
}
|
6
|
+
|
7
|
+
get data() {
|
8
|
+
return [this.options.processed, this.options.failed];
|
9
|
+
}
|
10
|
+
|
11
|
+
get datasets() {
|
12
|
+
return [
|
13
|
+
{
|
14
|
+
label: this.options.processedLabel,
|
15
|
+
data: this.data[0],
|
16
|
+
borderColor: this.colors.success,
|
17
|
+
backgroundColor: this.colors.success,
|
18
|
+
borderWidth: 2,
|
19
|
+
pointRadius: 2,
|
20
|
+
},
|
21
|
+
{
|
22
|
+
label: this.options.failedLabel,
|
23
|
+
data: this.data[1],
|
24
|
+
borderColor: this.colors.failure,
|
25
|
+
backgroundColor: this.colors.failure,
|
26
|
+
borderWidth: 2,
|
27
|
+
pointRadius: 2,
|
28
|
+
},
|
29
|
+
];
|
30
|
+
}
|
31
|
+
|
32
|
+
get chartOptions() {
|
33
|
+
return {
|
34
|
+
...super.chartOptions,
|
35
|
+
aspectRatio: 4,
|
36
|
+
scales: {
|
37
|
+
...super.chartOptions.scales,
|
38
|
+
x: {
|
39
|
+
...super.chartOptions.scales.x,
|
40
|
+
ticks: {
|
41
|
+
...super.chartOptions.scales.x.ticks,
|
42
|
+
callback: function (value, index, ticks) {
|
43
|
+
// Remove the year from the date string
|
44
|
+
return this.getLabelForValue(value).split("-").slice(1).join("-");
|
45
|
+
},
|
46
|
+
},
|
47
|
+
},
|
48
|
+
y: {
|
49
|
+
...super.chartOptions.scales.y,
|
50
|
+
beginAtZero: true,
|
51
|
+
},
|
52
|
+
},
|
53
|
+
};
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
class RealtimeChart extends DashboardChart {
|
58
|
+
constructor(el, options) {
|
59
|
+
super(el, options);
|
60
|
+
let d = parseInt(localStorage.sidekiqTimeInterval) || 5000;
|
61
|
+
if (d < 2000) { d = 2000; }
|
62
|
+
this.delay = d
|
63
|
+
this.startPolling();
|
64
|
+
document.addEventListener("interval:update", this.handleUpdate.bind(this));
|
65
|
+
}
|
66
|
+
|
67
|
+
async startPolling() {
|
68
|
+
// Fetch initial values so we can show diffs moving forward
|
69
|
+
this.stats = await this.fetchStats();
|
70
|
+
this._interval = setInterval(this.poll.bind(this), this.delay);
|
71
|
+
}
|
72
|
+
|
73
|
+
async poll() {
|
74
|
+
const stats = await this.fetchStats();
|
75
|
+
const processed = stats.sidekiq.processed - this.stats.sidekiq.processed;
|
76
|
+
const failed = stats.sidekiq.failed - this.stats.sidekiq.failed;
|
77
|
+
|
78
|
+
this.chart.data.labels.shift();
|
79
|
+
this.chart.data.datasets[0].data.shift();
|
80
|
+
this.chart.data.datasets[1].data.shift();
|
81
|
+
this.chart.data.labels.push(new Date().toUTCString().split(" ")[4]);
|
82
|
+
this.chart.data.datasets[0].data.push(processed);
|
83
|
+
this.chart.data.datasets[1].data.push(failed);
|
84
|
+
this.chart.update();
|
85
|
+
|
86
|
+
updateStatsSummary(this.stats.sidekiq);
|
87
|
+
updateRedisStats(this.stats.redis);
|
88
|
+
updateFooterUTCTime(this.stats.server_utc_time);
|
89
|
+
updateNumbers();
|
90
|
+
pulseBeacon();
|
91
|
+
|
92
|
+
this.stats = stats;
|
93
|
+
}
|
94
|
+
|
95
|
+
async fetchStats() {
|
96
|
+
const response = await fetch(this.options.updateUrl);
|
97
|
+
return await response.json();
|
98
|
+
}
|
99
|
+
|
100
|
+
handleUpdate(e) {
|
101
|
+
this.delay = parseInt(e.detail);
|
102
|
+
clearInterval(this._interval);
|
103
|
+
this.startPolling();
|
104
|
+
}
|
105
|
+
|
106
|
+
registerLegend(el) {
|
107
|
+
this.legend = el;
|
108
|
+
}
|
109
|
+
|
110
|
+
renderLegend(dp) {
|
111
|
+
const entry1 = this.legendEntry(dp[0]);
|
112
|
+
const entry2 = this.legendEntry(dp[1]);
|
113
|
+
const time = document.createElement("span");
|
114
|
+
time.classList.add("time");
|
115
|
+
time.innerText = dp[0].label;
|
116
|
+
|
117
|
+
this.legend.replaceChildren(entry1, entry2, time)
|
118
|
+
}
|
119
|
+
|
120
|
+
legendEntry(dp) {
|
121
|
+
const wrapper = document.createElement("span");
|
122
|
+
|
123
|
+
const swatch = document.createElement("span");
|
124
|
+
swatch.classList.add("swatch");
|
125
|
+
swatch.style.backgroundColor = dp.dataset.borderColor;
|
126
|
+
wrapper.appendChild(swatch)
|
127
|
+
|
128
|
+
const label = document.createElement("span");
|
129
|
+
label.innerText = `${dp.dataset.label}: ${dp.formattedValue}`;
|
130
|
+
wrapper.appendChild(label)
|
131
|
+
return wrapper;
|
132
|
+
}
|
133
|
+
|
134
|
+
renderCursor(dp) {
|
135
|
+
if (this.cursorX != dp[0].label) {
|
136
|
+
this.cursorX = dp[0].label;
|
137
|
+
this.update()
|
138
|
+
}
|
139
|
+
}
|
140
|
+
|
141
|
+
get chartOptions() {
|
142
|
+
return {
|
143
|
+
...super.chartOptions,
|
144
|
+
scales: {
|
145
|
+
...super.chartOptions.scales,
|
146
|
+
x: {
|
147
|
+
...super.chartOptions.scales.x,
|
148
|
+
display: false,
|
149
|
+
},
|
150
|
+
},
|
151
|
+
plugins: {
|
152
|
+
...super.chartOptions.plugins,
|
153
|
+
tooltip: {
|
154
|
+
...super.chartOptions.plugins.tooltip,
|
155
|
+
enabled: false,
|
156
|
+
external: (context) => {
|
157
|
+
const dp = context.tooltip.dataPoints;
|
158
|
+
if (dp && dp.length == 2 && this.legend) {
|
159
|
+
this.renderLegend(dp);
|
160
|
+
this.renderCursor(dp);
|
161
|
+
}
|
162
|
+
},
|
163
|
+
},
|
164
|
+
annotation: {
|
165
|
+
annotations: {
|
166
|
+
...super.chartOptions.plugins.annotation.annotations,
|
167
|
+
cursor: this.cursorX && {
|
168
|
+
type: "line",
|
169
|
+
borderColor: "rgba(0, 0, 0, 0.3)",
|
170
|
+
xMin: this.cursorX,
|
171
|
+
xMax: this.cursorX,
|
172
|
+
borderWidth: 1,
|
173
|
+
},
|
174
|
+
},
|
175
|
+
},
|
176
|
+
},
|
177
|
+
};
|
178
|
+
}
|
179
|
+
}
|
180
|
+
|
181
|
+
var rc = document.getElementById("realtime-chart")
|
182
|
+
if (rc != null) {
|
183
|
+
var rtc = new RealtimeChart(rc, JSON.parse(rc.textContent))
|
184
|
+
rtc.registerLegend(document.getElementById("realtime-legend"))
|
185
|
+
window.realtimeChart = rtc
|
186
|
+
}
|
187
|
+
|
188
|
+
var hc = document.getElementById("history-chart")
|
189
|
+
if (hc != null) {
|
190
|
+
var htc = new DashboardChart(hc, JSON.parse(hc.textContent))
|
191
|
+
window.historyChart = htc
|
192
|
+
}
|
@@ -1,197 +1,13 @@
|
|
1
1
|
Sidekiq = {};
|
2
2
|
|
3
|
-
var nf = new Intl.NumberFormat();
|
4
|
-
var poller;
|
5
|
-
var realtimeGraph = function(updatePath) {
|
6
|
-
var timeInterval = parseInt(localStorage.sidekiqTimeInterval) || 5000;
|
7
|
-
var graphElement = document.getElementById("realtime");
|
8
|
-
|
9
|
-
var graph = new Rickshaw.Graph( {
|
10
|
-
element: graphElement,
|
11
|
-
width: responsiveWidth(),
|
12
|
-
height: 200,
|
13
|
-
renderer: 'line',
|
14
|
-
interpolation: 'linear',
|
15
|
-
|
16
|
-
series: new Rickshaw.Series.FixedDuration([{ name: graphElement.dataset.failedLabel, color: '#af0014' }, { name: graphElement.dataset.processedLabel, color: '#006f68' }], undefined, {
|
17
|
-
timeInterval: timeInterval,
|
18
|
-
maxDataPoints: 100,
|
19
|
-
})
|
20
|
-
});
|
21
|
-
|
22
|
-
var y_axis = new Rickshaw.Graph.Axis.Y( {
|
23
|
-
graph: graph,
|
24
|
-
tickFormat: Rickshaw.Fixtures.Number.formatKMBT,
|
25
|
-
ticksTreatment: 'glow'
|
26
|
-
});
|
27
|
-
|
28
|
-
graph.render();
|
29
|
-
|
30
|
-
var legend = document.getElementById('realtime-legend');
|
31
|
-
var Hover = Rickshaw.Class.create(Rickshaw.Graph.HoverDetail, {
|
32
|
-
render: function(args) {
|
33
|
-
legend.innerHTML = "";
|
34
|
-
|
35
|
-
var timestamp = document.createElement('div');
|
36
|
-
timestamp.className = 'timestamp';
|
37
|
-
timestamp.innerHTML = args.formattedXValue;
|
38
|
-
legend.appendChild(timestamp);
|
39
|
-
|
40
|
-
args.detail.sort(function(a, b) { return a.order - b.order }).forEach( function(d) {
|
41
|
-
var line = document.createElement('div');
|
42
|
-
line.className = 'line';
|
43
|
-
|
44
|
-
var swatch = document.createElement('div');
|
45
|
-
swatch.className = 'swatch';
|
46
|
-
swatch.style.backgroundColor = d.series.color;
|
47
|
-
|
48
|
-
var label = document.createElement('div');
|
49
|
-
label.className = 'tag';
|
50
|
-
label.innerHTML = d.name + ": " + nf.format(Math.floor(d.formattedYValue));
|
51
|
-
|
52
|
-
line.appendChild(swatch);
|
53
|
-
line.appendChild(label);
|
54
|
-
legend.appendChild(line);
|
55
|
-
|
56
|
-
var dot = document.createElement('div');
|
57
|
-
dot.className = 'dot';
|
58
|
-
dot.style.top = graph.y(d.value.y0 + d.value.y) + 'px';
|
59
|
-
dot.style.borderColor = d.series.color;
|
60
|
-
|
61
|
-
this.element.appendChild(dot);
|
62
|
-
dot.className = 'dot active';
|
63
|
-
this.show();
|
64
|
-
}, this );
|
65
|
-
}
|
66
|
-
});
|
67
|
-
var hover = new Hover( { graph: graph } );
|
68
|
-
|
69
|
-
var i = 0;
|
70
|
-
poller = setInterval(function() {
|
71
|
-
var url = document.getElementById("history").getAttribute("data-update-url");
|
72
|
-
|
73
|
-
fetch(url).then(response => response.json()).then(data => {
|
74
|
-
if (i === 0) {
|
75
|
-
var processed = data.sidekiq.processed;
|
76
|
-
var failed = data.sidekiq.failed;
|
77
|
-
} else {
|
78
|
-
var processed = data.sidekiq.processed - Sidekiq.processed;
|
79
|
-
var failed = data.sidekiq.failed - Sidekiq.failed;
|
80
|
-
}
|
81
|
-
|
82
|
-
dataPoint = {};
|
83
|
-
dataPoint[graphElement.dataset.failedLabel] = failed;
|
84
|
-
dataPoint[graphElement.dataset.processedLabel] = processed;
|
85
|
-
|
86
|
-
graph.series.addData(dataPoint);
|
87
|
-
graph.render();
|
88
|
-
|
89
|
-
Sidekiq.processed = data.sidekiq.processed;
|
90
|
-
Sidekiq.failed = data.sidekiq.failed;
|
91
|
-
|
92
|
-
updateStatsSummary(data.sidekiq);
|
93
|
-
updateRedisStats(data.redis);
|
94
|
-
updateFooterUTCTime(data.server_utc_time)
|
95
|
-
|
96
|
-
pulseBeacon();
|
97
|
-
});
|
98
|
-
|
99
|
-
i++;
|
100
|
-
}, timeInterval);
|
101
|
-
}
|
102
|
-
|
103
|
-
var historyGraph = function() {
|
104
|
-
var h = document.getElementById("history");
|
105
|
-
processed = createSeries(h.getAttribute("data-processed"));
|
106
|
-
failed = createSeries(h.getAttribute("data-failed"));
|
107
|
-
|
108
|
-
var graphElement = h;
|
109
|
-
var graph = new Rickshaw.Graph( {
|
110
|
-
element: graphElement,
|
111
|
-
width: responsiveWidth(),
|
112
|
-
height: 200,
|
113
|
-
renderer: 'line',
|
114
|
-
interpolation: 'linear',
|
115
|
-
series: [
|
116
|
-
{
|
117
|
-
color: "#af0014",
|
118
|
-
data: failed,
|
119
|
-
name: graphElement.dataset.failedLabel
|
120
|
-
}, {
|
121
|
-
color: "#006f68",
|
122
|
-
data: processed,
|
123
|
-
name: graphElement.dataset.processedLabel
|
124
|
-
}
|
125
|
-
]
|
126
|
-
} );
|
127
|
-
var x_axis = new Rickshaw.Graph.Axis.Time( { graph: graph } );
|
128
|
-
var y_axis = new Rickshaw.Graph.Axis.Y({
|
129
|
-
graph: graph,
|
130
|
-
tickFormat: Rickshaw.Fixtures.Number.formatKMBT,
|
131
|
-
ticksTreatment: 'glow'
|
132
|
-
});
|
133
|
-
|
134
|
-
graph.render();
|
135
|
-
|
136
|
-
var legend = document.getElementById('history-legend');
|
137
|
-
var Hover = Rickshaw.Class.create(Rickshaw.Graph.HoverDetail, {
|
138
|
-
render: function(args) {
|
139
|
-
legend.innerHTML = "";
|
140
|
-
|
141
|
-
var timestamp = document.createElement('div');
|
142
|
-
timestamp.className = 'timestamp';
|
143
|
-
timestamp.innerHTML = args.formattedXValue;
|
144
|
-
legend.appendChild(timestamp);
|
145
|
-
|
146
|
-
args.detail.sort(function(a, b) { return a.order - b.order }).forEach( function(d) {
|
147
|
-
var line = document.createElement('div');
|
148
|
-
line.className = 'line';
|
149
|
-
|
150
|
-
var swatch = document.createElement('div');
|
151
|
-
swatch.className = 'swatch';
|
152
|
-
swatch.style.backgroundColor = d.series.color;
|
153
|
-
|
154
|
-
var label = document.createElement('div');
|
155
|
-
label.className = 'tag';
|
156
|
-
label.innerHTML = d.name + ": " + nf.format(Math.floor(d.formattedYValue));
|
157
|
-
|
158
|
-
line.appendChild(swatch);
|
159
|
-
line.appendChild(label);
|
160
|
-
legend.appendChild(line);
|
161
|
-
|
162
|
-
var dot = document.createElement('div');
|
163
|
-
dot.className = 'dot';
|
164
|
-
dot.style.top = graph.y(d.value.y0 + d.value.y) + 'px';
|
165
|
-
dot.style.borderColor = d.series.color;
|
166
|
-
|
167
|
-
this.element.appendChild(dot);
|
168
|
-
dot.className = 'dot active';
|
169
|
-
this.show();
|
170
|
-
}, this );
|
171
|
-
}
|
172
|
-
});
|
173
|
-
var hover = new Hover( { graph: graph } );
|
174
|
-
}
|
175
|
-
|
176
|
-
var createSeries = function(data) {
|
177
|
-
var obj = JSON.parse(data);
|
178
|
-
var series = [];
|
179
|
-
for (var date in obj) {
|
180
|
-
var value = obj[date];
|
181
|
-
var point = { x: Date.parse(date)/1000, y: value };
|
182
|
-
series.unshift(point);
|
183
|
-
}
|
184
|
-
return series;
|
185
|
-
};
|
186
|
-
|
187
3
|
var updateStatsSummary = function(data) {
|
188
|
-
document.getElementById("txtProcessed").innerText =
|
189
|
-
document.getElementById("txtFailed").innerText =
|
190
|
-
document.getElementById("txtBusy").innerText =
|
191
|
-
document.getElementById("txtScheduled").innerText =
|
192
|
-
document.getElementById("txtRetries").innerText =
|
193
|
-
document.getElementById("txtEnqueued").innerText =
|
194
|
-
document.getElementById("txtDead").innerText =
|
4
|
+
document.getElementById("txtProcessed").innerText = data.processed;
|
5
|
+
document.getElementById("txtFailed").innerText = data.failed;
|
6
|
+
document.getElementById("txtBusy").innerText = data.busy;
|
7
|
+
document.getElementById("txtScheduled").innerText = data.scheduled;
|
8
|
+
document.getElementById("txtRetries").innerText = data.retries;
|
9
|
+
document.getElementById("txtEnqueued").innerText = data.enqueued;
|
10
|
+
document.getElementById("txtDead").innerText = data.dead;
|
195
11
|
}
|
196
12
|
|
197
13
|
var updateRedisStats = function(data) {
|
@@ -211,14 +27,8 @@ var pulseBeacon = function() {
|
|
211
27
|
window.setTimeout(() => { document.getElementById('beacon').classList.remove('pulse'); }, 1000);
|
212
28
|
}
|
213
29
|
|
214
|
-
// Render graphs
|
215
|
-
var renderGraphs = function() {
|
216
|
-
realtimeGraph();
|
217
|
-
historyGraph();
|
218
|
-
};
|
219
|
-
|
220
30
|
var setSliderLabel = function(val) {
|
221
|
-
document.getElementById('sldr-text').innerText = Math.round(parseFloat(val) / 1000) + '
|
31
|
+
document.getElementById('sldr-text').innerText = Math.round(parseFloat(val) / 1000) + ' s';
|
222
32
|
}
|
223
33
|
|
224
34
|
var ready = (callback) => {
|
@@ -227,8 +37,6 @@ var ready = (callback) => {
|
|
227
37
|
}
|
228
38
|
|
229
39
|
ready(() => {
|
230
|
-
renderGraphs();
|
231
|
-
|
232
40
|
var sldr = document.getElementById('sldr');
|
233
41
|
if (typeof localStorage.sidekiqTimeInterval !== 'undefined') {
|
234
42
|
sldr.value = localStorage.sidekiqTimeInterval;
|
@@ -236,44 +44,14 @@ ready(() => {
|
|
236
44
|
}
|
237
45
|
|
238
46
|
sldr.addEventListener("change", event => {
|
239
|
-
clearInterval(poller);
|
240
47
|
localStorage.sidekiqTimeInterval = sldr.value;
|
241
48
|
setSliderLabel(sldr.value);
|
242
|
-
|
243
|
-
|
49
|
+
sldr.dispatchEvent(
|
50
|
+
new CustomEvent("interval:update", { bubbles: true, detail: sldr.value })
|
51
|
+
);
|
244
52
|
});
|
245
53
|
|
246
54
|
sldr.addEventListener("mousemove", event => {
|
247
55
|
setSliderLabel(sldr.value);
|
248
56
|
});
|
249
57
|
});
|
250
|
-
|
251
|
-
// Reset graphs
|
252
|
-
var resetGraphs = function() {
|
253
|
-
document.getElementById('realtime').innerHTML = '';
|
254
|
-
document.getElementById('history').innerHTML = '';
|
255
|
-
};
|
256
|
-
|
257
|
-
// Resize graphs after resizing window
|
258
|
-
var debounce = function(fn, timeout) {
|
259
|
-
var timeoutID = -1;
|
260
|
-
return function() {
|
261
|
-
if (timeoutID > -1) {
|
262
|
-
window.clearTimeout(timeoutID);
|
263
|
-
}
|
264
|
-
timeoutID = window.setTimeout(fn, timeout);
|
265
|
-
}
|
266
|
-
};
|
267
|
-
|
268
|
-
window.onresize = function() {
|
269
|
-
var prevWidth = window.innerWidth;
|
270
|
-
return debounce(function () {
|
271
|
-
var currWidth = window.innerWidth;
|
272
|
-
if (prevWidth !== currWidth) {
|
273
|
-
prevWidth = currWidth;
|
274
|
-
clearInterval(poller);
|
275
|
-
resetGraphs();
|
276
|
-
renderGraphs();
|
277
|
-
}
|
278
|
-
}, 125);
|
279
|
-
}();
|