-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sqlmesh): add response time metrics (#2513)
* feat(sqlmesh): add prs days to merge model * fix: number to issue_number * feat(sqlmesh): add model for time to first response * fix: small syntax improvements * Add aux table to local duckdb * Fix local pull * Fix factory * Get response times and time to merge * use correct table --------- Co-authored-by: Reuven V. Gonzales <[email protected]>
- Loading branch information
Showing
10 changed files
with
145 additions
and
7 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
warehouse/metrics_mesh/models/code/issue_event_time_deltas.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
-- Model that records the delta (in seconds) since the creation of the issue or | ||
-- pr. | ||
MODEL ( | ||
name metrics.issue_event_time_deltas, | ||
kind VIEW | ||
); | ||
select `time`, | ||
event_type, | ||
event_source, | ||
@oso_id( | ||
event_source, | ||
to_artifact_id, | ||
issue_number | ||
) as issue_id, | ||
issue_number, | ||
to_artifact_id, | ||
from_artifact_id, | ||
created_at, | ||
merged_at, | ||
closed_at, | ||
date_diff('second', created_at, `time`) as created_delta, | ||
case | ||
when merged_at is null then null | ||
else date_diff('second', merged_at, `time`) | ||
end as merged_delta, | ||
case | ||
when closed_at is null then null | ||
else date_diff('second', closed_at, `time`) | ||
end as closed_delta, | ||
comments | ||
from @oso_source.timeseries_events_aux_issues_by_artifact_v0 |
22 changes: 22 additions & 0 deletions
22
warehouse/metrics_mesh/models/first_of_event_from_artifact.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
MODEL ( | ||
name metrics.first_of_event_from_artifact, | ||
kind FULL, | ||
partitioned_by (day("time"), "event_type", "event_source"), | ||
grain ( | ||
time, | ||
event_type, | ||
event_source, | ||
from_artifact_id, | ||
to_artifact_id | ||
), | ||
); | ||
select MIN(time) as time, | ||
event_type, | ||
event_source, | ||
from_artifact_id, | ||
to_artifact_id | ||
from @oso_source.timeseries_events_by_artifact_v0 | ||
group by event_type, | ||
event_source, | ||
from_artifact_id, | ||
to_artifact_id |
22 changes: 22 additions & 0 deletions
22
warehouse/metrics_mesh/models/last_of_event_from_artifact.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
MODEL ( | ||
name metrics.last_of_event_from_artifact, | ||
kind FULL, | ||
partitioned_by (day("time"), "event_type", "event_source"), | ||
grain ( | ||
time, | ||
event_type, | ||
event_source, | ||
from_artifact_id, | ||
to_artifact_id | ||
), | ||
); | ||
select MAX(time) as time, | ||
event_type, | ||
event_source, | ||
from_artifact_id, | ||
to_artifact_id | ||
from @oso_source.timeseries_events_by_artifact_v0 | ||
group by event_type, | ||
event_source, | ||
from_artifact_id, | ||
to_artifact_id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
select @metrics_sample_date(time) as metrics_sample_date, | ||
event_source, | ||
to_artifact_id, | ||
'' as from_artifact_id, | ||
@metric_name() as metric, | ||
AVG(created_delta) as amount | ||
from metrics.issue_event_time_deltas | ||
where event_type = 'PULL_REQUEST_MERGED' | ||
and `time` BETWEEN @metrics_start('DATE') and @metrics_end('DATE') | ||
group by 1, | ||
metric, | ||
from_artifact_id, | ||
to_artifact_id, | ||
event_source, |
23 changes: 23 additions & 0 deletions
23
warehouse/metrics_mesh/oso_metrics/time_to_first_response.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
select @metrics_sample_date(time) as metrics_sample_date, | ||
event_source, | ||
to_artifact_id, | ||
'' as from_artifact_id, | ||
@metric_name() as metric, | ||
AVG(created_delta) as amount | ||
from metrics.issue_event_time_deltas | ||
where ( | ||
( | ||
event_type in ("PULL_REQUEST_MERGED", "ISSUE_CLOSED") | ||
and comments = 0 | ||
) | ||
or ( | ||
event_type in ("PULL_REQUEST_REVIEW_COMMENT", "ISSUE_COMMENT") | ||
and comments = 1 | ||
) | ||
) | ||
and `time` BETWEEN @metrics_start('DATE') and @metrics_end('DATE') | ||
group by 1, | ||
metric, | ||
from_artifact_id, | ||
to_artifact_id, | ||
event_source, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters