From 27651927610666eda6a3833b8473f4b6ab2648a7 Mon Sep 17 00:00:00 2001 From: sanposhiho Date: Wed, 2 Dec 2020 16:31:19 +0900 Subject: [PATCH 01/14] Add application deployment frequency proto file --- pkg/app/api/service/webservice/service.proto | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pkg/app/api/service/webservice/service.proto b/pkg/app/api/service/webservice/service.proto index 18e560f296..24d04c98b8 100644 --- a/pkg/app/api/service/webservice/service.proto +++ b/pkg/app/api/service/webservice/service.proto @@ -85,6 +85,9 @@ service WebService { rpc GenerateAPIKey(GenerateAPIKeyRequest) returns (GenerateAPIKeyResponse) {} rpc DisableAPIKey(DisableAPIKeyRequest) returns (DisableAPIKeyResponse) {} rpc ListAPIKeys(ListAPIKeysRequest) returns (ListAPIKeysResponse) {} + + // Insights + rpc GetApplicationDeploymentFrequency(GetApplicationDeploymentFrequencyRequest) returns (GetApplicationDeploymentFrequencyResponse) {} } message AddEnvironmentResponse { @@ -401,3 +404,13 @@ message ListAPIKeysRequest { message ListAPIKeysResponse { repeated model.APIKey keys = 1; } + +message GetApplicationDeploymentFrequencyRequest { + string application_id = 1 [(validate.rules).string.min_len = 1]; + repeated int64 days = 2; +} + +message GetApplicationDeploymentFrequencyResponse { + // key: day, value: deployment_count_of_the_day + map deployment_counts = 1; +} From 174d9a8a85958f5a4ab64c185bf0cf5d30df776b Mon Sep 17 00:00:00 2001 From: sanposhiho Date: Wed, 2 Dec 2020 16:40:05 +0900 Subject: [PATCH 02/14] Fix words day to date --- pkg/app/api/service/webservice/service.proto | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/app/api/service/webservice/service.proto b/pkg/app/api/service/webservice/service.proto index 24d04c98b8..b4117765c2 100644 --- a/pkg/app/api/service/webservice/service.proto +++ b/pkg/app/api/service/webservice/service.proto @@ -407,10 +407,10 @@ message ListAPIKeysResponse { message GetApplicationDeploymentFrequencyRequest { string application_id = 1 [(validate.rules).string.min_len = 1]; - repeated int64 days = 2; + repeated int64 dates = 2; } message GetApplicationDeploymentFrequencyResponse { - // key: day, value: deployment_count_of_the_day + // key: date, value: deployment_count_of_the_day map deployment_counts = 1; } From 4bd45055d6ab5a62d5d02af7851e5ddb4eca5eab Mon Sep 17 00:00:00 2001 From: sanposhiho Date: Wed, 2 Dec 2020 17:56:55 +0900 Subject: [PATCH 03/14] Add function GetApplicationDeploymentFrequency to satisfy interface --- pkg/app/api/grpcapi/web_api.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/app/api/grpcapi/web_api.go b/pkg/app/api/grpcapi/web_api.go index f0eb8e144b..095eda2aea 100644 --- a/pkg/app/api/grpcapi/web_api.go +++ b/pkg/app/api/grpcapi/web_api.go @@ -1309,3 +1309,7 @@ func (a *WebAPI) ListAPIKeys(ctx context.Context, req *webservice.ListAPIKeysReq Keys: apiKeys, }, nil } + +func (a *WebAPI) GetApplicationDeploymentFrequency(ctx context.Context, req *webservice.GetApplicationDeploymentFrequencyRequest) (*webservice.GetApplicationDeploymentFrequencyResponse, error) { + return nil, nil +} From 117bd27d95f1f59aae289c307fee25d84065356e Mon Sep 17 00:00:00 2001 From: sanposhiho Date: Wed, 2 Dec 2020 18:42:07 +0900 Subject: [PATCH 04/14] Fix to pass golangci-lint and comment about temporary implementation --- pkg/app/api/grpcapi/web_api.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/app/api/grpcapi/web_api.go b/pkg/app/api/grpcapi/web_api.go index 095eda2aea..f2418eb9d4 100644 --- a/pkg/app/api/grpcapi/web_api.go +++ b/pkg/app/api/grpcapi/web_api.go @@ -1310,6 +1310,11 @@ func (a *WebAPI) ListAPIKeys(ctx context.Context, req *webservice.ListAPIKeysReq }, nil } +// [WIP] Made a temporary implementation to satisfy interface func (a *WebAPI) GetApplicationDeploymentFrequency(ctx context.Context, req *webservice.GetApplicationDeploymentFrequencyRequest) (*webservice.GetApplicationDeploymentFrequencyResponse, error) { + // to pass golangci-lint(unused) check + fmt.Print(ctx) + fmt.Print(req) + return nil, nil } From fae84f51e4aaa4e9a5812e4ced950dece2bc04e2 Mon Sep 17 00:00:00 2001 From: sanposhiho Date: Wed, 2 Dec 2020 18:48:40 +0900 Subject: [PATCH 05/14] Format comment with the way of golint --- pkg/app/api/grpcapi/web_api.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/app/api/grpcapi/web_api.go b/pkg/app/api/grpcapi/web_api.go index f2418eb9d4..3a43758c77 100644 --- a/pkg/app/api/grpcapi/web_api.go +++ b/pkg/app/api/grpcapi/web_api.go @@ -1310,7 +1310,7 @@ func (a *WebAPI) ListAPIKeys(ctx context.Context, req *webservice.ListAPIKeysReq }, nil } -// [WIP] Made a temporary implementation to satisfy interface +// GetApplicationDeploymentFrequency [WIP] Made a temporary implementation to satisfy interface func (a *WebAPI) GetApplicationDeploymentFrequency(ctx context.Context, req *webservice.GetApplicationDeploymentFrequencyRequest) (*webservice.GetApplicationDeploymentFrequencyResponse, error) { // to pass golangci-lint(unused) check fmt.Print(ctx) From 566976bd7662ec3a69ae59ce60bdd58e295c3d06 Mon Sep 17 00:00:00 2001 From: sanposhiho Date: Thu, 3 Dec 2020 09:27:51 +0900 Subject: [PATCH 06/14] Fix to use blank identifier --- pkg/app/api/grpcapi/web_api.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pkg/app/api/grpcapi/web_api.go b/pkg/app/api/grpcapi/web_api.go index 3a43758c77..f7f33a0615 100644 --- a/pkg/app/api/grpcapi/web_api.go +++ b/pkg/app/api/grpcapi/web_api.go @@ -1311,10 +1311,6 @@ func (a *WebAPI) ListAPIKeys(ctx context.Context, req *webservice.ListAPIKeysReq } // GetApplicationDeploymentFrequency [WIP] Made a temporary implementation to satisfy interface -func (a *WebAPI) GetApplicationDeploymentFrequency(ctx context.Context, req *webservice.GetApplicationDeploymentFrequencyRequest) (*webservice.GetApplicationDeploymentFrequencyResponse, error) { - // to pass golangci-lint(unused) check - fmt.Print(ctx) - fmt.Print(req) - +func (a *WebAPI) GetApplicationDeploymentFrequency(_ context.Context, _ *webservice.GetApplicationDeploymentFrequencyRequest) (*webservice.GetApplicationDeploymentFrequencyResponse, error) { return nil, nil } From e1084a5b80e3fa27020e66c7d55ed8bd90e82fc0 Mon Sep 17 00:00:00 2001 From: sanposhiho Date: Thu, 3 Dec 2020 10:48:15 +0900 Subject: [PATCH 07/14] Fix to be able to use same rpc to other insights graph --- pkg/app/api/grpcapi/web_api.go | 4 +- pkg/app/api/service/webservice/insight.proto | 39 ++++++++++++++++++++ pkg/app/api/service/webservice/service.proto | 15 +++++++- 3 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 pkg/app/api/service/webservice/insight.proto diff --git a/pkg/app/api/grpcapi/web_api.go b/pkg/app/api/grpcapi/web_api.go index f7f33a0615..5c85c8573c 100644 --- a/pkg/app/api/grpcapi/web_api.go +++ b/pkg/app/api/grpcapi/web_api.go @@ -1310,7 +1310,7 @@ func (a *WebAPI) ListAPIKeys(ctx context.Context, req *webservice.ListAPIKeysReq }, nil } -// GetApplicationDeploymentFrequency [WIP] Made a temporary implementation to satisfy interface -func (a *WebAPI) GetApplicationDeploymentFrequency(_ context.Context, _ *webservice.GetApplicationDeploymentFrequencyRequest) (*webservice.GetApplicationDeploymentFrequencyResponse, error) { +// GetInsightData [WIP] Made a temporary implementation to satisfy interface +func (a *WebAPI) GetInsightData(_ context.Context, _ *webservice.GetInsightDataRequest) (*webservice.GetInsightDataResponse, error) { return nil, nil } diff --git a/pkg/app/api/service/webservice/insight.proto b/pkg/app/api/service/webservice/insight.proto new file mode 100644 index 0000000000..f593186ae4 --- /dev/null +++ b/pkg/app/api/service/webservice/insight.proto @@ -0,0 +1,39 @@ +// Copyright 2020 The PipeCD Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package pipe.model; +option go_package = "github.com/pipe-cd/pipe/pkg/model"; + +import "validate/validate.proto"; +import "pkg/model/common.proto"; + +message insightDataPoint { + int64 timestamp = 1; + float value = 2; +} + +enum InsightMetricsKind { + DEPLOYMENT_FREQUENCY = 0; + CHANGE_FAILURE_RATE = 1; + MTTR = 2; + LEAD_TIME_FOR_CHANGES = 3; +} + +enum InsightStep { + DAILY = 0; + WEEKLY = 1; + YEARLY = 2; +} diff --git a/pkg/app/api/service/webservice/service.proto b/pkg/app/api/service/webservice/service.proto index b4117765c2..23c04fd569 100644 --- a/pkg/app/api/service/webservice/service.proto +++ b/pkg/app/api/service/webservice/service.proto @@ -19,6 +19,7 @@ option go_package = "github.com/pipe-cd/pipe/pkg/app/api/service/webservice"; import "validate/validate.proto"; import "pkg/model/common.proto"; +import "pkg/model/insight.proto"; import "pkg/model/application.proto"; import "pkg/model/application_live_state.proto"; import "pkg/model/command.proto"; @@ -87,7 +88,7 @@ service WebService { rpc ListAPIKeys(ListAPIKeysRequest) returns (ListAPIKeysResponse) {} // Insights - rpc GetApplicationDeploymentFrequency(GetApplicationDeploymentFrequencyRequest) returns (GetApplicationDeploymentFrequencyResponse) {} + rpc GetInsightData(GetInsightDataRequest) returns (GetInsightDataResponse) {} } message AddEnvironmentResponse { @@ -414,3 +415,15 @@ message GetApplicationDeploymentFrequencyResponse { // key: date, value: deployment_count_of_the_day map deployment_counts = 1; } + +message GetInsightDataRequest { + string application_id = 1 [(validate.rules).string.min_len = 1]; + pipe.model.InsightMetricsKind metrics_kind = 2; + pipe.model.InsightStep insight_step = 3; + int64 first_date = 4; + int64 last_date = 5; +} +message GetInsightDataResponse { + int64 updated_at = 1; + repeated pipe.model.InsightDataPoint data_points = 2; +} \ No newline at end of file From 4cf59c7bc50876e17b80fa1adb4d556f3d701d11 Mon Sep 17 00:00:00 2001 From: sanposhiho Date: Thu, 3 Dec 2020 11:50:49 +0900 Subject: [PATCH 08/14] Fix proto file path --- pkg/{app/api/service/webservice => model}/insight.proto | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename pkg/{app/api/service/webservice => model}/insight.proto (100%) diff --git a/pkg/app/api/service/webservice/insight.proto b/pkg/model/insight.proto similarity index 100% rename from pkg/app/api/service/webservice/insight.proto rename to pkg/model/insight.proto From d501d705348d4948b0b2be43102394b9b217cf1a Mon Sep 17 00:00:00 2001 From: sanposhiho Date: Thu, 3 Dec 2020 12:29:38 +0900 Subject: [PATCH 09/14] Fix typo and rm unuse import --- pkg/model/insight.proto | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pkg/model/insight.proto b/pkg/model/insight.proto index f593186ae4..986228e7c3 100644 --- a/pkg/model/insight.proto +++ b/pkg/model/insight.proto @@ -17,10 +17,7 @@ syntax = "proto3"; package pipe.model; option go_package = "github.com/pipe-cd/pipe/pkg/model"; -import "validate/validate.proto"; -import "pkg/model/common.proto"; - -message insightDataPoint { +message InsightDataPoint { int64 timestamp = 1; float value = 2; } From b87b50b4993a93317809e3416a4eab096cc928ec Mon Sep 17 00:00:00 2001 From: sanposhiho Date: Thu, 3 Dec 2020 12:31:46 +0900 Subject: [PATCH 10/14] Add insight.proto --- pkg/model/BUILD.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/model/BUILD.bazel b/pkg/model/BUILD.bazel index 2f7dd0e90f..cc55ea480c 100644 --- a/pkg/model/BUILD.bazel +++ b/pkg/model/BUILD.bazel @@ -13,6 +13,7 @@ proto_library( "environment.proto", "event.proto", "logblock.proto", + "insight.proto", "piped.proto", "piped_stats.proto", "project.proto", From b24c7a4304570d92811dc836ee546a50e1c4efb0 Mon Sep 17 00:00:00 2001 From: sanposhiho Date: Thu, 3 Dec 2020 12:32:12 +0900 Subject: [PATCH 11/14] Remove unuse message --- pkg/app/api/service/webservice/service.proto | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/pkg/app/api/service/webservice/service.proto b/pkg/app/api/service/webservice/service.proto index 23c04fd569..0217b5a5df 100644 --- a/pkg/app/api/service/webservice/service.proto +++ b/pkg/app/api/service/webservice/service.proto @@ -406,16 +406,6 @@ message ListAPIKeysResponse { repeated model.APIKey keys = 1; } -message GetApplicationDeploymentFrequencyRequest { - string application_id = 1 [(validate.rules).string.min_len = 1]; - repeated int64 dates = 2; -} - -message GetApplicationDeploymentFrequencyResponse { - // key: date, value: deployment_count_of_the_day - map deployment_counts = 1; -} - message GetInsightDataRequest { string application_id = 1 [(validate.rules).string.min_len = 1]; pipe.model.InsightMetricsKind metrics_kind = 2; From d2c5d9d1a0e3bdc48771a7db1995740fcd9b3913 Mon Sep 17 00:00:00 2001 From: Kensei Nakada <44139130+sanposhiho@users.noreply.github.com> Date: Thu, 3 Dec 2020 12:37:58 +0900 Subject: [PATCH 12/14] Rename to LEAD_TIME Co-authored-by: Ryo Nakao --- pkg/model/insight.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/model/insight.proto b/pkg/model/insight.proto index 986228e7c3..113170ec23 100644 --- a/pkg/model/insight.proto +++ b/pkg/model/insight.proto @@ -26,7 +26,7 @@ enum InsightMetricsKind { DEPLOYMENT_FREQUENCY = 0; CHANGE_FAILURE_RATE = 1; MTTR = 2; - LEAD_TIME_FOR_CHANGES = 3; + LEAD_TIME = 3; } enum InsightStep { From e6b4ba318e47a6b2a4ebc81c9c27afa3d48bf3a6 Mon Sep 17 00:00:00 2001 From: sanposhiho Date: Thu, 3 Dec 2020 15:29:51 +0900 Subject: [PATCH 13/14] Add some validate and rename some fields --- pkg/app/api/service/webservice/service.proto | 13 +++++++------ pkg/model/insight.proto | 11 +++++++---- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/pkg/app/api/service/webservice/service.proto b/pkg/app/api/service/webservice/service.proto index 0217b5a5df..ceb2b02395 100644 --- a/pkg/app/api/service/webservice/service.proto +++ b/pkg/app/api/service/webservice/service.proto @@ -407,13 +407,14 @@ message ListAPIKeysResponse { } message GetInsightDataRequest { - string application_id = 1 [(validate.rules).string.min_len = 1]; - pipe.model.InsightMetricsKind metrics_kind = 2; - pipe.model.InsightStep insight_step = 3; - int64 first_date = 4; - int64 last_date = 5; + pipe.model.InsightMetricsKind metrics_kind = 1 [(validate.rules).enum.defined_only = true]; + pipe.model.InsightStep step = 2 [(validate.rules).enum.defined_only = true]; + int64 range_from = 3 [(validate.rules).int64.gt = 0]; + int64 range_to = 4 [(validate.rules).int64.gt = 0]; + string application_id = 5; } + message GetInsightDataResponse { int64 updated_at = 1; repeated pipe.model.InsightDataPoint data_points = 2; -} \ No newline at end of file +} diff --git a/pkg/model/insight.proto b/pkg/model/insight.proto index 986228e7c3..35a774b4ed 100644 --- a/pkg/model/insight.proto +++ b/pkg/model/insight.proto @@ -17,20 +17,23 @@ syntax = "proto3"; package pipe.model; option go_package = "github.com/pipe-cd/pipe/pkg/model"; +import "validate/validate.proto"; + message InsightDataPoint { - int64 timestamp = 1; - float value = 2; + int64 timestamp = 1 [(validate.rules).int64.gt = 0]; + float value = 2 [(validate.rules).float.gt = 0]; } enum InsightMetricsKind { DEPLOYMENT_FREQUENCY = 0; CHANGE_FAILURE_RATE = 1; MTTR = 2; - LEAD_TIME_FOR_CHANGES = 3; + LEAD_TIME = 3; } enum InsightStep { DAILY = 0; WEEKLY = 1; - YEARLY = 2; + MONTHLY = 2; + YEARLY = 3; } From dab071c46d482fb9d82dd5313bce6fbffa9fa9df Mon Sep 17 00:00:00 2001 From: sanposhiho Date: Thu, 3 Dec 2020 15:30:32 +0900 Subject: [PATCH 14/14] Fix to reponse Unimplemented --- pkg/app/api/grpcapi/web_api.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/app/api/grpcapi/web_api.go b/pkg/app/api/grpcapi/web_api.go index 5c85c8573c..80857efdeb 100644 --- a/pkg/app/api/grpcapi/web_api.go +++ b/pkg/app/api/grpcapi/web_api.go @@ -1310,7 +1310,7 @@ func (a *WebAPI) ListAPIKeys(ctx context.Context, req *webservice.ListAPIKeysReq }, nil } -// GetInsightData [WIP] Made a temporary implementation to satisfy interface +// GetInsightData returns the accumulated insight data. func (a *WebAPI) GetInsightData(_ context.Context, _ *webservice.GetInsightDataRequest) (*webservice.GetInsightDataResponse, error) { - return nil, nil + return nil, status.Error(codes.Unimplemented, "") }