Class: Dash::Report::Trends

Inherits:
Object
  • Object
show all
Defined in:
lib/dash/report/trends.rb

Overview

Compares this run with the last few saved reports of the same command and destination.

The Dockerfile rules can only see what one build looked like; these see what a project's deploys usually look like, which is the only way to tell "the build takes 84 seconds" from "the build suddenly takes twice what it used to". Everything here is informational: a slow deploy is a fact about today, not a defect to fix.

The phase names are the ones a deploy records in Dash::Cli::Main and Dash::Cli::Base. They are pinned from the other side by test/cli/main_test.rb, which asserts the table a real deploy prints, so a rename cannot quietly turn these rules off.

Constant Summary collapse

BUILD_PHASE =
"Build and push app image".freeze
BOOT_PHASE =
"Boot".freeze
OVERHEAD_PHASES =

Everything a deploy spends before and around the work itself: loading the gem, parsing the config, resolving secrets, and taking the locks.

[ "Startup (load, config)", "Validate config and secrets",
"Acquire deploy lock", "Acquire server lock" ].freeze
MINIMUM_HISTORY =

Two deploys are an anecdote. Three are the fewest that can have a median worth comparing against.

3
WINDOW =
5
FACTOR =
1.5
OVERHEAD_FLOOR =

Overhead this large is worth naming even to a project whose deploys have always carried it — "normal" is not the same as "cheap".

10.0
LOCATION =
"deploy history".freeze

Instance Method Summary collapse

Constructor Details

#initialize(document, history: [], ignore: []) ⇒ Trends

Returns a new instance of Trends.



30
31
32
33
34
# File 'lib/dash/report/trends.rb', line 30

def initialize(document, history: [], ignore: [])
  @document = document
  @history = comparable(history)
  @ignore = Array(ignore).map(&:to_s)
end

Instance Method Details

#findings ⇒ Object



36
37
38
39
40
# File 'lib/dash/report/trends.rb', line 36

def findings
  return [] if @history.size < MINIMUM_HISTORY

  [ build_finding, boot_finding, overhead_finding, total_finding ].compact.reject { |finding| @ignore.include?(finding.rule) }
end