Skip to content

Commit

Permalink
Fun/Consumed Budget Ratio metric (#413)
Browse files Browse the repository at this point in the history
* Add: *Consumed Budget Ratio metric added to report

* Add: *Consumed Budget Ratio metric added to report

* Add: *Consumed Budget Ratio metric added to report

* Add: Division by zero fixed

* Change made in setup.cfg for an issue related pip version vulnerability scanned by safety

* Change made in setup.cfg for an issue related pip version vulnerability scanned by safety

* Change made in setup.cfg for an issue related pip version vulnerability scanned by safety

* Rollback to pip 23.2

* Safety version setted to >=2.3.5

* consumed_budget_ratio renamed to error_budget_consumed_ratio

---------

Co-authored-by: Laurent Vaylet <[email protected]>
  • Loading branch information
mrtergl and lvaylet authored Jan 12, 2024
1 parent 743eacc commit 4d06fba
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions slo_generator/exporters/bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,11 @@ def _format(errors):
"type": "FLOAT",
"mode": "NULLABLE",
},
{
"name": "error_budget_consumed_ratio",
"type": "FLOAT",
"mode": "NULLABLE",
},
{
"name": "timestamp_human",
"type": "TIMESTAMP",
Expand Down
4 changes: 4 additions & 0 deletions slo_generator/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
LOGGER = logging.getLogger(__name__)


# pylint: disable=too-many-arguments,too-many-locals
@dataclass(init=False)
class SLOReport:
"""SLO report dataclass. Compute an SLO report out of an SLO config and an
Expand Down Expand Up @@ -60,6 +61,7 @@ class SLOReport:
error_budget_minutes: float
error_budget_remaining_minutes: float
error_minutes: float
error_budget_consumed_ratio: float

# Data validation
valid: bool
Expand Down Expand Up @@ -147,6 +149,7 @@ def build(self, step, data):
eb_remaining_minutes = self.window * gap / 60
eb_target_minutes = self.window * eb_target / 60
eb_minutes = self.window * eb_value / 60
eb_ratio = eb_value * 100 / eb_target if eb_target > 0 else 0
if eb_target == 0:
eb_burn_rate = 0
else:
Expand Down Expand Up @@ -178,6 +181,7 @@ def build(self, step, data):
error_budget_remaining_minutes=eb_remaining_minutes,
error_budget_minutes=eb_target_minutes,
error_minutes=eb_minutes,
error_budget_consumed_ratio=eb_ratio,
alert=alert,
consequence_message=consequence_message,
)
Expand Down
1 change: 1 addition & 0 deletions tests/unit/fixtures/slo_report_v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"error_budget_remaining_minutes": -288,
"error_budget_target": 0.09999999999999998,
"error_minutes": "360.0",
"error_budget_consumed_ratio": 19.9999999999999,
"events_count": 7112,
"gap": -0.4,
"goal": 0.9,
Expand Down

0 comments on commit 4d06fba

Please sign in to comment.