-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GSM] Some initial structure (grpc#33952)
<!-- 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. -->
- Loading branch information
Showing
8 changed files
with
266 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# gRPC Bazel BUILD file. | ||
# | ||
# 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. | ||
|
||
load( | ||
"//bazel:grpc_build_system.bzl", | ||
"grpc_cc_library", | ||
) | ||
|
||
licenses(["reciprocal"]) | ||
|
||
package( | ||
default_visibility = ["//visibility:public"], | ||
features = [ | ||
"layering_check", | ||
], | ||
) | ||
|
||
grpc_cc_library( | ||
name = "gsm_observability", | ||
srcs = [ | ||
"gsm_observability.cc", | ||
], | ||
hdrs = [ | ||
"gsm_observability.h", | ||
], | ||
external_deps = [ | ||
"absl/container:flat_hash_set", | ||
"absl/status", | ||
"absl/status:statusor", | ||
"absl/strings", | ||
"otel/sdk/src/metrics", | ||
], | ||
language = "c++", | ||
visibility = ["//:__subpackages__"], | ||
deps = [ | ||
"//:gpr_platform", | ||
"//src/cpp/ext/otel:otel_plugin", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// | ||
// | ||
// 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. | ||
// | ||
// | ||
|
||
#include <grpc/support/port_platform.h> | ||
|
||
#include "src/cpp/ext/gsm/gsm_observability.h" | ||
|
||
#include "absl/status/status.h" | ||
|
||
#include "src/cpp/ext/otel/otel_plugin.h" | ||
|
||
namespace grpc { | ||
namespace internal { | ||
|
||
// | ||
// GsmCustomObservabilityBuilder | ||
// | ||
|
||
GsmCustomObservabilityBuilder& GsmCustomObservabilityBuilder::SetMeterProvider( | ||
std::shared_ptr<opentelemetry::sdk::metrics::MeterProvider> | ||
meter_provider) { | ||
builder_.SetMeterProvider(meter_provider); | ||
return *this; | ||
} | ||
|
||
GsmCustomObservabilityBuilder& GsmCustomObservabilityBuilder::EnableMetrics( | ||
const absl::flat_hash_set<absl::string_view>& metric_names) { | ||
builder_.EnableMetrics(metric_names); | ||
return *this; | ||
} | ||
|
||
GsmCustomObservabilityBuilder& GsmCustomObservabilityBuilder::DisableMetrics( | ||
const absl::flat_hash_set<absl::string_view>& metric_names) { | ||
builder_.DisableMetrics(metric_names); | ||
return *this; | ||
} | ||
|
||
absl::StatusOr<GsmObservability> | ||
GsmCustomObservabilityBuilder::BuildAndRegister() { | ||
return absl::UnimplementedError("Not Implemented"); | ||
} | ||
|
||
} // namespace internal | ||
} // namespace grpc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// | ||
// | ||
// 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. | ||
// | ||
// | ||
|
||
#ifndef GRPC_SRC_CPP_EXT_GSM_GSM_OBSERVABILITY_H | ||
#define GRPC_SRC_CPP_EXT_GSM_GSM_OBSERVABILITY_H | ||
|
||
#include <grpc/support/port_platform.h> | ||
|
||
#include <memory> | ||
|
||
#include "absl/container/flat_hash_set.h" | ||
#include "absl/status/statusor.h" | ||
#include "absl/strings/string_view.h" | ||
#include "opentelemetry/sdk/metrics/meter_provider.h" | ||
|
||
#include "src/cpp/ext/otel/otel_plugin.h" | ||
|
||
namespace grpc { | ||
namespace internal { | ||
|
||
class GsmObservability {}; | ||
|
||
class GsmCustomObservabilityBuilder { | ||
public: | ||
// TODO(yashykt): Should this take the SDK or the API MeterProvider? Benefit | ||
// of SDK MeterProvider - Can explicitly set histogram bucket boundaries, but | ||
// in the next iteration of the API, we would have it there as well. | ||
GsmCustomObservabilityBuilder& SetMeterProvider( | ||
std::shared_ptr<opentelemetry::sdk::metrics::MeterProvider> | ||
meter_provider); | ||
// Enable metrics in \a metric_names | ||
GsmCustomObservabilityBuilder& EnableMetrics( | ||
const absl::flat_hash_set<absl::string_view>& metric_names); | ||
// Disable metrics in \a metric_names | ||
GsmCustomObservabilityBuilder& DisableMetrics( | ||
const absl::flat_hash_set<absl::string_view>& metric_names); | ||
// Builds the GsmObservability plugin. The return status shows whether | ||
// GsmObservability was successfully enabled or not. TODO(): Is the | ||
// GsmObservability object useful? | ||
absl::StatusOr<GsmObservability> BuildAndRegister(); | ||
|
||
private: | ||
OpenTelemetryPluginBuilder builder_; | ||
}; | ||
|
||
} // namespace internal | ||
} // namespace grpc | ||
|
||
#endif // GRPC_SRC_CPP_EXT_GSM_GSM_OBSERVABILITY_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# 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. | ||
|
||
load("//bazel:grpc_build_system.bzl", "grpc_cc_test", "grpc_package") | ||
|
||
licenses(["notice"]) | ||
|
||
grpc_package( | ||
name = "test/cpp/ext/gsm", | ||
visibility = "tests", | ||
) | ||
|
||
grpc_cc_test( | ||
name = "gsm_observability_test", | ||
srcs = [ | ||
"gsm_observability_test.cc", | ||
], | ||
external_deps = [ | ||
"gtest", | ||
"otel/sdk/src/metrics", | ||
], | ||
language = "C++", | ||
tags = [ | ||
], | ||
deps = [ | ||
"//:grpc++", | ||
"//src/cpp/ext/gsm:gsm_observability", | ||
"//test/core/util:grpc_test_util", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// | ||
// | ||
// 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. | ||
// | ||
// | ||
|
||
#include "src/cpp/ext/gsm/gsm_observability.h" | ||
|
||
#include "gtest/gtest.h" | ||
|
||
#include "test/core/util/test_config.h" | ||
|
||
namespace grpc { | ||
namespace testing { | ||
namespace { | ||
|
||
TEST(GsmCustomObservabilityBuilderTest, Basic) { | ||
EXPECT_EQ( | ||
internal::GsmCustomObservabilityBuilder().BuildAndRegister().status(), | ||
absl::UnimplementedError("Not Implemented")); | ||
} | ||
|
||
} // namespace | ||
} // namespace testing | ||
} // namespace grpc | ||
|
||
int main(int argc, char** argv) { | ||
grpc::testing::TestEnvironment env(&argc, argv); | ||
::testing::InitGoogleTest(&argc, argv); | ||
return RUN_ALL_TESTS(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters