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

GcpObservability: Add experimental public target #31339

Merged
merged 2 commits into from Oct 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions BUILD
Expand Up @@ -39,6 +39,11 @@ exports_files([
"etc/roots.pem",
])

exports_files(
glob(["include/**"]),
visibility = ["//:__subpackages__"],
)

config_setting(
name = "grpc_no_ares",
values = {"define": "grpc_no_ares=true"},
Expand Down Expand Up @@ -7775,6 +7780,20 @@ grpc_cc_library(
],
)

# This is an EXPERIMENTAL target subject to change.
grpc_cc_library(
name = "grpcpp_gcp_observability",
hdrs = [
"include/grpcpp/ext/gcp_observability.h",
],
language = "c++",
tags = ["nofixdeps"],
visibility = ["@grpc:grpcpp_gcp_observability"],
deps = [
"//src/cpp/ext/gcp:observability",
],
)

grpc_cc_library(
name = "json",
srcs = [
Expand Down
1 change: 1 addition & 0 deletions bazel/grpc_build_system.bzl
Expand Up @@ -94,6 +94,7 @@ def _update_visibility(visibility):
"endpoint_tests": PRIVATE,
"grpclb": PRIVATE,
"grpc_opencensus_plugin": PUBLIC,
"grpcpp_gcp_observability": PUBLIC,
"grpc_resolver_fake": PRIVATE,
"grpc++_test": PRIVATE,
"http": PRIVATE,
Expand Down
Expand Up @@ -14,12 +14,8 @@
// limitations under the License.
//

#ifndef GRPC_INTERNAL_CPP_EXT_GCP_OBSERVABILITY_GCP_OBSERVABILITY_H
#define GRPC_INTERNAL_CPP_EXT_GCP_OBSERVABILITY_GCP_OBSERVABILITY_H

// TODO(yashykt): This file would have been in the top include/grpcpp directory
// instead of in src/, but I'm not yet sure about the naming, so keeping it here
// till we decide.
#ifndef GRPCPP_EXT_GCP_OBSERVABILITY_H
yashykt marked this conversation as resolved.
Show resolved Hide resolved
#define GRPCPP_EXT_GCP_OBSERVABILITY_H

#include "absl/status/status.h"

Expand All @@ -32,4 +28,4 @@ absl::Status GcpObservabilityInit();
} // namespace experimental
} // namespace grpc

#endif // GRPC_INTERNAL_CPP_EXT_GCP_OBSERVABILITY_GCP_OBSERVABILITY_H
#endif // GRPCPP_EXT_GCP_OBSERVABILITY_H
5 changes: 2 additions & 3 deletions src/cpp/ext/gcp/BUILD
Expand Up @@ -28,14 +28,13 @@ package(
],
)

# This is an EXPERIMENTAL target subject to change.
grpc_cc_library(
name = "observability",
srcs = [
"observability.cc",
],
hdrs = [
"observability.h",
"//:include/grpcpp/ext/gcp_observability.h",
],
external_deps = [
"absl/status",
Expand All @@ -50,7 +49,7 @@ grpc_cc_library(
],
language = "c++",
tags = ["nofixdeps"],
visibility = ["//test:__subpackages__"],
visibility = ["//:__subpackages__"],
deps = [
":observability_config",
"//:gpr",
Expand Down
4 changes: 2 additions & 2 deletions src/cpp/ext/gcp/observability.cc
Expand Up @@ -16,14 +16,13 @@

#include <grpc/support/port_platform.h>

#include "src/cpp/ext/gcp/observability.h"

#include <stdint.h>

#include <memory>
#include <string>
#include <utility>

#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/types/optional.h"
#include "google/devtools/cloudtrace/v2/tracing.grpc.pb.h"
Expand All @@ -34,6 +33,7 @@
#include "opencensus/trace/sampler.h"
#include "opencensus/trace/trace_config.h"

#include <grpcpp/ext/gcp_observability.h>
#include <grpcpp/opencensus.h>
#include <grpcpp/security/credentials.h>
#include <grpcpp/support/channel_arguments.h>
Expand Down
2 changes: 1 addition & 1 deletion test/cpp/ext/gcp/BUILD
Expand Up @@ -28,7 +28,7 @@ grpc_cc_test(
],
language = "C++",
deps = [
"//src/cpp/ext/gcp:observability",
"//:grpcpp_gcp_observability",
"//test/cpp/util:test_util",
],
)
Expand Down
4 changes: 2 additions & 2 deletions test/cpp/ext/gcp/observability_test.cc
Expand Up @@ -14,11 +14,11 @@
// limitations under the License.
//

#include "src/cpp/ext/gcp/observability.h"

#include "gmock/gmock.h"
#include "gtest/gtest.h"

#include <grpcpp/ext/gcp_observability.h>

#include "src/core/lib/config/core_configuration.h"
#include "test/core/util/test_config.h"

Expand Down
23 changes: 17 additions & 6 deletions tools/distrib/fix_build_deps.py
Expand Up @@ -296,15 +296,22 @@ def grpc_cc_library(name,
proto_hdr = '%s%s' % ((parsing_path + '/' if parsing_path else ''),
proto.replace('.proto', '.pb.h'))
skip_headers[name].add(proto_hdr)

# Convert the source or header target to a relative path.
def get_filename(name, parsing_path):
filename = '%s%s' % (
(parsing_path + '/' if
(parsing_path and not name.startswith('//')) else ''), name)
filename = filename.replace('//:', '')
return filename

for hdr in hdrs + public_hdrs:
filename = '%s%s' % ((parsing_path + '/' if parsing_path else ''), hdr)
vendors[filename].append(name)
vendors[get_filename(hdr, parsing_path)].append(name)
inc = set()
original_deps[name] = frozenset(deps)
original_external_deps[name] = frozenset(external_deps)
for src in hdrs + public_hdrs + srcs:
filename = '%s%s' % ((parsing_path + '/' if parsing_path else ''), src)
for line in open(filename):
for line in open(get_filename(src, parsing_path)):
m = re.search(r'^#include <(.*)>', line)
if m:
inc.add(m.group(1))
Expand Down Expand Up @@ -408,7 +415,7 @@ def score_best(proposed, existing):
'load': lambda filename, *args: None,
'licenses': lambda licenses: None,
'package': lambda **kwargs: None,
'exports_files': lambda files: None,
'exports_files': lambda files, visibility=None: None,
'config_setting': lambda **kwargs: None,
'selects': FakeSelects(),
'python_config_settings': lambda **kwargs: None,
Expand All @@ -418,6 +425,7 @@ def score_best(proposed, existing):
'grpc_fuzzer': grpc_cc_library,
'grpc_proto_fuzzer': grpc_cc_library,
'select': lambda d: d["//conditions:default"],
'glob': lambda files: None,
'grpc_end2end_tests': lambda: None,
'grpc_upb_proto_library': lambda name, **kwargs: None,
'grpc_upb_proto_reflection_library': lambda name, **kwargs: None,
Expand Down Expand Up @@ -498,7 +506,10 @@ def best(self, scorer):
choices = new_choices

best = None
final_scorer = lambda x: (total_avoidness(x), scorer(x), total_score(x))

def final_scorer(x):
return (total_avoidness(x), scorer(x), total_score(x))

for choice in choices:
if best is None or final_scorer(choice) < final_scorer(best):
best = choice
Expand Down