Revert "GCP Observability: Add plugin registry API (#30571)" (#30765)

This reverts commit 486710317f.
pull/30766/head
Craig Tiller 2 years ago committed by GitHub
parent 486710317f
commit b8fde2ab47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 23
      BUILD
  2. 10
      bazel/grpc_deps.bzl
  3. 65
      src/cpp/ext/gcp_observability/gcp_observability.cc
  4. 33
      src/cpp/ext/gcp_observability/gcp_observability.h
  5. 34
      test/cpp/ext/gcp_observability/BUILD
  6. 36
      test/cpp/ext/gcp_observability/gcp_observability_test.cc
  7. 3
      tools/buildgen/extract_metadata_from_bazel_xml.py

23
BUILD

@ -7262,29 +7262,6 @@ grpc_cc_library(
], ],
) )
# This is an EXPERIMENTAL target subject to change.
grpc_cc_library(
name = "grpcpp_gcp_observability",
srcs = [
"src/cpp/ext/gcp_observability/gcp_observability.cc",
],
hdrs = [
"src/cpp/ext/gcp_observability/gcp_observability.h",
],
external_deps = [
"opencensus-trace",
"opencensus-trace-stackdriver_exporter",
"opencensus-stats-stackdriver_exporter",
],
language = "c++",
tags = ["nofixdeps"],
visibility = ["//test:__subpackages__"],
deps = [
"gpr",
"grpc_opencensus_plugin",
],
)
grpc_cc_library( grpc_cc_library(
name = "json", name = "json",
srcs = [ srcs = [

@ -170,16 +170,6 @@ def grpc_deps():
actual = "@io_opencensus_cpp//opencensus/tags:context_util", actual = "@io_opencensus_cpp//opencensus/tags:context_util",
) )
native.bind(
name = "opencensus-trace-stackdriver_exporter",
actual = "@io_opencensus_cpp//opencensus/exporters/trace/stackdriver:stackdriver_exporter",
)
native.bind(
name = "opencensus-stats-stackdriver_exporter",
actual = "@io_opencensus_cpp//opencensus/exporters/stats/stackdriver:stackdriver_exporter",
)
native.bind( native.bind(
name = "libuv", name = "libuv",
actual = "@com_github_libuv_libuv//:libuv", actual = "@com_github_libuv_libuv//:libuv",

@ -1,65 +0,0 @@
//
// Copyright 2022 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.
//
#include <grpc/support/port_platform.h>
#include "src/cpp/ext/gcp_observability/gcp_observability.h"
#include <stdint.h>
#include <utility>
#include "opencensus/exporters/stats/stackdriver/stackdriver_exporter.h"
#include "opencensus/exporters/trace/stackdriver/stackdriver_exporter.h"
#include "opencensus/trace/sampler.h"
#include "opencensus/trace/trace_config.h"
#include <grpcpp/opencensus.h>
namespace grpc {
namespace experimental {
namespace {
// TODO(yashykt): These constants are currently derived from the example at
// https://cloud.google.com/traffic-director/docs/observability-proxyless#c++.
// We might want these to be configurable.
constexpr uint32_t kMaxAttributes = 128;
constexpr uint32_t kMaxAnnotations = 128;
constexpr uint32_t kMaxMessageEvents = 128;
constexpr uint32_t kMaxLinks = 128;
} // namespace
void GcpObservabilityInit() {
// TODO(yashykt): Add code for gRPC config parsing
grpc::RegisterOpenCensusPlugin();
grpc::RegisterOpenCensusViewsForExport();
// TODO(yashykt): Setup tracing and stats exporting only if enabled in config.
// TODO(yashykt): Get probability from config
opencensus::trace::TraceConfig::SetCurrentTraceParams(
{kMaxAttributes, kMaxAnnotations, kMaxMessageEvents, kMaxLinks,
opencensus::trace::ProbabilitySampler(1.0)});
opencensus::exporters::trace::StackdriverOptions trace_opts;
// TODO(yashykt): Set up project ID based on config
opencensus::exporters::trace::StackdriverExporter::Register(
std::move(trace_opts));
opencensus::exporters::stats::StackdriverOptions stats_opts;
// TODO(yashykt): Set up project ID based on config
opencensus::exporters::stats::StackdriverExporter::Register(
std::move(stats_opts));
}
} // namespace experimental
} // namespace grpc

@ -1,33 +0,0 @@
//
// Copyright 2022 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.
//
#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.
namespace grpc {
namespace experimental {
// Initialize GCP Observability for gRPC.
void GcpObservabilityInit();
} // namespace experimental
} // namespace grpc
#endif // GRPC_INTERNAL_CPP_EXT_GCP_OBSERVABILITY_GCP_OBSERVABILITY_H

@ -1,34 +0,0 @@
# Copyright 2022 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.
load("//bazel:grpc_build_system.bzl", "grpc_cc_test", "grpc_package")
licenses(["notice"])
grpc_package(name = "test/cpp/ext/gcp_observability")
grpc_cc_test(
name = "gcp_observability_test",
srcs = [
"gcp_observability_test.cc",
],
external_deps = [
"gtest",
],
language = "C++",
deps = [
"//:grpcpp_gcp_observability",
"//test/cpp/util:test_util",
],
)

@ -1,36 +0,0 @@
//
// Copyright 2022 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.
//
#include "src/cpp/ext/gcp_observability/gcp_observability.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "test/core/util/test_config.h"
namespace {
TEST(GcpObservabilityTest, RegistrationTest) {
grpc::experimental::GcpObservabilityInit();
}
} // namespace
int main(int argc, char** argv) {
grpc::testing::TestEnvironment env(&argc, argv);
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

@ -655,8 +655,7 @@ def _exclude_unwanted_cc_tests(tests: List[str]) -> List[str]:
tests = [ tests = [
test for test in tests test for test in tests
if not test.startswith('test/cpp/ext/filters/census:') and if not test.startswith('test/cpp/ext/filters/census:') and
not test.startswith('test/core/xds:xds_channel_stack_modifier_test') and not test.startswith('test/core/xds:xds_channel_stack_modifier_test')
not test.startswith('test/cpp/ext/gcp_observability:')
] ]
# missing opencensus/stats/stats.h # missing opencensus/stats/stats.h

Loading…
Cancel
Save