ModusCreateOrg / gimbal

Web Performance Auditing tooling
https://labs.moduscreate.com/gimbal-web-performance-audit-budgeting
MIT License
115 stars 8 forks source link

First pass of a last value support, uses sqlite for the first pass #101

Closed mitchellsimoens closed 5 years ago

mitchellsimoens commented 5 years ago

Adds a "Last Value" column and calculates it. It also gets and saves the last value.

~This first pass has sqlite "hardcoded" but am working on a way to abstract the storage.~

For now, a sqlite plugin can be used to store historic runs. This can be configured easily.

Threshold Types

There are three threshold types:

Thresholds also can be upper or lower thresholds. If is an upper threshold, the value cannot exceed but can be equal. If is a lower threshold, the value cannot be below but can be equal.

Config

export interface Config {
  failOnBreach: boolean;
  saveOnlyOnSuccess: boolean;
  storage?: PluginConfig;
  thresholds: {
    diffPercentage: number;
    number: number;
    percentage: number;
    size: number;
  };
}

const defaultConfig: Config = {
  failOnBreach: false,
  saveOnlyOnSuccess: true,
  thresholds: {
    diffPercentage: 2,
    number: 1,
    percentage: 1,
    size: 1000,
  },
};

Storage

To enable storage, the last-value plugin fires two events: plugin/last-value/report/get & plugin/last-value/report/save. Both get the command name and the save gets the report. If is not the first save, the report items will have the last value, raw last value, the diff and the change (number 0-100 for percentage). This allows to add another plugin that can listen to these events.

Right now, the sqlite plugin has a lastValue config that will enable supporting the last-value plugin events. A sample .gimbalrc.yml would be:

plugins:
  - last-value
  - plugin: sqlite
    lastValue: true

Screenshots

Would present as a warning if over threshold warning

Would fail if over threshold and failOnBreach is set to true fail

Success if the item changed but under the threshold under_threshold

grgur commented 5 years ago

@mitchellsimoens waiting on you to merge and publish 👍