Skip to content
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

Add a gRPC interceptor for embedding payloads into trace spans #900

Merged
merged 7 commits into from
Jan 21, 2021

Conversation

rinx
Copy link
Contributor

@rinx rinx commented Dec 23, 2020

Signed-off-by: Rintaro Okamura rintaro.okamura@gmail.com

Description:

In this PR, I added a gRPC interceptor for embedding gRPC request & response payloads into trace spans.

screenshot

Related Issue:

nothing

How Has This Been Tested?:

nothing

Environment:

  • Go Version: 1.15.2
  • Docker Version: 19.03.8
  • Kubernetes Version: 1.18.2
  • NGT Version: 1.12.1

Types of changes:

  • Bug fix [type/bug]
  • New feature [type/feature]
  • Add tests [type/test]
  • Security related changes [type/security]
  • Add documents [type/documentation]
  • Refactoring [type/refactoring]
  • Update dependencies [type/dependency]
  • Update benchmarks and performances [type/bench]
  • Update CI [type/ci]

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Checklist:

  • I have read the CONTRIBUTING document.
  • I have checked open Pull Requests for the similar feature or fixes?
  • I have added tests and benchmarks to cover my changes.
  • I have ensured all new and existing tests passed.
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly.

@vdaas-ci
Copy link
Collaborator

[CHATOPS:HELP] ChatOps commands.

  • 🙆‍♀️ /approve - approve
  • 💌 /changelog - add changelog comment
  • 🍱 /format - format codes and add licenses
  • /gen-test - generate test codes
  • 🏷️ /label - add labels
  • /rebase - rebase master

@codecov
Copy link

codecov bot commented Dec 23, 2020

Codecov Report

Merging #900 (b1af006) into master (fa1db2b) will increase coverage by 0.04%.
The diff coverage is 38.23%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #900      +/-   ##
==========================================
+ Coverage   15.94%   15.98%   +0.04%     
==========================================
  Files         474      474              
  Lines       23693    23707      +14     
==========================================
+ Hits         3778     3790      +12     
- Misses      19678    19679       +1     
- Partials      237      238       +1     
Impacted Files Coverage Δ
...nal/net/grpc/interceptor/server/recover/recover.go 0.00% <0.00%> (ø)
pkg/agent/core/ngt/usecase/agentd.go 0.00% <ø> (ø)
...ent/sidecar/usecase/initcontainer/initcontainer.go 0.00% <ø> (ø)
pkg/agent/sidecar/usecase/sidecar/sidecar.go 0.00% <ø> (ø)
pkg/discoverer/k8s/usecase/discovered.go 0.00% <ø> (ø)
pkg/gateway/vald/usecase/vald.go 0.00% <ø> (ø)
pkg/manager/backup/cassandra/usecase/backupd.go 0.00% <ø> (ø)
pkg/manager/backup/mysql/usecase/backupd.go 0.00% <ø> (ø)
pkg/manager/compressor/usecase/compressord.go 0.00% <ø> (ø)
pkg/manager/index/usecase/indexer.go 0.00% <ø> (ø)
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fa1db2b...4f4924a. Read the comment docs.

@github-actions github-actions bot added the team/set SET team label Dec 23, 2020
@rinx rinx force-pushed the feature/internal/add-rpc-payload-grpc-interceptor branch from 05ed181 to 6e87b03 Compare December 23, 2020 07:38
@rinx rinx force-pushed the feature/internal/add-access-log-grpc-interceptor branch from 80384c2 to 5adf052 Compare December 24, 2020 02:36
@rinx rinx force-pushed the feature/internal/add-rpc-payload-grpc-interceptor branch from 6e87b03 to aaa7b7a Compare December 24, 2020 02:44
@rinx rinx force-pushed the feature/internal/add-access-log-grpc-interceptor branch from 5adf052 to af018a2 Compare January 6, 2021 01:52
@rinx rinx force-pushed the feature/internal/add-rpc-payload-grpc-interceptor branch from aaa7b7a to 8f7b0ff Compare January 6, 2021 02:05
@rinx rinx force-pushed the feature/internal/add-access-log-grpc-interceptor branch from af018a2 to f5e2132 Compare January 12, 2021 01:18
@rinx rinx force-pushed the feature/internal/add-rpc-payload-grpc-interceptor branch from 8f7b0ff to c80b8d0 Compare January 12, 2021 01:19
@rinx rinx force-pushed the feature/internal/add-access-log-grpc-interceptor branch from f5e2132 to f699079 Compare January 12, 2021 02:19
@rinx rinx force-pushed the feature/internal/add-access-log-grpc-interceptor branch 2 times, most recently from ad99d8b to df36f12 Compare January 20, 2021 06:31
@rinx rinx force-pushed the feature/internal/add-rpc-payload-grpc-interceptor branch from c80b8d0 to 6f75ff2 Compare January 20, 2021 06:41
@rinx rinx force-pushed the feature/internal/add-access-log-grpc-interceptor branch from df36f12 to 3e558e5 Compare January 20, 2021 07:25
@rinx rinx force-pushed the feature/internal/add-rpc-payload-grpc-interceptor branch from 6f75ff2 to 2297533 Compare January 20, 2021 09:24
@rinx rinx changed the base branch from feature/internal/add-access-log-grpc-interceptor to master January 20, 2021 09:25
@github-actions github-actions bot added size/L and removed size/L labels Jan 20, 2021
@rinx rinx force-pushed the feature/internal/add-rpc-payload-grpc-interceptor branch from 7e8cb6b to dbbaa13 Compare January 20, 2021 09:45
@github-actions github-actions bot added size/L and removed size/L labels Jan 20, 2021
@rinx rinx added the size/L label Jan 20, 2021
Copy link
Collaborator

