Skip to content

Conversation

@sanposhiho
Copy link
Member

What this PR does / why we need it:

Add a definition of function to pass data to plot the deployment frequency graph

Which issue(s) this PR fixes:

ref: #1142

Deployment Frequency: How often does your application/project deploy code to production.

Does this PR introduce a user-facing change?:

NONE

@nakabonne
Copy link
Member

The commit message (as well as the PR title) should start with an uppercase letter like "Add application...".

@sanposhiho sanposhiho changed the title add application deployment frequency proto file Add a definition of function for the deployment frequency graph Dec 2, 2020
@sanposhiho sanposhiho force-pushed the create-application-deployment-frequency-proto branch from a603228 to 174d9a8 Compare December 2, 2020 07:56

message GetApplicationDeploymentFrequencyRequest {
string application_id = 1 [(validate.rules).string.min_len = 1];
repeated int64 dates = 2;
Copy link
Contributor

Choose a reason for hiding this comment

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

@sanposhiho If we want to fetch for a week data, how we use this parameter?
[startDate, endDate] or [date1, date2, date3, ..., date7] ?

Copy link
Member Author

Choose a reason for hiding this comment

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

[date1, date2, date3, ..., date7], so that we may want to add filter for dates(not including holidays in the graph, etc.) later.

Copy link
Member

Choose a reason for hiding this comment

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

(not including holidays in the graph, etc.)

Agree with you 👍

Copy link
Collaborator

@pipecd-bot pipecd-bot left a comment

Choose a reason for hiding this comment

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

GO_LINTER

Some issues were detected while linting go source files in your changes.

}, nil
}

func (a *WebAPI) GetApplicationDeploymentFrequency(ctx context.Context, req *webservice.GetApplicationDeploymentFrequencyRequest) (*webservice.GetApplicationDeploymentFrequencyResponse, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

ctx is unused in GetApplicationDeploymentFrequency

}, nil
}

func (a *WebAPI) GetApplicationDeploymentFrequency(ctx context.Context, req *webservice.GetApplicationDeploymentFrequencyRequest) (*webservice.GetApplicationDeploymentFrequencyResponse, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

req is unused in GetApplicationDeploymentFrequency

Copy link
Collaborator

@pipecd-bot pipecd-bot left a comment

Choose a reason for hiding this comment

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

GO_LINTER

Some issues were detected while linting go source files in your changes.

}, nil
}

// [WIP] Made a temporary implementation to satisfy interface
Copy link
Collaborator

Choose a reason for hiding this comment

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

comment on exported method WebAPI.GetApplicationDeploymentFrequency should be of the form "GetApplicationDeploymentFrequency ..."

https://golang.org/wiki/CodeReviewComments#doc-comments

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 33.26%. This pull request decreases coverage by -0.01%.

File Function Base Head Diff
pkg/app/api/grpcapi/web_api.go WebAPI.GetApplicationDeploymentFrequency -- 0.00% +0.00%

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 33.26%. This pull request decreases coverage by -0.01%.

File Function Base Head Diff
pkg/app/api/grpcapi/web_api.go WebAPI.GetApplicationDeploymentFrequency -- 0.00% +0.00%

message GetApplicationDeploymentFrequencyResponse {
// key: date, value: deployment_count_of_the_day
map<int64, int64> deployment_counts = 1;
}
Copy link
Member

@nghialv nghialv Dec 2, 2020

Choose a reason for hiding this comment

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

I think we can abstract the models/definitions around this Insights functionality.
First of all, a graph can be considered as a series of data points.
So maybe only one rpc to retrieve the graph data is enough.

The web client sends a request that includes:

  • metrics_kind: what kind of metrics should be returned (deployment frequency, change failure rate, MTTR...)
  • step: the time unit (daily, weekly, monthly, yearly)
  • range: from when to when
  • filters: e.g. application id...

and the response will contain either a list of data points or an error.

Here are suggestions:

  • inside the model package
message InsightDataPoint {
   int64 timestamp
   float value
}

enum InsightMetricsKind {
   DEPLOYMENT_FREQUENCY
   CHANGE_FAILURE_RATE
   ...
}

enum InsightStep {
   DAILY
   WEEKLY
   ...
}
  • inside the service package
rpc GetInsightData()...

message GetInsightDataRequest{
   InsightMetricsKind metrics_kind;
   ...
}

message GetInsightDataResponse {
    int64 updated_at;
    repeated InsightDataPoint data_points;
}

Copy link
Member

Choose a reason for hiding this comment

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

Looks good. Some metrics kind may not be able to be represented by only timestamp and value alone, but then let's reconsider it at that time.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good :)
fixed like above.

}

// GetApplicationDeploymentFrequency [WIP] Made a temporary implementation to satisfy interface
func (a *WebAPI) GetApplicationDeploymentFrequency(ctx context.Context, req *webservice.GetApplicationDeploymentFrequencyRequest) (*webservice.GetApplicationDeploymentFrequencyResponse, error) {
Copy link
Member

Choose a reason for hiding this comment

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

With _, can be a clear indication of what not to use in a function.

Suggested change
func (a *WebAPI) GetApplicationDeploymentFrequency(ctx context.Context, req *webservice.GetApplicationDeploymentFrequencyRequest) (*webservice.GetApplicationDeploymentFrequencyResponse, error) {
func (a *WebAPI) GetApplicationDeploymentFrequency(_ context.Context, _ *webservice.GetApplicationDeploymentFrequencyRequest) (*webservice.GetApplicationDeploymentFrequencyResponse, error) {

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 33.27%. This pull request decreases coverage by -0.00%.

File Function Base Head Diff
pkg/app/api/grpcapi/web_api.go WebAPI.GetApplicationDeploymentFrequency -- 0.00% +0.00%

@pipecd-bot pipecd-bot added size/M and removed size/S labels Dec 3, 2020
@sanposhiho sanposhiho marked this pull request as ready for review December 3, 2020 02:48
@sanposhiho sanposhiho marked this pull request as draft December 3, 2020 02:48
repeated model.APIKey keys = 1;
}

message GetApplicationDeploymentFrequencyRequest {
Copy link
Member

Choose a reason for hiding this comment

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

Still is it needed? I feel like all operations can be done via GetInsightDataRequest.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, I forgot removing 👍

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 33.27%. This pull request decreases coverage by -0.00%.

File Function Base Head Diff
pkg/app/api/grpcapi/web_api.go WebAPI.GetInsightData -- 0.00% +0.00%

@sanposhiho sanposhiho marked this pull request as ready for review December 3, 2020 05:00
@nakabonne
Copy link
Member

/lgtm

@pipecd-bot pipecd-bot added the lgtm label Dec 3, 2020
enum InsightStep {
DAILY = 0;
WEEKLY = 1;
YEARLY = 2;
Copy link
Member

Choose a reason for hiding this comment

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

Missing the MONTHLY

option go_package = "github.com/pipe-cd/pipe/pkg/model";

message InsightDataPoint {
int64 timestamp = 1;
Copy link
Member

Choose a reason for hiding this comment

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

Please add the validation for this field.

message GetInsightDataResponse {
int64 updated_at = 1;
repeated pipe.model.InsightDataPoint data_points = 2;
}
Copy link
Member

Choose a reason for hiding this comment

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

Please add an empty line at the end of the file.

Copy link
Member

@khanhtc1202 khanhtc1202 Dec 3, 2020

Choose a reason for hiding this comment

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

Do we have lint for this kind of problem? Missing line at the end of the file is a regular issue. 👀

Copy link
Member

Choose a reason for hiding this comment

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

We were talking about that adding a Kapetanios plugin to perform the linter for protobuf before, but still not addressed it...

Copy link
Member

@khanhtc1202 khanhtc1202 Dec 3, 2020

Choose a reason for hiding this comment

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

I see, thanks 🙆‍♂️

pipe.model.InsightStep insight_step = 3;
int64 first_date = 4;
int64 last_date = 5;
}
Copy link
Member

Choose a reason for hiding this comment

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

Please add the validation for those fields.

// GetInsightData [WIP] Made a temporary implementation to satisfy interface
func (a *WebAPI) GetInsightData(_ context.Context, _ *webservice.GetInsightDataRequest) (*webservice.GetInsightDataResponse, error) {
return nil, nil
}
Copy link
Member

Choose a reason for hiding this comment

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

nit:

// GetInsightData returns the accumulated insight data.
func (a *WebAPI) GetInsightData(_ context.Context, _ *webservice.GetInsightDataRequest) (*webservice.GetInsightDataResponse, error) {
	return nil, status.Error(codes. Unimplemented, "")
}

message GetInsightDataRequest {
string application_id = 1 [(validate.rules).string.min_len = 1];
pipe.model.InsightMetricsKind metrics_kind = 2;
pipe.model.InsightStep insight_step = 3;
Copy link
Member

Choose a reason for hiding this comment

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

nit: I think "step" is fine. We are also using "metrics_kind" instead of "insight_metrics_kind"

pipe.model.InsightMetricsKind metrics_kind = 2;
pipe.model.InsightStep insight_step = 3;
int64 first_date = 4;
int64 last_date = 5;
Copy link
Member

Choose a reason for hiding this comment

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

These are the Unix times so, range_from, and range_to looks good.

pipe.model.InsightStep insight_step = 3;
int64 first_date = 4;
int64 last_date = 5;
}
Copy link
Member

Choose a reason for hiding this comment

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

Can we reorder the fields by their stability/importance. I mean the metrics_kind must be required so it should at the top.

metrics_kind
step
range_from
range_to
application_id

}

message GetInsightDataRequest {
string application_id = 1 [(validate.rules).string.min_len = 1];
Copy link
Member

Choose a reason for hiding this comment

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

I think the application id is optional.
If it was specified we find the data for only the specified one.
If it was empty, we find the data for the whole project.

@nghialv
Copy link
Member

nghialv commented Dec 3, 2020

@sanposhiho Thank you. I have just left some comments.

@pipecd-bot pipecd-bot removed the lgtm label Dec 3, 2020
@sanposhiho
Copy link
Member Author

@nghialv
Thanks for much reviews :D

Fix:

  • add validation on some fields
  • rename some fields

@nghialv
Copy link
Member

nghialv commented Dec 3, 2020

Nice. Thank you.
/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 162c018 into master Dec 3, 2020
@pipecd-bot pipecd-bot deleted the create-application-deployment-frequency-proto branch December 3, 2020 06:45
@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.

7 participants