Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
populate monitors_enabled_unique_users (#57163)
Browse files Browse the repository at this point in the history
* populate monitors_enabled_unique_users and monitors_enabled_last_run_errored code monitors so they don't return nil
* remove code_monitors_last_run_errored
* adds comment about unpopulated monitors_enabled_last_run_errored
  • Loading branch information
jasonhawkharris authored Sep 28, 2023
1 parent 52a66a9 commit dd3cf57
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
14 changes: 8 additions & 6 deletions internal/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1837,12 +1837,14 @@ type CodeMonitoringUsageStatistics struct {
WebhookActionsEnabledUniqueUsers *int32
MonitorsEnabled *int32
MonitorsEnabledUniqueUsers *int32
MonitorsEnabledLastRunErrored *int32
ReposMonitored *int32
TriggerRuns *int32
TriggerRunsErrored *int32
P50TriggerRunTimeSeconds *float32
P90TriggerRunTimeSeconds *float32
// (TODO @jasonhawkharris ) Currently, MonitorsEnabledLastRunErrored is unpopulated
// It will require adjusting the query to select a row inside of a group
MonitorsEnabledLastRunErrored *int32
ReposMonitored *int32
TriggerRuns *int32
TriggerRunsErrored *int32
P50TriggerRunTimeSeconds *float32
P90TriggerRunTimeSeconds *float32
}

type NotebooksUsageStatistics struct {
Expand Down
1 change: 1 addition & 0 deletions internal/usagestats/code_monitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func GetCodeMonitoringUsageStatistics(ctx context.Context, db database.DB) (*typ
&stats.P50TriggerRunTimeSeconds,
&stats.P90TriggerRunTimeSeconds,
&stats.MonitorsEnabled,
&stats.MonitorsEnabledUniqueUsers,
); err != nil {
return nil, err
}
Expand Down
1 change: 1 addition & 0 deletions internal/usagestats/code_monitoring_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ func TestCodeMonitoringUsageStatistics(t *testing.T) {
P50TriggerRunTimeSeconds: ptr(float32(3)),
P90TriggerRunTimeSeconds: ptr(float32(6)),
MonitorsEnabled: ptr(int32(8)),
MonitorsEnabledUniqueUsers: ptr(int32(8)),
}
require.Equal(t, want, have)
}
Expand Down
6 changes: 5 additions & 1 deletion internal/usagestats/code_monitoring_usage_stats.sql
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@ SELECT
-- monitors_enabled
COALESCE(slack_actions.slack_actions_enabled, 0) +
COALESCE(email_actions.email_actions_enabled, 0) +
COALESCE(webhook_actions.webhook_actions_enabled, 0) AS monitors_enabled
COALESCE(webhook_actions.webhook_actions_enabled, 0) AS monitors_enabled,
-- monitors_enabled_unique_users
COALESCE(slack_actions.slack_actions_enabled_unique_users, 0) +
COALESCE(email_actions.email_actions_enabled_unique_users, 0) +
COALESCE(webhook_actions.webhook_actions_enabled_unique_users, 0) AS monitors_enabled_unique_users
FROM
event_log_stats,
email_actions,
Expand Down

0 comments on commit dd3cf57

Please sign in to comment.