-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
[RRIO] Define and implement mock quota aware API #28893
Conversation
Codecov Report
@@ Coverage Diff @@
## master #28893 +/- ##
===========================================
- Coverage 72.22% 38.38% -33.84%
===========================================
Files 684 686 +2
Lines 101241 101608 +367
===========================================
- Hits 73117 39007 -34110
- Misses 26548 61025 +34477
Partials 1576 1576
Flags with carried forward coverage won't be shown. Click here to find out more. see 314 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Assigning reviewers. If you would like to opt out of this review, comment R: @bvolpato for label java. Available commands:
The PR bot will only process comments in the main thread (not review comments). |
thanks for the change, could you please find a go reviewer? |
I did already thank you. |
That would be me :) It's a lot of code to go through. |
Damon, in particular, by commenting R: |
Would you like me to break it up? In the future I'll prevent this. |
I'm already halfway through it. Please make no changes at this time, to
avoid comment loss.
…On Wed, Oct 11, 2023, 2:26 PM Damon ***@***.***> wrote:
That would be me :) It's a lot of code to go through.
Would you like me to break it up? In the future I'll prevent this.
—
Reply to this email directly, view it on GitHub
<#28893 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADKDOFLX3RNBTIMUE5OQLI3X64FGVANCNFSM6AAAAAA5YNTQ6Q>
.
You are receiving this because your review was requested.Message ID:
***@***.***>
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked at all the Go code, but not the Java code.
I'm very happy with this! I have several mostly minor style nits, but other than that, this is clean and well factored.
.test-infra/mock-apis/src/main/go/cmd/service/refresher/main.go
Outdated
Show resolved
Hide resolved
.test-infra/mock-apis/src/main/go/cmd/service/refresher/main.go
Outdated
Show resolved
Hide resolved
.test-infra/mock-apis/src/main/go/internal/environment/variable_test.go
Outdated
Show resolved
Hide resolved
.test-infra/mock-apis/src/main/go/internal/service/echo/echo.go
Outdated
Show resolved
Hide resolved
.test-infra/mock-apis/src/main/go/internal/service/echo/echo.go
Outdated
Show resolved
Hide resolved
Re-adding the Java label. There's ~2k lines of Java here. It gets the Java label. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like what you've done with slog!
This is just a note, do not undo your work.
I will note that you went farther than necessary for plumbing the logger everywhere. It would have also been acceptable and sufficient to override the default logger/handler of slog in your package mains, and then just using the package level logging calls instead of plumbing it through everywhere.
I started looking at the java, and eventually realized it must be generated since it fully qualifies all the types. Including java.lang.String. I didn't understand that from the PR description initially. Sorry about that.
I'm gonna remove that java label.
}, | ||
} | ||
|
||
ref.opts.Logger.LogAttrs(ctx, slog.LevelInfo, "starting refresher service", attrs...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using attrs... on every call, use the logger.With method early on to get a logger with those outputs built.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noting this and thank you. Per your original comment, I won't change anything and just keep this comment open for the future Thank you again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, I meant not to change the fact that you plumb the logger through everywhere, instead of using the package level slog methods.
You should totally avoid repeatedly unrolling variadic parameters at every call site, where appropriate.
LoggingAttrs: logAttrs, | ||
Logger: logger, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the intent here is to always print out these attrs with every request, just build them into the logger instead of forcing per-callsite behavior on yourself.
https://pkg.go.dev/log/slog#Logger.With
If the attributes are only going to be logged sometimes though, document the field with the conditions they're logged, so it's clear what that field is for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah this is a good tip thank you. I won't change anything with slog related as you requested not up undo my work. I'll keep this comment open as a future reference.
) | ||
|
||
var ( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rm blank line
// Package metric supports monitoring. | ||
package metric |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style note: If the documentation is small, and the package is small (file wise), it's better to just put it on top of one ot the non test files. A separate doc file works best when the package documentation is long, or doesn't naturally fit into one of the existing files.
Usually though in that case there'd be a file named the same as the package. If it were me, I'd rename interface.go to metric.go since it's an evident entry point to the package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was anticipating it being longer in the beginning but then realized it didn't need to be. I won't change anything at this point though unless you or others feel strongly about it.
return | ||
} | ||
if err := json.NewEncoder(w).Encode(resp); err != nil { | ||
srv.opts.Logger.LogAttrs(context.Background(), slog.LevelError, err.Error(), srv.opts.LoggingAttrs...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using context.Background() for these logging calls, use the one attached to the request:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah this was a silly oversight on my part. I forgot there is a request.Context(). I will change this in a future PR.
// Register a grpc.Server with the echov1.EchoService. Returns a http.Handler or error. | ||
func Register(s *grpc.Server, opts *Options) (http.Handler, error) { | ||
if opts.Logger == nil { | ||
opts.Logger = logging.New(&logging.Options{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment here WRT the logger and the always used LoggingAttrs. Use .With()
to build them into the logger.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mentioned not to undo work in the context of slog. Does your comment apply in this context as well? FYI, I will be doing the infrastructure as code PR and may uncover a couple of things in the code that might need fixing so perhaps I can refactor the slog related stuff there.
This PR closes #28708. It defines and implements a mock quota aware API. See PR branch's .test-infra/mock-apis/README for more details.
Notes for the reviewer:
./gradlew :beam-test-infra-mock-apis:check
happy, I had to add some suppress configurations that weren't relevant for this project. If this project were to use the gradle plugin for proto generation, it wouldn't play as nicely with Go, which is arguably more important.Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
addresses #123
), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, commentfixes #<ISSUE NUMBER>
instead.CHANGES.md
with noteworthy changes.See the Contributor Guide for more tips on how to make review process smoother.
To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md
GitHub Actions Tests Status (on master branch)
See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.