Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display historical count metrics in ui #105

Merged
merged 1 commit into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ require 'outboxer'
require 'sidekiq'

environment = ENV['RAILS_ENV'] || 'development'
config = Outboxer::Database.config(environment: environment)
Outboxer::Database.connect(config: config.merge(pool: 1))
config = Outboxer::Database.config(environment: environment, pool: 1)
Outboxer::Database.connect(config: config)

Sidekiq.configure_client do |config|
redis_url = ENV['REDIS_URL'] || 'redis://localhost:6379/0'
Expand Down
2 changes: 1 addition & 1 deletion bin/outboxer_published_messages_deleter
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ environment = ENV['RAILS_ENV'] || 'development'

logger = Outboxer::Logger.new($stdout, level: log_level)

db_config = Outboxer::Database.config(environment: environment)
db_config = Outboxer::Database.config(environment: environment, pool: 1)
Outboxer::Database.connect(config: db_config, logger: logger)

$running = true
Expand Down
3 changes: 3 additions & 0 deletions lib/outboxer/messages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,9 @@ def metrics(current_utc_time: Time.now.utc)
metrics[status][:throughput] = grouped_message.throughput
end

metrics[:published][:count][:total] =
metrics[:published][:count][:historic] + metrics[:published][:count][:current]

metrics
end
end
Expand Down
10 changes: 7 additions & 3 deletions lib/outboxer/web/views/home.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
<thead>
<tr>
<th scope="col">Status</th>
<th scope="col">Count</th>
<th scope="col">Throughput (per second)</th>
<th scope="col">Latency (seconds)</th>
<th scope="col">Current count</th>
<th scope="col">Throughput</th>
<th scope="col">Latency</th>
<th scope="col">Historic count</th>
<th scope="col">Total count</th>
</tr>
</thead>
<tbody>
Expand All @@ -25,6 +27,8 @@
<td><%= messages_metrics[status.to_sym][:count][:current] %></td>
<td><%= messages_metrics[status.to_sym][:throughput] %></td>
<td><%= messages_metrics[status.to_sym][:latency] %></td>
<td><%= messages_metrics[status.to_sym][:count][:historic] || '-' %></td>
<td><%= messages_metrics[status.to_sym][:count][:total] || '-' %></td>
</tr>
<% end %>
</tbody>
Expand Down
6 changes: 3 additions & 3 deletions spec/lib/outboxer/messages/metrics_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ module Outboxer
throughput: 0,
},
published: {
count: { current: 2, historic: 500 },
count: { historic: 500, current: 2, total: 502 },
latency: (current_utc_time - oldest_published_message.updated_at.utc).to_i,
throughput: 0,
},
Expand All @@ -93,7 +93,7 @@ module Outboxer
queued: { count: { current: 0 }, latency: 0, throughput: 0 },
dequeued: { count: { current: 0 }, latency: 0, throughput: 0 },
publishing: { count: { current: 0 }, latency: 0, throughput: 0 },
published: { count: { current: 0, historic: 0 }, latency: 0, throughput: 0 },
published: { count: { historic: 0, current: 0, total: 0 }, latency: 0, throughput: 0 },
failed: { count: { current: 0 }, latency: 0, throughput: 0 }
)
end
Expand All @@ -107,7 +107,7 @@ module Outboxer
queued: { count: { current: 0 }, latency: 0, throughput: 0 },
dequeued: { count: { current: 0 }, latency: 0, throughput: 0 },
publishing: { count: { current: 0 }, latency: 0, throughput: 0 },
published: { count: { current: 0, historic: 0 }, latency: 0, throughput: 0 },
published: { count: { historic: 0, current: 0, total: 0 }, latency: 0, throughput: 0 },
failed: { count: { current: 0 }, latency: 0, throughput: 0 }
)
end
Expand Down
Loading