1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15+ load ("@bazel_skylib//rules:common_settings.bzl" , "bool_flag" )
1516load (":bigtable_client_testing.bzl" , "bigtable_client_testing_hdrs" , "bigtable_client_testing_srcs" )
1617load (":bigtable_client_unit_tests.bzl" , "bigtable_client_unit_tests" )
1718load (":google_cloud_cpp_bigtable.bzl" , "google_cloud_cpp_bigtable_hdrs" , "google_cloud_cpp_bigtable_srcs" )
@@ -21,6 +22,16 @@ package(default_visibility = ["//visibility:private"])
2122
2223licenses (["notice" ]) # Apache 2.0
2324
25+ bool_flag (
26+ name = "enable_metrics" ,
27+ build_setting_default = True ,
28+ )
29+
30+ config_setting (
31+ name = "metrics_enabled" ,
32+ flag_values = {":enable_metrics" : "true" },
33+ )
34+
2435filegroup (
2536 name = "public_hdrs" ,
2637 srcs = [h for h in google_cloud_cpp_bigtable_hdrs if not h .startswith ("internal/" )],
@@ -31,6 +42,10 @@ cc_library(
3142 name = "google_cloud_cpp_bigtable" ,
3243 srcs = google_cloud_cpp_bigtable_srcs ,
3344 hdrs = google_cloud_cpp_bigtable_hdrs ,
45+ local_defines = select ({
46+ ":metrics_enabled" : ["GOOGLE_CLOUD_CPP_BIGTABLE_WITH_OTEL_METRICS" ],
47+ "//conditions:default" : [],
48+ }),
3449 visibility = [
3550 ":__subpackages__" ,
3651 "//:__pkg__" ,
@@ -45,7 +60,14 @@ cc_library(
4560 "@com_google_googleapis//google/longrunning:longrunning_cc_grpc" ,
4661 "@com_google_googleapis//google/rpc:error_details_cc_proto" ,
4762 "@com_github_grpc_grpc//:grpc++" ,
48- ],
63+ ] + select ({
64+ ":metrics_enabled" : [
65+ "//:opentelemetry" ,
66+ "@io_opentelemetry_cpp//api" ,
67+ "@io_opentelemetry_cpp//sdk/src/metrics" ,
68+ ],
69+ "//conditions:default" : [],
70+ }),
4971)
5072
5173filegroup (
0 commit comments