-
Notifications
You must be signed in to change notification settings - Fork 204
Create insight data for change failure rate #1197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create insight data for change failure rate #1197
Conversation
|
The golinter build is completed with FAILURE. The build will be triggered again when you push any other commits. Or you can trigger it manually by You can check the build log from here. |
|
The golinter build is completed with FAILURE. The build will be triggered again when you push any other commits. Or you can trigger it manually by You can check the build log from here. |
|
Code coverage for golang is
|
pkg/app/api/grpcapi/web_api.go
Outdated
| case model.InsightMetricsKind_DEPLOYMENT_FREQUENCY: | ||
| count, err := a.getInsightDataForDeployFrequency(ctx, projectID, req.ApplicationId, targetRangeFrom, targetRangeTo) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| counts[i] = count | ||
| case model.InsightMetricsKind_CHANGE_FAILURE_RATE: | ||
| count, err := a.getInsightDataForChangeFailureRate(ctx, projectID, req.ApplicationId, targetRangeFrom, targetRangeTo) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| counts[i] = count |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: To avoid to be deeply nested, why not just do like:
var getInsightData func(context.Context, string, string, time.Time, time.Time)
switch req.MetricsKind {
case model.InsightMetricsKind_DEPLOYMENT_FREQUENCY:
getInsightData = getInsightDataForDeployFrequency
case model.InsightMetricsKind_CHANGE_FAILURE_RATE:
getInsightData = getInsightDataForChangeFailureRate
...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great idea. Thanks :)
|
Code coverage for golang is
|
pkg/app/api/grpcapi/web_api.go
Outdated
| successCount := len(successDeployments) | ||
| failureCount := len(failureDeployments) | ||
|
|
||
| changeFailureRate := float32(failureCount) / float32(successCount+failureCount) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The number of deployments can be zero.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still didn't know enough about math...
(I thought 0/0 = 1)
|
Code coverage for golang is
|
pkg/app/api/grpcapi/web_api.go
Outdated
| if successCount+failureCount != 0 { | ||
| changeFailureRate = float32(failureCount) / float32(successCount+failureCount) | ||
| } else { | ||
| changeFailureRate = 1.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be 0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, Thanks :D
|
Code coverage for golang is
|
|
/approve |
What this PR does / why we need it:
Which issue(s) this PR fixes:
ref #1142
Does this PR introduce a user-facing change?: