Skip to content

Commit

Permalink
bug: rename stanza to journey1 in testing mixin (#261)
Browse files Browse the repository at this point in the history
* bug: rename stanza to journey1 in testing mixin

* refactor: add error handling to avoid naming journey testing or test

* refactor: update the logic to compare product and journey name

* refactor: update error message
  • Loading branch information
mahrufiqbalHO authored Sep 30, 2022
1 parent b1df9e5 commit f92fb86
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion monitoring-as-code/mixin-defs/testing-mixin.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ local config = {
};

local sliSpecList = {
testing: {
journey1: {
SLI01: {
title: 'test',
sliDescription: 'test',
Expand Down
25 changes: 14 additions & 11 deletions monitoring-as-code/src/mixin-builder.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,20 @@ local updateSliSpec(sliType, sliSpec) =
// @param journeyKey The key of the journey containing the SLI having rules generated
// @returns The SLI with standard elements
local createSli(sliType, config, passedSliSpec, sliKey, journeyKey) =
local sliSpec = updateSliSpec(sliType, passedSliSpec);

if std.objectHas(macConfig.metricTypes, sliSpec.metricType) then
if std.objectHas(macConfig.metricTypes[sliSpec.metricType].sliTypesConfig, sliType) then
sliElementFunctions.createRecordingRules(sliSpec, config) +
sliElementFunctions.createSliStandardElements(sliKey, sliSpec) +
dashboardFunctions.createDashboardStandardElements(sliKey, journeyKey, sliSpec, config) +
alertFunctions.createBurnRateRules(sliSpec) +
alertFunctions.createBurnRateAlerts(config, sliSpec, sliKey, journeyKey)
else error 'Metric type %s does not have SLI type %s' % [sliSpec.metricType, sliType]
else error 'Undefined metric type %s' % sliSpec.metricType;
if journeyKey == config.product then
error 'Invalid Journey name [%s]. Journey name cannot match Product name [%s].' % [journeyKey, config.product]
else
local sliSpec = updateSliSpec(sliType, passedSliSpec);

if std.objectHas(macConfig.metricTypes, sliSpec.metricType) then
if std.objectHas(macConfig.metricTypes[sliSpec.metricType].sliTypesConfig, sliType) then
sliElementFunctions.createRecordingRules(sliSpec, config) +
sliElementFunctions.createSliStandardElements(sliKey, sliSpec) +
dashboardFunctions.createDashboardStandardElements(sliKey, journeyKey, sliSpec, config) +
alertFunctions.createBurnRateRules(sliSpec) +
alertFunctions.createBurnRateAlerts(config, sliSpec, sliKey, journeyKey)
else error 'Metric type %s does not have SLI type %s' % [sliSpec.metricType, sliType]
else error 'Undefined metric type %s' % sliSpec.metricType;

// Creates a list of all the SLIs in a service with their standard dashboard elements, unique
// dashboard elements, recording rules, alerting rules and alerts
Expand Down

0 comments on commit f92fb86

Please sign in to comment.