@kpango kpango left a comment

Choose a reason for hiding this comment

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

Others LGTM

internal/net/grpc/interceptor/server/trace/payload.go Outdated Show resolved Hide resolved
internal/net/grpc/interceptor/server/trace/payload.go Outdated Show resolved Hide resolved
@kpango
Copy link
Collaborator

kpango commented Jan 20, 2021

In this PR, the package structure of the interceptor seems to have changed.
Could you please move internal/net/grpc/interceptor.go to internal/net/grpc/interceptor/server/recover/recover_interceptor.go?
and remove each configuration point for RecoverInterceptor configuration from the use case layer of each pkg so that it can be set from the WithGRPCInterceptors function as well as TraceInterceptor.
It would also be helpful if the RecoverInterceptor could be set to be on by default in helm.

@rinx
Copy link
Contributor Author

rinx commented Jan 21, 2021

Thanks. that's good idea. I'll try to do it.

Signed-off-by: Rintaro Okamura <rintaro.okamura@gmail.com>

fixup! ✨ Add TracePayloadInterceptor

Signed-off-by: Rintaro Okamura <rintaro.okamura@gmail.com>

📄 update license headers

Signed-off-by: Rintaro Okamura <rintaro.okamura@gmail.com>

✏️ Fix typo

Signed-off-by: Rintaro Okamura <rintaro.okamura@gmail.com>
Signed-off-by: Rintaro Okamura <rintaro.okamura@gmail.com>
Signed-off-by: Rintaro Okamura <rintaro.okamura@gmail.com>
Signed-off-by: Rintaro Okamura <rintaro.okamura@gmail.com>
Signed-off-by: Rintaro Okamura <rintaro.okamura@gmail.com>
Signed-off-by: Rintaro Okamura <rintaro.okamura@gmail.com>
@rinx
Copy link
Contributor Author

rinx commented Jan 21, 2021

@kpango this PR is revised as you mentioned. could you please review again?

traceAttrGRPCResponsePayload = "grpc.response.payload"
)

var (
Copy link
Contributor

Choose a reason for hiding this comment

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

🚫 [golangci] reported by reviewdog 🐶
File is not gofumpt-ed (gofumpt)

)

var (
bufferPool = sync.Pool{
Copy link
Contributor

Choose a reason for hiding this comment

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

🚫 [golangci] reported by reviewdog 🐶
bufferPool is a global variable (gochecknoglobals)

@@ -84,23 +85,24 @@ func TestRecoverInterceptor(t *testing.T) {
if err := test.checkFunc(test.want, got); err != nil {
tt.Errorf("error = %v", err)
}

Copy link
Contributor

Choose a reason for hiding this comment

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

🚫 [golangci] reported by reviewdog 🐶
File is not gofumpt-ed (gofumpt)

@@ -147,6 +149,7 @@ func TestRecoverStreamInterceptor(t *testing.T) {
if err := test.checkFunc(test.want, got); err != nil {
tt.Errorf("error = %v", err)
}

Copy link
Contributor

Choose a reason for hiding this comment

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

🚫 [golangci] reported by reviewdog 🐶
File is not gofumpt-ed (gofumpt)

//

// Package recover provides gRPC interceptors for recovery
package recover
Copy link
Contributor

Choose a reason for hiding this comment

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

🚫 [golangci] reported by reviewdog 🐶
package name recover has same name as predeclared identifier (predeclared)

// Package grpc provides generic functionality for grpc
package grpc
// Package recover provides gRPC interceptors for recovery
package recover
Copy link
Contributor

Choose a reason for hiding this comment

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

🚫 [golangci] reported by reviewdog 🐶
package name recover has same name as predeclared identifier (predeclared)

Signed-off-by: Rintaro Okamura <rintaro.okamura@gmail.com>
Copy link
Collaborator

@kpango kpango left a comment

Choose a reason for hiding this comment

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

Looks Really Good for Me, thanks for revise.

@kpango kpango merged commit efad135 into master Jan 21, 2021
@kpango kpango deleted the feature/internal/add-rpc-payload-grpc-interceptor branch January 21, 2021 03:29
@rinx
Copy link
Contributor Author

rinx commented Jan 21, 2021

Thanks!

@vdaas-ci vdaas-ci mentioned this pull request Jan 29, 2021
18 tasks
@kpango kpango mentioned this pull request Feb 2, 2021
11 tasks
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.

None yet

3 participants