mirror of https://github.com/grpc/grpc.git
This reverts commit 486710317f
.
pull/30766/head
parent
486710317f
commit
b8fde2ab47
7 changed files with 1 additions and 203 deletions
@ -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(); |
|
||||||
} |
|
Loading…
Reference in new issue