"Average" aggregate properties to calculate over whole time period rather than just available entities
M
Mark Tarry
In calculating metrics such as Deployment Frequency (https://dora.dev/guides/dora-metrics-four-keys/) for a particular service. We are trying to measure how often deployments are taking place. We interpret this as deployments
per week
into a production environment.So we introduce the following aggregate property to our "Service" blueprint:
```json
{
"aggregationProperties": {
"metric_avg_deployment_frequency_3_months": {
"title": "Deployment Frequency (3 months)",
"icon": "Metric",
"type": "number",
"description": "The average number of deployments to production each week, over the last 3 months, which have shipped from this repository",
"target": "deployment",
"query": {
"combinator": "and",
"rules": [
{
"operator": "=",
"property": "is_production",
"value": true
},
{
"operator": "between",
"property": "deployed_at",
"value": {
"preset": "last3Months"
}
}
]
},
"calculationSpec": {
"averageOf": "week",
"calculationBy": "entities",
"func": "average",
"measureTimeBy": "deployed_at"
}
}
}
}
```
What this seems to do is to filter down to the deployments within the timeframe, and then group the filtered results by week (based on
deployed_at
), count entities in each group, and calculate the mean average.This is fine - until you consider that any given service many not have had
any
deployments in some weeks. The average calculation divides by the number of weeks where entities were found - rather than the total number of weeks in a predetermined timeframe of, in the above example, 3 months.This can artificially inflate the average. As any service which has only deployed once in the timeframe automatically gets a Deployment Frequency of "1". Whereas services which deployed multiple times are scored lower. See attached screenshot.
I'm proposing an optional feature on aggregate properties, to calculate mean averages and take into account time periods where there is no data - i.e. count each period as zero. In order to calculate a more representative average.