Skip to content

Conversation

@sanposhiho
Copy link
Member

What this PR does / why we need it:

  • Create insight data for change failure rate

Which issue(s) this PR fixes:

ref #1142

Does this PR introduce a user-facing change?:

NONE

@pipecd-bot
Copy link
Collaborator

KAPETANIOS

Failed while validating Kapetanios configuration.

Details
Error: rpc error: code = NotFound desc = not found

@pipecd-bot
Copy link
Collaborator

GO_LINTER

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 /golinter trigger command right now.

You can check the build log from here.

@pipecd-bot
Copy link
Collaborator

GO_LINTER

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 /golinter trigger command right now.

You can check the build log from here.

@pipecd-bot pipecd-bot added size/L and removed size/XL labels Dec 7, 2020
@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 33.81%. This pull request increases coverage by 0.15%.

File Function Base Head Diff
pkg/app/api/grpcapi/web_api.go WebAPI.calculateInsightData -- 68.00% +68.00%
pkg/app/api/grpcapi/web_api.go WebAPI.getInsightDataForChangeFailureRate -- 88.89% +88.89%
pkg/app/api/grpcapi/web_api.go WebAPI.GetInsightData 0.00% 0.00% +0.00%
pkg/app/api/grpcapi/web_api.go WebAPI.getInsightDataForDeployFrequency 91.30% 100.00% +8.70%

Comment on lines 1351 to 1362
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
Copy link
Member

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
...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea. Thanks :)

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 33.84%. This pull request increases coverage by 0.18%.

File Function Base Head Diff
pkg/app/api/grpcapi/web_api.go WebAPI.getInsightData -- 79.17% +79.17%
pkg/app/api/grpcapi/web_api.go WebAPI.getInsightDataForChangeFailureRate -- 88.89% +88.89%
pkg/app/api/grpcapi/web_api.go WebAPI.GetInsightData 0.00% 0.00% +0.00%
pkg/app/api/grpcapi/web_api.go WebAPI.getInsightDataForDeployFrequency 91.30% 100.00% +8.70%

successCount := len(successDeployments)
failureCount := len(failureDeployments)

changeFailureRate := float32(failureCount) / float32(successCount+failureCount)
Copy link
Member

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.

Copy link
Member Author

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)

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 33.86%. This pull request increases coverage by 0.19%.

File Function Base Head Diff
pkg/app/api/grpcapi/web_api.go WebAPI.getInsightData -- 79.17% +79.17%
pkg/app/api/grpcapi/web_api.go WebAPI.getInsightDataForChangeFailureRate -- 85.71% +85.71%
pkg/app/api/grpcapi/web_api.go WebAPI.GetInsightData 0.00% 0.00% +0.00%
pkg/app/api/grpcapi/web_api.go WebAPI.getInsightDataForDeployFrequency 91.30% 100.00% +8.70%

if successCount+failureCount != 0 {
changeFailureRate = float32(failureCount) / float32(successCount+failureCount)
} else {
changeFailureRate = 1.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be 0.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, Thanks :D

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 33.86%. This pull request increases coverage by 0.19%.

File Function Base Head Diff
pkg/app/api/grpcapi/web_api.go WebAPI.getInsightData -- 79.17% +79.17%
pkg/app/api/grpcapi/web_api.go WebAPI.getInsightDataForChangeFailureRate -- 85.71% +85.71%
pkg/app/api/grpcapi/web_api.go WebAPI.getInsightDataForDeployFrequency 91.30% 100.00% +8.70%
pkg/app/api/grpcapi/web_api.go WebAPI.GetInsightData 0.00% 0.00% +0.00%

@nghialv
Copy link
Member

nghialv commented Dec 9, 2020

/approve

@pipecd-bot
Copy link
Collaborator

APPROVE

This pull request is APPROVED by nghialv.

Approvers can cancel the approval by writing /approve cancel in a comment. Any additional commits also will change this pull request to be not-approved.

@pipecd-bot pipecd-bot merged commit 7881b89 into master Dec 9, 2020
@pipecd-bot pipecd-bot deleted the create-insight-data-for-change-failure-rate branch December 9, 2020 04:22
@pipecd-bot pipecd-bot mentioned this pull request Dec 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants