[GSM Observability] Add cloud c++ dependency.. this time for sure (#34071)

<!--

If you know who should review your pull request, please assign it to
that
person, otherwise the pull request would get assigned randomly.

If your pull request is for a specific language, please add the
appropriate
lang label.

-->
pull/34082/head
Yash Tibrewal 1 year ago committed by GitHub
parent 0d5dc5c45b
commit 6878609fc5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 28
      bazel/googleapis.BUILD
  2. 2
      bazel/grpc_build_system.bzl
  3. 12
      bazel/grpc_deps.bzl
  4. 3
      bazel/grpc_extra_deps.bzl
  5. 1
      test/cpp/ext/gsm/BUILD
  6. 5
      test/cpp/ext/gsm/gsm_observability_test.cc
  7. 1
      tools/distrib/fix_build_deps.py
  8. 4
      tools/run_tests/sanity/check_bazel_workspace.py

@ -0,0 +1,28 @@
# Copyright 2023 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
licenses(["notice"])
package(
default_visibility = ["//visibility:public"]
)
# This is needed for the dependency on google_cloud_cpp to work.
# Taken from https://github.com/googleapis/google-cloud-cpp/blob/2839e9dba793ca023e11ea67f201f66f74fa7d3e/bazel/googleapis.BUILD
cc_library(
name = "googleapis_system_includes",
includes = [
".",
],
)

@ -75,6 +75,8 @@ def _get_external_deps(external_deps):
ret.append("@com_google_googleapis//" + dep)
elif dep.startswith("otel/"):
ret.append(dep.replace("otel/", "@io_opentelemetry_cpp//"))
elif dep.startswith("google_cloud_cpp"):
ret.append(dep.replace("google_cloud_cpp", "@google_cloud_cpp//"))
else:
ret.append("//external:" + dep)
return ret

@ -438,6 +438,7 @@ def grpc_deps():
name = "com_google_googleapis",
sha256 = "5bb6b0253ccf64b53d6c7249625a7e3f6c3bc6402abd52d3778bfa48258703a0",
strip_prefix = "googleapis-2f9af297c84c55c8b871ba4495e01ade42476c92",
build_file = Label("//bazel:googleapis.BUILD"),
urls = [
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/googleapis/googleapis/archive/2f9af297c84c55c8b871ba4495e01ade42476c92.tar.gz",
"https://github.com/googleapis/googleapis/archive/2f9af297c84c55c8b871ba4495e01ade42476c92.tar.gz",
@ -499,6 +500,17 @@ def grpc_deps():
],
)
if "google_cloud_cpp" not in native.existing_rules():
http_archive(
name = "google_cloud_cpp",
sha256 = "371d01b03c7e2604d671b8fa1c86710abe3b524a78bc2705a6bb4de715696755",
strip_prefix = "google-cloud-cpp-2.14.0",
urls = [
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/googleapis/google-cloud-cpp/archive/refs/tags/v2.14.0.tar.gz",
"https://github.com/googleapis/google-cloud-cpp/archive/refs/tags/v2.14.0.tar.gz",
],
)
grpc_python_deps()
# TODO: move some dependencies from "grpc_deps" here?

@ -20,6 +20,7 @@ load("@com_envoyproxy_protoc_gen_validate//:dependencies.bzl", "go_third_party")
load("@com_google_googleapis//:repository_rules.bzl", "switched_rules_by_language")
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
load("@envoy_api//bazel:repositories.bzl", "api_dependencies")
load("@google_cloud_cpp//bazel:google_cloud_cpp_deps.bzl", "google_cloud_cpp_deps")
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
load("@upb//bazel:workspace_deps.bzl", "upb_deps")
@ -71,3 +72,5 @@ def grpc_extra_deps(ignore_version_differences = False):
grpc = True,
python = True,
)
google_cloud_cpp_deps()

@ -27,6 +27,7 @@ grpc_cc_test(
"gsm_observability_test.cc",
],
external_deps = [
"google_cloud_cpp:experimental-opentelemetry",
"gtest",
"otel/sdk/src/metrics",
],

@ -18,6 +18,7 @@
#include "src/cpp/ext/gsm/gsm_observability.h"
#include "google/cloud/opentelemetry/resource_detector.h"
#include "gtest/gtest.h"
#include "test/core/util/test_config.h"
@ -32,6 +33,10 @@ TEST(GsmCustomObservabilityBuilderTest, Basic) {
absl::UnimplementedError("Not Implemented"));
}
TEST(GsmDependencyTest, GoogleCloudOpenTelemetryDependency) {
EXPECT_NE(google::cloud::otel::MakeResourceDetector(), nullptr);
}
} // namespace
} // namespace testing
} // namespace grpc

@ -93,6 +93,7 @@ EXTERNAL_DEPS = {
"absl/types/variant.h": "absl/types:variant",
"absl/utility/utility.h": "absl/utility",
"address_sorting/address_sorting.h": "address_sorting",
"google/cloud/opentelemetry/resource_detector.h": "google_cloud_cpp:experimental-opentelemetry",
"opentelemetry/context/context.h": "otel/api",
"opentelemetry/metrics/meter.h": "otel/api",
"opentelemetry/metrics/meter_provider.h": "otel/api",

@ -78,6 +78,7 @@ _GRPC_DEP_NAMES = [
"com_google_googleapis",
"com_google_libprotobuf_mutator",
"com_github_cncf_udpa",
"google_cloud_cpp",
]
_GRPC_BAZEL_ONLY_DEPS = [
@ -104,6 +105,7 @@ _GRPC_BAZEL_ONLY_DEPS = [
"com_envoyproxy_protoc_gen_validate",
"com_google_googleapis",
"com_google_libprotobuf_mutator",
"google_cloud_cpp",
]
@ -165,6 +167,7 @@ build_rules = {
"load": lambda a, b: None,
"git_repository": lambda **args: eval_state.git_repository(**args),
"grpc_python_deps": lambda: None,
"Label": lambda a: None,
}
exec((bazel_file), build_rules)
for name in _GRPC_DEP_NAMES:
@ -213,6 +216,7 @@ for name in _GRPC_DEP_NAMES:
"load": lambda a, b: None,
"git_repository": lambda **args: state.git_repository(**args),
"grpc_python_deps": lambda *args, **kwargs: None,
"Label": lambda a: None,
}
exec((bazel_file), rules)
assert name not in list(names_and_urls_with_overridden_name.keys())

Loading…
Cancel
Save