Skip to content

Commit

Permalink
Add specific metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
tschaefer committed Jan 14, 2025
1 parent d70cb7e commit 1451097
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
4 changes: 3 additions & 1 deletion app/jobs/stack_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ def perform(stack)

def execute
script = render_script(@stack, @assets)
run_script(script)
Yabeda.supervisor.stack_jobs_runtime.measure do
run_script(script)
end
return if instance_of?(StackDestroyJob)

stack_log
Expand Down
12 changes: 11 additions & 1 deletion app/models/stack/has_stats.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,24 @@ def update_stats(succeeded: false, action: nil)
last_action: action || 'unknown'
)

Yabeda.supervisor.stack_processed_count.increment(
status = succeeded ? 'succeeded' : 'failed'

Yabeda.supervisor.stack_jobs_executed_total.increment(
{
name: name,
action: last_action,
status: succeeded ? 'succeeded' : 'failed'
},
by: 1
)

Yabeda.supervisor.send(:"stack_jobs_#{status}_total").increment(
{
name: name,
action: last_action
},
by: 1
)
end
end
end
Expand Down
21 changes: 20 additions & 1 deletion config/initializers/yabeda.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,26 @@

Yabeda.configure do
group :supervisor do
counter :stack_processed_count, comment: 'Total number of stack jobs processed', tags: %i[name action status]
counter :stack_jobs_executed_total do
comment 'Total number of stack jobs executed'
tags %i[name action status]
end
counter :stack_jobs_failed_total do
comment 'Total number of failed stack jobs'
tags %i[name action]
end
counter :stack_jobs_succeeded_total do
comment 'Total number of succeeded stack jobs'
tags %i[name action]
end
histogram :stack_jobs_runtime do
comment 'Total time taken to execute stack jobs'
unit :seconds
buckets [
0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10,
30, 60, 120, 300, 1800, 3600, 86_400
].freeze
end
end
end

Expand Down

0 comments on commit 1451097

Please sign in to comment.