Skip to content

Commit 2da7476

Browse files
authored
feat(trace): add v1 service (#11158)
* feat(trace): add v1 service * generated changes
1 parent 8760005 commit 2da7476

36 files changed

Lines changed: 2223 additions & 13 deletions

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ The library has been expanded to include the Cloud Build repositories (2nd gen)
127127
API. Note that the client is tagged as experimental, because the service is
128128
still in [preview][product-launch-stages].
129129

130+
### [Cloud Trace](/google/cloud/cloudbuild/README.md)
131+
132+
The library has been expanded to include the v1 service.
133+
130134
### Testing
131135

132136
We have stopped testing with MSVC 2017. Microsoft stopped mainstream support for

ci/etc/expected_install_directories

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,9 @@
558558
./include/google/cloud/tpu/v2/mocks
559559
./include/google/cloud/trace
560560
./include/google/cloud/trace/mocks
561+
./include/google/cloud/trace/v1
562+
./include/google/cloud/trace/v1/internal
563+
./include/google/cloud/trace/v1/mocks
561564
./include/google/cloud/trace/v2
562565
./include/google/cloud/trace/v2/internal
563566
./include/google/cloud/trace/v2/mocks
@@ -636,6 +639,7 @@
636639
./include/google/devtools/cloudprofiler
637640
./include/google/devtools/cloudprofiler/v2
638641
./include/google/devtools/cloudtrace
642+
./include/google/devtools/cloudtrace/v1
639643
./include/google/devtools/cloudtrace/v2
640644
./include/google/devtools/containeranalysis
641645
./include/google/devtools/containeranalysis/v1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
@com_google_googleapis//google/devtools/cloudtrace/v1:trace.proto
12
@com_google_googleapis//google/devtools/cloudtrace/v2:trace.proto
23
@com_google_googleapis//google/devtools/cloudtrace/v2:tracing.proto

external/googleapis/update_libraries.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,11 @@ declare -A -r LIBRARIES=(
221221
"@com_google_googleapis//google/cloud/tpu/v1:tpu_cc_grpc" \
222222
"@com_google_googleapis//google/cloud/tpu/v2:tpu_cc_grpc"
223223
)"
224-
["trace"]="@com_google_googleapis//google/devtools/cloudtrace/v2:cloudtrace_cc_grpc"
224+
["trace"]="$(
225+
printf ",%s" \
226+
"@com_google_googleapis//google/devtools/cloudtrace/v1:cloudtrace_cc_grpc" \
227+
"@com_google_googleapis//google/devtools/cloudtrace/v2:cloudtrace_cc_grpc"
228+
)"
225229
["translate"]="@com_google_googleapis//google/cloud/translate/v3:translation_cc_grpc"
226230
["video"]="$(
227231
printf ",%s" \

generator/generator_config.textproto

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1782,6 +1782,16 @@ service {
17821782
}
17831783
17841784
# Cloud Trace
1785+
service {
1786+
service_proto_path: "google/devtools/cloudtrace/v1/trace.proto"
1787+
product_path: "google/cloud/trace/v1"
1788+
initial_copyright_year: "2023"
1789+
retryable_status_codes: ["kUnavailable"]
1790+
idempotency_overrides: [
1791+
{rpc_name: "TraceService.PatchTraces", idempotency: IDEMPOTENT}
1792+
]
1793+
}
1794+
17851795
service {
17861796
service_proto_path: "google/devtools/cloudtrace/v2/tracing.proto"
17871797
product_path: "google/cloud/trace/v2"

google/cloud/trace/BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ licenses(["notice"]) # Apache 2.0
1818

1919
service_dirs = [
2020
"",
21+
"v1/",
2122
"v2/",
2223
]
2324

@@ -46,6 +47,7 @@ cc_library(
4647
deps = [
4748
"//:common",
4849
"//:grpc_utils",
50+
"@com_google_googleapis//google/devtools/cloudtrace/v1:cloudtrace_cc_grpc",
4951
"@com_google_googleapis//google/devtools/cloudtrace/v2:cloudtrace_cc_grpc",
5052
],
5153
)

google/cloud/trace/CMakeLists.txt

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ set(DOXYGEN_EXAMPLE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/quickstart")
2323

2424
unset(mocks_globs)
2525
unset(source_globs)
26-
set(service_dirs "" "v2/")
26+
set(service_dirs "" "v1/" "v2/")
2727
foreach (dir IN LISTS service_dirs)
2828
string(REPLACE "/" "_" ns "${dir}")
2929
list(APPEND source_globs "${dir}*.h" "${dir}*.cc" "${dir}internal/*")
@@ -46,16 +46,19 @@ if (PROTO_INCLUDE_DIR)
4646
list(INSERT PROTOBUF_IMPORT_DIRS 0 "${PROTO_INCLUDE_DIR}")
4747
endif ()
4848

49-
add_library(google_cloud_cpp_trace_protos INTERFACE)
50-
target_link_libraries(
51-
google_cloud_cpp_trace_protos
52-
INTERFACE google-cloud-cpp::devtools_cloudtrace_v2_trace_protos
53-
google-cloud-cpp::devtools_cloudtrace_v2_tracing_protos)
54-
set_target_properties(google_cloud_cpp_trace_protos
55-
PROPERTIES EXPORT_NAME google-cloud-cpp::trace_protos)
56-
target_compile_options(google_cloud_cpp_trace_protos
57-
INTERFACE ${GOOGLE_CLOUD_CPP_EXCEPTIONS_FLAG})
58-
add_library(google-cloud-cpp::trace_protos ALIAS google_cloud_cpp_trace_protos)
49+
include(CompileProtos)
50+
google_cloud_cpp_find_proto_include_dir(PROTO_INCLUDE_DIR)
51+
google_cloud_cpp_load_protolist(
52+
proto_list
53+
"${PROJECT_SOURCE_DIR}/external/googleapis/protolists/trace.list")
54+
google_cloud_cpp_load_protodeps(
55+
proto_deps "${PROJECT_SOURCE_DIR}/external/googleapis/protodeps/trace.deps")
56+
google_cloud_cpp_grpcpp_library(
57+
google_cloud_cpp_trace_protos # cmake-format: sort
58+
${proto_list} PROTO_PATH_DIRECTORIES "${EXTERNAL_GOOGLEAPIS_SOURCE}"
59+
"${PROTO_INCLUDE_DIR}")
60+
external_googleapis_set_version_and_alias(trace_protos)
61+
target_link_libraries(google_cloud_cpp_trace_protos PUBLIC ${proto_deps})
5962

6063
file(
6164
GLOB source_files

google/cloud/trace/doc/main.dox

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,14 @@ library. Use the `google::cloud::EndpointOption` when initializing the client
9595
library to change this default.
9696

9797
<!-- inject-endpoint-snippet-start -->
98-
For example, this will override the default endpoint for `trace_v2::TraceServiceClient`:
98+
For example, this will override the default endpoint for `trace_v1::TraceServiceClient`:
9999

100100
@snippet trace_client_samples.cc set-client-endpoint
101101

102+
Follow these links to find examples for other \c *Client classes:
103+
[trace_v1::TraceServiceClient](@ref trace_v1::TraceServiceClient-endpoint-snippet)
104+
[trace_v2::TraceServiceClient](@ref trace_v2::TraceServiceClient-endpoint-snippet)
105+
102106
<!-- inject-endpoint-snippet-end -->
103107

104108
## Override the authentication configuration
@@ -111,6 +115,10 @@ to explicitly load a service account key file.
111115
<!-- inject-service-account-snippet-start -->
112116
@snippet trace_client_samples.cc with-service-account
113117

118+
Follow these links to find examples for other \c *Client classes:
119+
[trace_v1::TraceServiceClient](@ref trace_v1::TraceServiceClient-service-account-snippet)
120+
[trace_v2::TraceServiceClient](@ref trace_v2::TraceServiceClient-service-account-snippet)
121+
114122
<!-- inject-service-account-snippet-end -->
115123

116124
Keep in mind that we chose this as an example because it is relatively easy to
@@ -140,6 +148,18 @@ can override the default policies.
140148

141149
// <!-- inject-endpoint-pages-start -->
142150

151+
/*! @page trace_v1::TraceServiceClient-endpoint-snippet Override trace_v1::TraceServiceClient Endpoint Configuration
152+
153+
@snippet google/cloud/trace/v1/samples/trace_client_samples.cc set-client-endpoint
154+
155+
*/
156+
157+
/*! @page trace_v1::TraceServiceClient-service-account-snippet Override trace_v1::TraceServiceClient Authentication Defaults
158+
159+
@snippet google/cloud/trace/v1/samples/trace_client_samples.cc with-service-account
160+
161+
*/
162+
143163
/*! @page trace_v2::TraceServiceClient-endpoint-snippet Override trace_v2::TraceServiceClient Endpoint Configuration
144164

145165
@snippet google/cloud/trace/v2/samples/trace_client_samples.cc set-client-endpoint
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright 2023 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// Generated by the Codegen C++ plugin.
16+
// If you make any local changes, they will be lost.
17+
// source: google/devtools/cloudtrace/v1/trace.proto
18+
19+
#include "google/cloud/trace/v1/internal/trace_auth_decorator.h"
20+
#include <google/devtools/cloudtrace/v1/trace.grpc.pb.h>
21+
#include <memory>
22+
23+
namespace google {
24+
namespace cloud {
25+
namespace trace_v1_internal {
26+
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
27+
28+
TraceServiceAuth::TraceServiceAuth(
29+
std::shared_ptr<google::cloud::internal::GrpcAuthenticationStrategy> auth,
30+
std::shared_ptr<TraceServiceStub> child)
31+
: auth_(std::move(auth)), child_(std::move(child)) {}
32+
33+
StatusOr<google::devtools::cloudtrace::v1::ListTracesResponse>
34+
TraceServiceAuth::ListTraces(
35+
grpc::ClientContext& context,
36+
google::devtools::cloudtrace::v1::ListTracesRequest const& request) {
37+
auto status = auth_->ConfigureContext(context);
38+
if (!status.ok()) return status;
39+
return child_->ListTraces(context, request);
40+
}
41+
42+
StatusOr<google::devtools::cloudtrace::v1::Trace> TraceServiceAuth::GetTrace(
43+
grpc::ClientContext& context,
44+
google::devtools::cloudtrace::v1::GetTraceRequest const& request) {
45+
auto status = auth_->ConfigureContext(context);
46+
if (!status.ok()) return status;
47+
return child_->GetTrace(context, request);
48+
}
49+
50+
Status TraceServiceAuth::PatchTraces(
51+
grpc::ClientContext& context,
52+
google::devtools::cloudtrace::v1::PatchTracesRequest const& request) {
53+
auto status = auth_->ConfigureContext(context);
54+
if (!status.ok()) return status;
55+
return child_->PatchTraces(context, request);
56+
}
57+
58+
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
59+
} // namespace trace_v1_internal
60+
} // namespace cloud
61+
} // namespace google
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// Copyright 2023 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// Generated by the Codegen C++ plugin.
16+
// If you make any local changes, they will be lost.
17+
// source: google/devtools/cloudtrace/v1/trace.proto
18+
19+
#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_TRACE_V1_INTERNAL_TRACE_AUTH_DECORATOR_H
20+
#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_TRACE_V1_INTERNAL_TRACE_AUTH_DECORATOR_H
21+
22+
#include "google/cloud/trace/v1/internal/trace_stub.h"
23+
#include "google/cloud/internal/unified_grpc_credentials.h"
24+
#include "google/cloud/version.h"
25+
#include <memory>
26+
#include <set>
27+
#include <string>
28+
29+
namespace google {
30+
namespace cloud {
31+
namespace trace_v1_internal {
32+
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
33+
34+
class TraceServiceAuth : public TraceServiceStub {
35+
public:
36+
~TraceServiceAuth() override = default;
37+
TraceServiceAuth(
38+
std::shared_ptr<google::cloud::internal::GrpcAuthenticationStrategy> auth,
39+
std::shared_ptr<TraceServiceStub> child);
40+
41+
StatusOr<google::devtools::cloudtrace::v1::ListTracesResponse> ListTraces(
42+
grpc::ClientContext& context,
43+
google::devtools::cloudtrace::v1::ListTracesRequest const& request)
44+
override;
45+
46+
StatusOr<google::devtools::cloudtrace::v1::Trace> GetTrace(
47+
grpc::ClientContext& context,
48+
google::devtools::cloudtrace::v1::GetTraceRequest const& request)
49+
override;
50+
51+
Status PatchTraces(grpc::ClientContext& context,
52+
google::devtools::cloudtrace::v1::PatchTracesRequest const&
53+
request) override;
54+
55+
private:
56+
std::shared_ptr<google::cloud::internal::GrpcAuthenticationStrategy> auth_;
57+
std::shared_ptr<TraceServiceStub> child_;
58+
};
59+
60+
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
61+
} // namespace trace_v1_internal
62+
} // namespace cloud
63+
} // namespace google
64+
65+
#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_TRACE_V1_INTERNAL_TRACE_AUTH_DECORATOR_H

0 commit comments

Comments
 (0)