-
Notifications
You must be signed in to change notification settings - Fork 374
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
impl(generator): add Start and Await overloads to connections #14348
impl(generator): add Start and Await overloads to connections #14348
Conversation
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 didn't get very far in the review. My browser keeps crashing when I open the "generated code" commit. Can you put the golden changes in its own commit?
"NAM4", | ||
# Metadata is mispelled in this proto message name found in | ||
# google/cloud/aiplatform/v1/vizier_service.proto | ||
"CheckTrialEarlyStoppingStateMetatdata" |
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.
lol
" virtual StatusOr<$longrunning_operation_type$>\n"}, | ||
// clang-format on | ||
// TODO(#14344): Remove experimental tag. | ||
{" $method_name$(google::cloud::ExperimentalTag, " |
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.
nit: I would omit google::cloud::
from all of these things.
@@ -18,6 +18,7 @@ | |||
|
|||
google_cloud_cpp_common_hdrs = [ | |||
"access_token.h", | |||
"await_tag.h", |
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.
nit: rename to no_await_tag.h
?
@@ -21,7 +21,9 @@ | |||
|
|||
#include "generator/integration_tests/golden/v1/golden_kitchen_sink_connection_idempotency_policy.h" | |||
#include "generator/integration_tests/golden/v1/internal/golden_kitchen_sink_retry_traits.h" | |||
#include "google/cloud/await_tag.h" |
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.
unused?
093d8c6
to
d8fcdc1
Compare
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.
Done.
Reviewable status: 0 of 2029 files reviewed, 4 unresolved discussions (waiting on @dbolduc)
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.
Only nits, and suggestions so approved. The two important things are:
- We should consider naming the wait method:
Await$method_name$
- We should change the
OTelScope
thingy in the synchronous tracing method.
@@ -52,6 +52,22 @@ GoldenThingAdminConnection::CreateDatabase( | |||
Status(StatusCode::kUnimplemented, "not implemented")); | |||
} | |||
|
|||
StatusOr<google::longrunning::Operation> |
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.
pre-checkers nit: remove space at the start of the line?
@@ -52,6 +52,22 @@ GoldenThingAdminConnection::CreateDatabase( | |||
Status(StatusCode::kUnimplemented, "not implemented")); | |||
} | |||
|
|||
StatusOr<google::longrunning::Operation> | |||
GoldenThingAdminConnection::CreateDatabase( | |||
google::cloud::ExperimentalTag, google::cloud::NoAwaitTag, |
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.
nit: I'd drop the google::cloud::
@@ -126,6 +126,53 @@ GoldenThingAdminConnectionImpl::CreateDatabase(google::test::admin::database::v1 | |||
polling_policy(*current), __func__); | |||
} | |||
|
|||
|
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.
nit: extra space
google::cloud::NoAwaitTag, google::test::admin::database::v1::CreateDatabaseRequest const& request) { | ||
auto span = internal::MakeSpan( | ||
"golden_v1::GoldenThingAdminConnection::CreateDatabase"); | ||
internal::OTelScope scope(span); |
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.
For synchronous calls, it is simpler to use:
opentelemetry::trace::Scope scope(span);
google::longrunning::Operation const& operation) { | ||
auto span = internal::MakeSpan( | ||
"golden_v1::GoldenThingAdminConnection::CreateDatabase"); | ||
internal::OTelScope scope(span); |
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.
comment: FTR, this OTelScope
is necessary.
GoldenThingAdminTracingConnection::UpdateDatabaseDdl(google::cloud::ExperimentalTag, | ||
google::cloud::NoAwaitTag, google::test::admin::database::v1::UpdateDatabaseDdlRequest const& request) { | ||
auto span = internal::MakeSpan( | ||
"golden_v1::GoldenThingAdminConnection::UpdateDatabaseDdl"); |
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.
Feel free to defer this.
I am noticing that the spans for the three overloads are identical in names and attributes. How will we tell them apart in the trace UI?
I think we would at least want an attribute equivalent of "NoAwaitTag"
auto mock = std::make_shared<MockGoldenThingAdminConnection>(); | ||
EXPECT_CALL(*mock, CreateDatabase(_, _, _)).WillOnce([] { | ||
EXPECT_TRUE(ThereIsAnActiveSpan()); | ||
EXPECT_TRUE(OTelContextCaptured()); |
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.
this expectation is only necessary for async operations
EXPECT_EQ(expected_operation.name(), r.name()); | ||
google::longrunning::Operation op; | ||
op.set_name(r.name()); | ||
op.set_done(true); |
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.
comment for myself: I was wondering if we need/want tests for the polling loop side of things? Like, when the operation is not immediately done.
I think no. I think those cases are covered in async_long_running_operation_test.cc
. We do not need to recreate the tests for AsyncAwaitLongRunningOperation
in the connections.
google::cloud::NoAwaitTag, $request_type$ const& request) { | ||
auto span = internal::MakeSpan( | ||
"$product_namespace$::$connection_class_name$::$method_name$"); | ||
internal::OTelScope scope(span); |
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.
s/internal::OtelScope/opentelemetry::trace::Scope
What you have works, it just does some unnecessary extra work (duplicating OTel's thread_local state) that we do not need to do in the synchronous case.
" virtual future<Status>\n", | ||
" virtual future<StatusOr<$longrunning_deduced_response_type$>>\n"}, | ||
// TODO(#14344): Remove experimental tag. | ||
{" $method_name$(google::cloud::ExperimentalTag," |
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 think I prefer to call these things: AwaitCreateFoo(...)
or WaitForCreateFoo(...)
.
It stops being an overload set. I don't think that's bad.
auto operation = CreateFoo(request);
auto foo = CreateFoo(..., *operation);
The second line isn't creating a foo. That already happened. It is waiting on a foo. That is why I like the different name.
It seems super unlikely, but it could open us up to RPC name clashes. If that is the concern, feel free to leave it as is.
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.
- My concern is that method names are defined by the service, not us. While small, we risk future naming collisions.
- Fixed.
Reviewable status: 0 of 2029 files reviewed, 13 unresolved discussions (waiting on @dbolduc)
.typos.toml
line 67 at r2 (raw file):
Previously, dbolduc (Darren Bolduc) wrote…
lol
Done.
generator/integration_tests/golden/v1/golden_thing_admin_connection.cc
line 55 at r5 (raw file):
Previously, dbolduc (Darren Bolduc) wrote…
pre-checkers nit: remove space at the start of the line?
Fixed
generator/integration_tests/golden/v1/golden_thing_admin_connection.cc
line 57 at r5 (raw file):
Previously, dbolduc (Darren Bolduc) wrote…
nit: I'd drop the
google::cloud::
Dropped
generator/integration_tests/golden/v1/internal/golden_thing_admin_connection_impl.cc
line 129 at r5 (raw file):
Previously, dbolduc (Darren Bolduc) wrote…
nit: extra space
Fixed
generator/integration_tests/golden/v1/internal/golden_thing_admin_tracing_connection.cc
line 58 at r5 (raw file):
Previously, dbolduc (Darren Bolduc) wrote…
For synchronous calls, it is simpler to use:
opentelemetry::trace::Scope scope(span);
Done.
generator/integration_tests/golden/v1/internal/golden_thing_admin_tracing_connection.cc
line 68 at r5 (raw file):
Previously, dbolduc (Darren Bolduc) wrote…
comment: FTR, this
OTelScope
is necessary.
Done.
generator/integration_tests/golden/v1/internal/golden_thing_admin_tracing_connection.cc
line 92 at r5 (raw file):
Previously, dbolduc (Darren Bolduc) wrote…
Feel free to defer this.
I am noticing that the spans for the three overloads are identical in names and attributes. How will we tell them apart in the trace UI?
I think we would at least want an attribute equivalent of "NoAwaitTag"
Created issue #14367
generator/integration_tests/tests/golden_thing_admin_connection_test.cc
line 263 at r4 (raw file):
Previously, dbolduc (Darren Bolduc) wrote…
comment for myself: I was wondering if we need/want tests for the polling loop side of things? Like, when the operation is not immediately done.
I think no. I think those cases are covered in
async_long_running_operation_test.cc
. We do not need to recreate the tests forAsyncAwaitLongRunningOperation
in the connections.
Done.
generator/integration_tests/tests/golden_thing_admin_tracing_connection_test.cc
line 131 at r4 (raw file):
Previously, dbolduc (Darren Bolduc) wrote…
this expectation is only necessary for async operations
Removed
generator/internal/connection_generator.cc
line 264 at r2 (raw file):
Previously, dbolduc (Darren Bolduc) wrote…
nit: I would omit
google::cloud::
from all of these things.
Done
generator/internal/connection_generator.cc
line 272 at r2 (raw file):
Previously, dbolduc (Darren Bolduc) wrote…
I think I prefer to call these things:
AwaitCreateFoo(...)
orWaitForCreateFoo(...)
.It stops being an overload set. I don't think that's bad.
auto operation = CreateFoo(request); auto foo = CreateFoo(..., *operation);The second line isn't creating a foo. That already happened. It is waiting on a foo. That is why I like the different name.
It seems super unlikely, but it could open us up to RPC name clashes. If that is the concern, feel free to leave it as is.
Same as previous comment. My concern is that the service defines the methods, not us. While small, there is a risk of a name collision in the future.
generator/internal/tracing_connection_generator.cc
line 327 at r2 (raw file):
Previously, dbolduc (Darren Bolduc) wrote…
s/internal::OtelScope/opentelemetry::trace::Scope
What you have works, it just does some unnecessary extra work (duplicating OTel's thread_local state) that we do not need to do in the synchronous case.
Done.
google/cloud/google_cloud_cpp_common.bzl
line 21 at r2 (raw file):
Previously, dbolduc (Darren Bolduc) wrote…
nit: rename to
no_await_tag.h
?
Renamed
part of the work for #7658
This PR adds the connection methods and decorator overrides to create an overload set for each LRO rpc, adding a "Start" method and an "Await" method. A new tag type
NoAwaitTag
is used to signal a call to the "Start" overload and passing anOperation
signals a call to the "Await" overload.A few Bigtable tests needed their
EXPECT_CALL
invocations adjusted to remove ambiguities the additional overloads introduced.The PR is split into multiple commits to separate the generator changes, tests for the golden generated code, and all the generated code updates.
This change is