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

api: logging the HTTP request details #6718

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

rleungx
Copy link
Member

@rleungx rleungx commented Jun 29, 2023

What problem does this PR solve?

Issue Number: Ref #5895

What is changed and how does it work?

Support logging keyspace(group) related HTTP request details.

Check List

Tests

  • Manual test

failed case:

[2023/06/29 17:39:00.123 +08:00] [INFO] [zap.go:90] [/pd/api/v2/keyspaces] [status=500] [method=POST] [path=/pd/api/v2/keyspaces] [query=] [ip=127.0.0.1] [user-agent=Go-http-client/1.1] [latency=30.004148063s] [body=]

succeed case:

[2023/06/29 17:37:14.794 +08:00] [INFO] [id.go:174] ["idAllocator allocates a new id"] [new-end=100] [new-base=0] [label=keyspace-idAlloc] [check-curr-end=true]
[2023/06/29 17:37:14.800 +08:00] [INFO] [keyspace.go:237] ["[keyspace] keyspace created"] [keyspace-id=1] [name=test_keyspace_0]
[2023/06/29 17:37:14.800 +08:00] [INFO] [zap.go:90] [/pd/api/v2/keyspaces] [status=200] [method=POST] [path=/pd/api/v2/keyspaces] [query=] [ip=127.0.0.1] [user-agent=Go-http-client/1.1] [latency=7.665786ms] [body=]
[2023/06/29 17:37:14.808 +08:00] [INFO] [keyspace.go:237] ["[keyspace] keyspace created"] [keyspace-id=2] [name=test_keyspace_1]
[2023/06/29 17:37:14.808 +08:00] [INFO] [zap.go:90] [/pd/api/v2/keyspaces] [status=200] [method=POST] [path=/pd/api/v2/keyspaces] [query=] [ip=127.0.0.1] [user-agent=Go-http-client/1.1] [latency=7.596356ms] [body=]
[2023/06/29 17:37:14.813 +08:00] [INFO] [keyspace.go:237] ["[keyspace] keyspace created"] [keyspace-id=3] [name=test_keyspace_2]
[2023/06/29 17:37:14.813 +08:00] [INFO] [zap.go:90] [/pd/api/v2/keyspaces] [status=200] [method=POST] [path=/pd/api/v2/keyspaces] [query=] [ip=127.0.0.1] [user-agent=Go-http-client/1.1] [latency=4.482295ms] [body=]

Release note

None.

Signed-off-by: Ryan Leung <rleungx@gmail.com>
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Jun 29, 2023

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • disksing

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot bot added the release-note-none Denotes a PR that doesn't merit a release note. label Jun 29, 2023
@ti-chi-bot ti-chi-bot bot requested review from disksing and nolouch June 29, 2023 09:34
@ti-chi-bot ti-chi-bot bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jun 29, 2023
@rleungx rleungx added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 29, 2023
@codecov
Copy link

codecov bot commented Jun 29, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (7d43f69) 74.46% compared to head (5ed40eb) 74.41%.
Report is 268 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6718      +/-   ##
==========================================
- Coverage   74.46%   74.41%   -0.06%     
==========================================
  Files         416      421       +5     
  Lines       43596    44245     +649     
==========================================
+ Hits        32465    32923     +458     
- Misses       8228     8416     +188     
- Partials     2903     2906       +3     
Flag Coverage Δ
unittests 74.41% <100.00%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rleungx rleungx requested review from JmPotato and binshi-bing and removed request for nolouch and disksing June 29, 2023 09:55
@rleungx
Copy link
Member Author

rleungx commented Jun 29, 2023

@AmoebaProtozoa Is there possible that the log will print too much when operating the keyspace?

@AmoebaProtozoa
Copy link
Contributor

@AmoebaProtozoa Is there possible that the log will print too much when operating the keyspace?

It's probably fine, the most frequent keyspace operation is probably get, which is called everytime a new tidb connect to the cluster, other operations are relatively infrequent.

@rleungx
Copy link
Member Author

rleungx commented Jun 30, 2023

t keyspace operation is probably get, which is called everytime a new tidb connect to the cluster, other operations are relatively infrequent.

Then, I prefer to enable the logging to help us record more info on the incoming request.
What's your opinion?
@binshi-bing @JmPotato @lhy1024

@bufferflies
Copy link
Contributor

are there some problems with data security if you print all the body?

@rleungx
Copy link
Member Author

rleungx commented Jul 3, 2023

body

good point

Copy link
Contributor

@nolouch nolouch left a comment

Choose a reason for hiding this comment

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

Is it duplicated with audit log? maybe directly change audit log format.

Signed-off-by: Ryan Leung <rleungx@gmail.com>
@ti-chi-bot ti-chi-bot bot added the status/LGT1 Indicates that a PR has LGTM 1. label Jul 20, 2023
@ti-chi-bot ti-chi-bot bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 17, 2023
Copy link
Contributor

ti-chi-bot bot commented Nov 17, 2023

PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. status/LGT1 Indicates that a PR has LGTM 1.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants