Amount of incidents per 1,000 lines of code.
N/A
The number of incidents divided by total accumulated lines of code (additions + deletions) in the given data range.
Data Sources Required
issues collected from Jira, GitHub, TAPD or PagerDuty.commits collected from GitHub, GitLab or BitBucket.Data Transformation Required
This metric relies on the ‘type-incident’ configuration in Jira, GitHub or TAPD's transformation rules while adding/editing a blueprint. This configuration tells DevLake what issues are incidents.
SQL Queries
If you want to measure the monthly trend of Incidents per 1k lines of code in the screenshot below, please run the following SQL in Grafana.
with _line_of_code as (
select
DATE_ADD(date(authored_date), INTERVAL -DAY(date(authored_date))+1 DAY) as time,
sum(additions + deletions) as line_count
from
commits
where
message not like 'Merge%'
and $__timeFilter(authored_date)
group by 1
),
_incident_count as(
select
DATE_ADD(date(created_date), INTERVAL -DAY(date(created_date))+1 DAY) as time,
count(*) as incident_count
from issues i
where
type = 'INCIDENT'
and $__timeFilter(created_date)
group by 1
),
_incident_count_per_1k_loc as(
select
loc.time,
1.0 * ic.incident_count / loc.line_count * 1000 as incident_count_per_1k_loc
from
_line_of_code loc
left join _incident_count ic on ic.time = loc.time
where
ic.incident_count is not null
and loc.line_count is not null
and loc.line_count != 0
)
select
date_format(time,'%M %Y') as month,
incident_count_per_1k_loc as 'Incident Count per 1000 Lines of Code'
from _incident_count_per_1k_loc
order by time;