Skip to content

Commit 9cb551c

Browse files
authored
cleanup: Enable flag enable_opentelemetry in bazel (#99)
1 parent 99d0301 commit 9cb551c

File tree

4 files changed

+43
-25
lines changed

4 files changed

+43
-25
lines changed

.bazelrc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ common:macos --repo_env=BAZEL_NO_APPLE_CPP_TOOLCHAIN=1
5555
test --test_env=GTEST_SHUFFLE --test_env=GTEST_RANDOM_SEED
5656

5757
# By default, build the library with OpenTelemetry
58-
# Enable the config when the bool flag is visible.
59-
# https://github.com/googleapis/google-cloud-cpp-bigquery/issues/98
60-
# build --@com_google_googleapis_google_cloud_cpp//:enable_opentelemetry
58+
build --@com_google_googleapis_google_cloud_cpp//:enable_opentelemetry
6159

6260
# Don't show warnings when building external dependencies. This still shows
6361
# warnings when using these dependencies (say in headers).

google/cloud/bigquery_unified/BUILD.bazel

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ licenses(["notice"]) # Apache 2.0
2424
config_setting(
2525
name = "enable_opentelemetry",
2626
flag_values = {
27-
"@google_cloud_cpp//:enable_opentelemetry": "true",
27+
"@com_google_googleapis_google_cloud_cpp//:enable_opentelemetry": "true",
2828
},
2929
)
3030

@@ -60,15 +60,13 @@ cc_library(
6060
name = "google_cloud_cpp_bigquery_bigquery_unified",
6161
srcs = google_cloud_cpp_bigquery_bigquery_unified_srcs,
6262
hdrs = google_cloud_cpp_bigquery_bigquery_unified_hdrs,
63-
# Enable the config when the bool flag is visible.
64-
# https://github.com/googleapis/google-cloud-cpp-bigquery/issues/98
65-
# defines = select({
66-
# ":enable_opentelemetry": [
67-
# # Enable OpenTelemetry features in google-cloud-cpp
68-
# "GOOGLE_CLOUD_CPP_BIGQUERY_HAVE_OPENTELEMETRY",
69-
# ],
70-
# "//conditions:default": [],
71-
# }),
63+
defines = select({
64+
":enable_opentelemetry": [
65+
# Enable OpenTelemetry features in google-cloud-cpp
66+
"GOOGLE_CLOUD_CPP_BIGQUERY_HAVE_OPENTELEMETRY",
67+
],
68+
"//conditions:default": [],
69+
}),
7270
visibility = ["//:__pkg__"],
7371
deps = [
7472
":google_cloud_cpp_bigquery_common",

google/cloud/bigquery_unified/connection_test.cc

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
// limitations under the License.
1414

1515
#include "google/cloud/bigquery_unified/connection.h"
16+
#include "google/cloud/bigquery_unified/job_options.h"
1617
#include "google/cloud/bigquery_unified/testing_util/opentelemetry_matchers.h"
1718
#include "google/cloud/bigquery_unified/version.h"
19+
#include "google/cloud/common_options.h"
1820

1921
namespace google::cloud::bigquery_unified {
2022
GOOGLE_CLOUD_CPP_BIGQUERY_INLINE_NAMESPACE_BEGIN
@@ -30,7 +32,12 @@ using ::testing::Not;
3032
TEST(BigQueryUnifiedConnectionTest, TracingEnabled) {
3133
auto span_catcher = testing_util::InstallSpanCatcher();
3234

33-
auto options = EnableTracing(Options{});
35+
auto options = EnableTracing(
36+
Options{}
37+
.set<EndpointOption>("localhost:1")
38+
.set<bigquery_unified::RetryPolicyOption>(
39+
std::make_shared<bigquery_unified::LimitedErrorCountRetryPolicy>(
40+
0)));
3441
auto conn = MakeConnection(std::move(options));
3542
google::cloud::internal::OptionsSpan span(
3643
google::cloud::internal::MergeOptions(Options{}, conn->options()));
@@ -46,7 +53,12 @@ TEST(BigQueryUnifiedConnectionTest, TracingEnabled) {
4653
TEST(BigQueryUnifiedConnectionTest, TracingDisabled) {
4754
auto span_catcher = testing_util::InstallSpanCatcher();
4855

49-
auto options = DisableTracing(Options{});
56+
auto options = DisableTracing(
57+
Options{}
58+
.set<EndpointOption>("localhost:1")
59+
.set<bigquery_unified::RetryPolicyOption>(
60+
std::make_shared<bigquery_unified::LimitedErrorCountRetryPolicy>(
61+
0)));
5062
auto conn = MakeConnection(std::move(options));
5163
google::cloud::internal::OptionsSpan span(
5264
google::cloud::internal::MergeOptions(Options{}, conn->options()));

google/cloud/bigquery_unified/testing_util/BUILD.bazel

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ package(default_visibility = ["//:__subpackages__"])
2020

2121
licenses(["notice"]) # Apache 2.0
2222

23+
config_setting(
24+
name = "enable_opentelemetry",
25+
flag_values = {
26+
"@com_google_googleapis_google_cloud_cpp//:enable_opentelemetry": "true",
27+
},
28+
)
29+
2330
cc_library(
2431
name = "google_cloud_cpp_bigquery_bigquery_unified_testing_private",
2532
testonly = True,
@@ -34,21 +41,24 @@ cc_library(
3441
"GOOGLE_CLOUD_CPP_HAVE_GETRUSAGE",
3542
],
3643
"//conditions:default": [],
44+
}) + select({
45+
":enable_opentelemetry": [
46+
# Enable OpenTelemetry features in google-cloud-cpp
47+
"GOOGLE_CLOUD_CPP_BIGQUERY_HAVE_OPENTELEMETRY",
48+
],
49+
"//conditions:default": [],
3750
}),
3851
deps = [
3952
"//:common",
4053
"@com_google_absl//absl/debugging:failure_signal_handler",
4154
"@com_google_absl//absl/debugging:symbolize",
4255
"@com_google_googletest//:gtest_main",
4356
"@google_cloud_cpp//:common",
44-
],
45-
# Enable the config when the bool flag is visible.
46-
# https://github.com/googleapis/google-cloud-cpp-bigquery/issues/98
47-
# + select({
48-
# ":enable_opentelemetry": [
49-
# "@io_opentelemetry_cpp//exporters/memory:in_memory_span_exporter",
50-
# "@io_opentelemetry_cpp//sdk/src/trace",
51-
# ],
52-
# "//conditions:default": [],
53-
# })
57+
] + select({
58+
":enable_opentelemetry": [
59+
"@io_opentelemetry_cpp//exporters/memory:in_memory_span_exporter",
60+
"@io_opentelemetry_cpp//sdk/src/trace",
61+
],
62+
"//conditions:default": [],
63+
}),
5464
)

0 commit comments

Comments
 (0)