From 2025d7063d9c2ecc06bd2bef3c88ceffaae2114c Mon Sep 17 00:00:00 2001 From: mpeddada1 Date: Wed, 17 Dec 2025 20:44:46 +0000 Subject: [PATCH 1/8] feat: remove ifdef opentelemetry statements in handwritten libs --- ...en_kitchen_sink_tracing_connection_test.cc | 3 -- .../golden_kitchen_sink_tracing_stub_test.cc | 17 -------- .../golden_thing_admin_connection_test.cc | 4 -- ...golden_thing_admin_rest_connection_test.cc | 3 -- ...den_thing_admin_tracing_connection_test.cc | 15 ------- .../golden_thing_admin_tracing_stub_test.cc | 20 --------- google/cloud/BUILD.bazel | 4 -- google/cloud/bigtable/data_connection_test.cc | 2 - .../internal/async_bulk_apply_test.cc | 2 - .../internal/async_row_reader_test.cc | 2 - .../internal/async_row_sampler_test.cc | 2 - .../internal/bigtable_stub_factory_test.cc | 2 - .../internal/data_tracing_connection.cc | 3 -- .../internal/data_tracing_connection_test.cc | 2 - .../internal/mutate_rows_limiter_test.cc | 2 - .../bigtable/internal/traced_row_reader.cc | 2 - .../bigtable/internal/traced_row_reader.h | 2 - .../internal/traced_row_reader_test.cc | 2 - google/cloud/bigtable/row_reader_test.cc | 2 - google/cloud/google_cloud_cpp_common.cmake | 4 +- .../internal/async_connection_ready_test.cc | 4 -- .../cloud/internal/async_polling_loop_test.cc | 3 -- .../async_read_write_stream_impl_test.cc | 4 -- .../async_read_write_stream_tracing.h | 2 - .../async_read_write_stream_tracing_test.cc | 4 +- .../internal/async_rest_polling_loop_test.cc | 3 -- .../internal/async_rest_retry_loop_test.cc | 3 -- .../cloud/internal/async_retry_loop_test.cc | 3 -- .../async_streaming_read_rpc_impl_test.cc | 4 -- .../async_streaming_read_rpc_tracing.h | 2 - .../async_streaming_read_rpc_tracing_test.cc | 4 +- .../async_streaming_write_rpc_impl_test.cc | 4 -- .../async_streaming_write_rpc_tracing.h | 2 - .../async_streaming_write_rpc_tracing_test.cc | 2 - google/cloud/internal/call_context.h | 11 +---- google/cloud/internal/call_context_test.cc | 3 -- google/cloud/internal/grpc_opentelemetry.cc | 5 --- google/cloud/internal/grpc_opentelemetry.h | 8 ---- .../cloud/internal/grpc_opentelemetry_test.cc | 5 --- .../internal/minimal_iam_credentials_stub.cc | 5 --- .../minimal_iam_credentials_stub_test.cc | 2 - google/cloud/internal/opentelemetry.cc | 14 ------- google/cloud/internal/opentelemetry.h | 42 +++++++++++++++---- .../cloud/internal/opentelemetry_context.cc | 2 - google/cloud/internal/opentelemetry_context.h | 2 - .../internal/opentelemetry_context_test.cc | 2 - google/cloud/internal/opentelemetry_test.cc | 20 --------- google/cloud/internal/rest_carrier.cc | 4 -- google/cloud/internal/rest_carrier.h | 4 -- google/cloud/internal/rest_carrier_test.cc | 4 -- google/cloud/internal/rest_opentelemetry.cc | 3 -- google/cloud/internal/rest_opentelemetry.h | 3 -- .../cloud/internal/rest_opentelemetry_test.cc | 3 -- google/cloud/internal/rest_retry_loop_test.cc | 3 -- google/cloud/internal/retry_loop_test.cc | 3 -- .../internal/streaming_read_rpc_tracing.h | 2 - .../streaming_read_rpc_tracing_test.cc | 2 - .../internal/streaming_write_rpc_tracing.h | 2 - .../streaming_write_rpc_tracing_test.cc | 2 - google/cloud/internal/trace_propagator.cc | 5 +-- google/cloud/internal/trace_propagator.h | 4 -- .../cloud/internal/trace_propagator_test.cc | 4 +- google/cloud/internal/traced_stream_range.h | 2 - .../internal/traced_stream_range_test.cc | 4 +- google/cloud/internal/tracing_http_payload.cc | 4 -- google/cloud/internal/tracing_http_payload.h | 4 -- .../internal/tracing_http_payload_test.cc | 3 -- google/cloud/internal/tracing_rest_client.cc | 5 +-- .../internal/tracing_rest_client_test.cc | 5 --- .../cloud/internal/tracing_rest_response.cc | 4 -- google/cloud/internal/tracing_rest_response.h | 4 -- .../internal/tracing_rest_response_test.cc | 3 -- ...onfigure_basic_tracing_integration_test.cc | 4 +- .../internal/resource_detector_impl_test.cc | 2 - .../opentelemetry/trace_exporter_test.cc | 2 - .../blocking_publisher_integration_test.cc | 3 +- .../batching_publisher_tracing_connection.cc | 13 ------ .../blocking_publisher_tracing_connection.cc | 13 ------ ...cking_publisher_tracing_connection_test.cc | 4 -- .../internal/extend_leases_with_retry.cc | 11 ----- .../internal/extend_leases_with_retry_test.cc | 4 -- ...controlled_publisher_tracing_connection.cc | 14 ------- ...olled_publisher_tracing_connection_test.cc | 4 -- .../cloud/pubsub/internal/message_carrier.cc | 6 +-- .../cloud/pubsub/internal/message_carrier.h | 4 -- .../pubsub/internal/message_carrier_test.cc | 6 +-- .../pubsub/internal/message_propagator.cc | 6 +-- .../pubsub/internal/message_propagator.h | 4 -- .../internal/message_propagator_test.cc | 4 -- .../internal/publisher_stub_factory_test.cc | 2 - .../internal/publisher_tracing_connection.cc | 25 +++-------- .../publisher_tracing_connection_test.cc | 4 -- .../internal/pull_ack_handler_factory_test.cc | 3 -- .../pull_lease_manager_factory_test.cc | 3 -- google/cloud/pubsub/internal/span.h | 6 +-- .../internal/subscriber_stub_factory_test.cc | 2 - .../internal/subscriber_tracing_connection.cc | 13 ------ .../subscriber_tracing_connection_test.cc | 6 +-- .../internal/subscription_session_test.cc | 8 +--- .../pubsub/internal/tracing_batch_callback.cc | 14 ------- .../internal/tracing_batch_callback_test.cc | 6 +-- .../pubsub/internal/tracing_batch_sink.cc | 13 ------ .../internal/tracing_batch_sink_test.cc | 4 -- .../tracing_exactly_once_ack_handler.cc | 13 ------ .../tracing_exactly_once_ack_handler_test.cc | 4 -- .../cloud/pubsub/internal/tracing_helpers.cc | 4 -- .../cloud/pubsub/internal/tracing_helpers.h | 4 -- .../pubsub/internal/tracing_helpers_test.cc | 4 -- .../internal/tracing_message_callback.cc | 13 ------ .../internal/tracing_message_callback_test.cc | 29 +------------ .../internal/tracing_pull_ack_handler.cc | 13 ------ .../internal/tracing_pull_ack_handler_test.cc | 4 -- .../internal/tracing_pull_lease_manager.cc | 14 ------- .../tracing_pull_lease_manager_test.cc | 6 +-- .../cloud/pubsub/publisher_connection_test.cc | 2 - .../pubsub/subscriber_connection_test.cc | 4 +- .../internal/spanner_stub_factory_test.cc | 2 - google/cloud/storage/client_test.cc | 3 -- .../internal/async/connection_tracing.cc | 12 ------ .../internal/async/connection_tracing_test.cc | 4 -- .../object_descriptor_connection_tracing.cc | 6 --- .../object_descriptor_connection_tracing.h | 6 --- ...ject_descriptor_connection_tracing_test.cc | 4 -- .../async/object_descriptor_reader_tracing.cc | 13 ------ .../object_descriptor_reader_tracing_test.cc | 4 -- .../async/reader_connection_tracing.cc | 4 -- .../async/reader_connection_tracing.h | 4 -- .../async/reader_connection_tracing_test.cc | 4 -- .../async/rewriter_connection_tracing.cc | 13 ------ .../async/rewriter_connection_tracing_test.cc | 6 +-- .../async/writer_connection_tracing.cc | 3 -- .../async/writer_connection_tracing.h | 4 -- .../async/writer_connection_tracing_test.cc | 4 -- .../storage/internal/connection_impl_test.cc | 2 - .../internal/retry_object_read_source_test.cc | 3 -- .../internal/storage_stub_factory_test.cc | 2 - .../storage/internal/tracing_connection.cc | 11 ----- .../storage/internal/tracing_connection.h | 4 -- .../internal/tracing_connection_test.cc | 4 -- .../internal/tracing_object_read_source.cc | 4 -- .../internal/tracing_object_read_source.h | 4 -- .../tracing_object_read_source_test.cc | 4 -- google/cloud/stream_range_test.cc | 4 -- 143 files changed, 62 insertions(+), 749 deletions(-) diff --git a/generator/integration_tests/tests/golden_kitchen_sink_tracing_connection_test.cc b/generator/integration_tests/tests/golden_kitchen_sink_tracing_connection_test.cc index dee9cb2a324a3..707b3cb8106cd 100644 --- a/generator/integration_tests/tests/golden_kitchen_sink_tracing_connection_test.cc +++ b/generator/integration_tests/tests/golden_kitchen_sink_tracing_connection_test.cc @@ -32,7 +32,6 @@ using ::google::cloud::golden_v1_mocks::MockGoldenKitchenSinkConnection; using ::google::cloud::testing_util::StatusIs; using ::testing::Return; -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY using ::google::cloud::testing_util::DisableTracing; using ::google::cloud::testing_util::EnableTracing; using ::google::cloud::testing_util::InstallSpanCatcher; @@ -388,8 +387,6 @@ TEST(MakeGoldenKitchenSinkTracingConnection, NoOpenTelemetry) { EXPECT_THAT(result, StatusIs(StatusCode::kAborted)); } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - } // namespace GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace golden_v1_internal diff --git a/generator/integration_tests/tests/golden_kitchen_sink_tracing_stub_test.cc b/generator/integration_tests/tests/golden_kitchen_sink_tracing_stub_test.cc index 306754d8db0f4..69e6bf36d0630 100644 --- a/generator/integration_tests/tests/golden_kitchen_sink_tracing_stub_test.cc +++ b/generator/integration_tests/tests/golden_kitchen_sink_tracing_stub_test.cc @@ -33,8 +33,6 @@ namespace { using ::google::cloud::testing_util::StatusIs; using ::testing::Return; -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - using ::google::cloud::testing_util::InstallSpanCatcher; using ::google::cloud::testing_util::OTelAttribute; using ::google::cloud::testing_util::OTelContextCaptured; @@ -489,21 +487,6 @@ TEST(MakeGoldenKitchenSinkTracingStub, OpenTelemetry) { EXPECT_THAT(spans, Not(IsEmpty())); } -#else - -TEST(MakeGoldenKitchenSinkTracingStub, NoOpenTelemetry) { - auto mock = std::make_shared(); - EXPECT_CALL(*mock, DoNothing) - .WillOnce(Return(internal::AbortedError("fail"))); - - auto under_test = MakeGoldenKitchenSinkTracingStub(mock); - grpc::ClientContext context; - auto result = under_test->DoNothing(context, Options{}, {}); - EXPECT_THAT(result, StatusIs(StatusCode::kAborted)); -} - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - } // namespace GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace golden_v1_internal diff --git a/generator/integration_tests/tests/golden_thing_admin_connection_test.cc b/generator/integration_tests/tests/golden_thing_admin_connection_test.cc index f4fd6b1c543cf..ef2d6171bd9a3 100644 --- a/generator/integration_tests/tests/golden_thing_admin_connection_test.cc +++ b/generator/integration_tests/tests/golden_thing_admin_connection_test.cc @@ -1617,7 +1617,6 @@ TEST(GoldenThingAdminConnectionTest, CheckExpectedOptions) { Contains(ContainsRegex("Unexpected option.+UnexpectedOption"))); } -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY using ::google::cloud::testing_util::DisableTracing; using ::google::cloud::testing_util::EnableTracing; using ::google::cloud::testing_util::SpanNamed; @@ -1662,9 +1661,6 @@ TEST(GoldenThingAdminConnectionTest, TracingDisabled) { Not(Contains(SpanNamed( "golden_v1::GoldenThingAdminConnection::DeleteBackup")))); } - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - } // namespace GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace golden_v1 diff --git a/generator/integration_tests/tests/golden_thing_admin_rest_connection_test.cc b/generator/integration_tests/tests/golden_thing_admin_rest_connection_test.cc index 3e148cc032271..721ff35c2e208 100644 --- a/generator/integration_tests/tests/golden_thing_admin_rest_connection_test.cc +++ b/generator/integration_tests/tests/golden_thing_admin_rest_connection_test.cc @@ -1678,7 +1678,6 @@ TEST(GoldenThingAdminConnectionTest, ConnectionCreatedWithOption) { EXPECT_THAT(conn->options().get(), Eq("foo")); } -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY using ::google::cloud::testing_util::DisableTracing; using ::google::cloud::testing_util::EnableTracing; using ::google::cloud::testing_util::SpanNamed; @@ -1723,8 +1722,6 @@ TEST(GoldenThingAdminConnectionTest, TracingDisabled) { Not(Contains(SpanNamed( "golden_v1::GoldenThingAdminConnection::DeleteBackup")))); } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - } // namespace GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace golden_v1 diff --git a/generator/integration_tests/tests/golden_thing_admin_tracing_connection_test.cc b/generator/integration_tests/tests/golden_thing_admin_tracing_connection_test.cc index 7e994c2abef99..348d7016d2761 100644 --- a/generator/integration_tests/tests/golden_thing_admin_tracing_connection_test.cc +++ b/generator/integration_tests/tests/golden_thing_admin_tracing_connection_test.cc @@ -32,7 +32,6 @@ using ::google::cloud::golden_v1_mocks::MockGoldenThingAdminConnection; using ::google::cloud::testing_util::StatusIs; using ::testing::Return; -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY using ::google::cloud::testing_util::DisableTracing; using ::google::cloud::testing_util::EnableTracing; using ::google::cloud::testing_util::InstallSpanCatcher; @@ -702,20 +701,6 @@ TEST(MakeGoldenThingAdminTracingConnection, TracingDisabled) { EXPECT_THAT(spans, IsEmpty()); } -#else - -TEST(MakeGoldenThingAdminTracingConnection, NoOpenTelemetry) { - auto mock = std::make_shared(); - EXPECT_CALL(*mock, DropDatabase) - .WillOnce(Return(internal::AbortedError("fail"))); - - auto under_test = MakeGoldenThingAdminTracingConnection(mock); - auto result = under_test->DropDatabase({}); - EXPECT_THAT(result, StatusIs(StatusCode::kAborted)); -} - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - } // namespace GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace golden_v1_internal diff --git a/generator/integration_tests/tests/golden_thing_admin_tracing_stub_test.cc b/generator/integration_tests/tests/golden_thing_admin_tracing_stub_test.cc index 8ca098fdea0a8..4c01aa06805c3 100644 --- a/generator/integration_tests/tests/golden_thing_admin_tracing_stub_test.cc +++ b/generator/integration_tests/tests/golden_thing_admin_tracing_stub_test.cc @@ -26,8 +26,6 @@ namespace golden_v1_internal { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN namespace { -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - using ::google::cloud::testing_util::InstallSpanCatcher; using ::google::cloud::testing_util::OTelAttribute; using ::google::cloud::testing_util::OTelContextCaptured; @@ -698,24 +696,6 @@ TEST(MakeGoldenThingAdminTracingStub, OpenTelemetry) { EXPECT_THAT(spans, Not(IsEmpty())); } -#else - -using ::google::cloud::testing_util::StatusIs; -using ::testing::Return; - -TEST(MakeGoldenThingAdminTracingStub, NoOpenTelemetry) { - auto mock = std::make_shared(); - EXPECT_CALL(*mock, DropDatabase) - .WillOnce(Return(internal::AbortedError("fail"))); - - auto under_test = MakeGoldenThingAdminTracingStub(mock); - grpc::ClientContext context; - auto result = under_test->DropDatabase(context, Options{}, {}); - EXPECT_THAT(result, StatusIs(StatusCode::kAborted)); -} - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - } // namespace GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace golden_v1_internal diff --git a/google/cloud/BUILD.bazel b/google/cloud/BUILD.bazel index dd5358871e187..8ed27115adb70 100644 --- a/google/cloud/BUILD.bazel +++ b/google/cloud/BUILD.bazel @@ -54,10 +54,6 @@ cc_library( name = "google_cloud_cpp_common_private", srcs = google_cloud_cpp_common_srcs + ["internal/build_info.cc"], hdrs = google_cloud_cpp_common_hdrs, - defines = [ - # Enable OpenTelemetry features in google-cloud-cpp - "GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY", - ], linkopts = select({ "@platforms//os:windows": [ "-DEFAULTLIB:bcrypt.lib", diff --git a/google/cloud/bigtable/data_connection_test.cc b/google/cloud/bigtable/data_connection_test.cc index 2a428214bca96..e51d7f38819e8 100644 --- a/google/cloud/bigtable/data_connection_test.cc +++ b/google/cloud/bigtable/data_connection_test.cc @@ -54,7 +54,6 @@ TEST(MakeDataConnection, DefaultsOptions) { << "User supplied Options are overridden in MakeDataConnection()"; } -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY using ::google::cloud::testing_util::DisableTracing; using ::google::cloud::testing_util::EnableTracing; using ::google::cloud::testing_util::SpanNamed; @@ -81,7 +80,6 @@ TEST(MakeDataConnection, TracingDisabled) { EXPECT_THAT(span_catcher->GetSpans(), IsEmpty()); } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY } // namespace GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/bigtable/internal/async_bulk_apply_test.cc b/google/cloud/bigtable/internal/async_bulk_apply_test.cc index d8304717c466b..930eed5281915 100644 --- a/google/cloud/bigtable/internal/async_bulk_apply_test.cc +++ b/google/cloud/bigtable/internal/async_bulk_apply_test.cc @@ -1119,7 +1119,6 @@ TEST_F(AsyncBulkApplyTest, BigtableCookie) { CheckFailedMutations(actual.get(), expected); } -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY using ::google::cloud::testing_util::EnableTracing; using ::google::cloud::testing_util::IsActive; using ::google::cloud::testing_util::SpanNamed; @@ -1191,7 +1190,6 @@ TEST_F(AsyncBulkApplyTest, CallSpanActiveThroughout) { auto overlay = opentelemetry::trace::Scope(internal::MakeSpan("overlay")); (void)f.get(); } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY } // namespace GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/bigtable/internal/async_row_reader_test.cc b/google/cloud/bigtable/internal/async_row_reader_test.cc index 41dfec788c604..b742726626875 100644 --- a/google/cloud/bigtable/internal/async_row_reader_test.cc +++ b/google/cloud/bigtable/internal/async_row_reader_test.cc @@ -1733,7 +1733,6 @@ TEST_F(AsyncRowReaderTest, BigtableCookie) { std::make_shared()); } -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY using ::google::cloud::testing_util::EnableTracing; using ::google::cloud::testing_util::IsActive; using ::google::cloud::testing_util::SpanNamed; @@ -1811,7 +1810,6 @@ TEST_F(AsyncRowReaderTest, CallSpanActiveThroughout) { // Block until the async call has completed. p.get_future().get(); } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY } // namespace GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace bigtable_internal diff --git a/google/cloud/bigtable/internal/async_row_sampler_test.cc b/google/cloud/bigtable/internal/async_row_sampler_test.cc index 5a88ade0c8f84..8593f32811c88 100644 --- a/google/cloud/bigtable/internal/async_row_sampler_test.cc +++ b/google/cloud/bigtable/internal/async_row_sampler_test.cc @@ -772,7 +772,6 @@ TEST_F(AsyncSampleRowKeysTest, BigtableCookie) { EXPECT_THAT(sor, StatusIs(StatusCode::kPermissionDenied, HasSubstr("fail"))); } -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY using ::google::cloud::testing_util::EnableTracing; using ::google::cloud::testing_util::IsActive; using ::google::cloud::testing_util::SpanNamed; @@ -838,7 +837,6 @@ TEST_F(AsyncSampleRowKeysTest, CallSpanActiveThroughout) { auto overlay = opentelemetry::trace::Scope(internal::MakeSpan("overlay")); (void)f.get(); } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY } // namespace GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/bigtable/internal/bigtable_stub_factory_test.cc b/google/cloud/bigtable/internal/bigtable_stub_factory_test.cc index d7b07d00cc171..a94e233fd2928 100644 --- a/google/cloud/bigtable/internal/bigtable_stub_factory_test.cc +++ b/google/cloud/bigtable/internal/bigtable_stub_factory_test.cc @@ -264,7 +264,6 @@ TEST(BigtableStubFactory, FeaturesFlags) { (void)stub->MutateRow(context, Options{}, {}); } -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY using ::google::cloud::testing_util::DisableTracing; using ::google::cloud::testing_util::EnableTracing; using ::google::cloud::testing_util::SpanNamed; @@ -335,7 +334,6 @@ TEST(BigtableStubFactory, TracingDisabled) { EXPECT_THAT(span_catcher->GetSpans(), IsEmpty()); } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY } // namespace GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/bigtable/internal/data_tracing_connection.cc b/google/cloud/bigtable/internal/data_tracing_connection.cc index e7c4942135b62..c8440821e7434 100644 --- a/google/cloud/bigtable/internal/data_tracing_connection.cc +++ b/google/cloud/bigtable/internal/data_tracing_connection.cc @@ -21,7 +21,6 @@ namespace cloud { namespace bigtable_internal { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY namespace { std::vector EndBulkApplySpan( @@ -222,8 +221,6 @@ std::shared_ptr MakeDataTracingConnection( return conn; } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace bigtable_internal } // namespace cloud diff --git a/google/cloud/bigtable/internal/data_tracing_connection_test.cc b/google/cloud/bigtable/internal/data_tracing_connection_test.cc index 5e9fadf777fc6..d60ef219b1a07 100644 --- a/google/cloud/bigtable/internal/data_tracing_connection_test.cc +++ b/google/cloud/bigtable/internal/data_tracing_connection_test.cc @@ -26,7 +26,6 @@ namespace bigtable_internal { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN namespace { -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY using ::google::cloud::bigtable_mocks::MockDataConnection; using ::google::cloud::testing_util::InstallSpanCatcher; using ::google::cloud::testing_util::IsOkAndHolds; @@ -641,7 +640,6 @@ TEST(DataTracingConnection, AsyncReadRowFailure) { Not(SpanHasAttributes( OTelAttribute("gcloud.bigtable.row_found", _)))))); } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY } // namespace GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/bigtable/internal/mutate_rows_limiter_test.cc b/google/cloud/bigtable/internal/mutate_rows_limiter_test.cc index c8636759728fd..d392d00c3ef73 100644 --- a/google/cloud/bigtable/internal/mutate_rows_limiter_test.cc +++ b/google/cloud/bigtable/internal/mutate_rows_limiter_test.cc @@ -278,7 +278,6 @@ TEST(MakeMutateRowsLimiter, LoggingDisabled) { } } -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY using ::google::cloud::testing_util::DisableTracing; using ::google::cloud::testing_util::EnableTracing; using ::google::cloud::testing_util::MockCompletionQueueImpl; @@ -353,7 +352,6 @@ TEST(MakeMutateRowsLimiter, TracingDisabledAsync) { EXPECT_THAT(span_catcher->GetSpans(), IsEmpty()); } } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY } // namespace GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/bigtable/internal/traced_row_reader.cc b/google/cloud/bigtable/internal/traced_row_reader.cc index 55397c63f17ff..07fbeb8b59929 100644 --- a/google/cloud/bigtable/internal/traced_row_reader.cc +++ b/google/cloud/bigtable/internal/traced_row_reader.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include "google/cloud/bigtable/internal/traced_row_reader.h" #include "google/cloud/internal/opentelemetry.h" @@ -72,4 +71,3 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace bigtable_internal } // namespace cloud } // namespace google -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY diff --git a/google/cloud/bigtable/internal/traced_row_reader.h b/google/cloud/bigtable/internal/traced_row_reader.h index a423214d6dd7e..c7221b3a46ca6 100644 --- a/google/cloud/bigtable/internal/traced_row_reader.h +++ b/google/cloud/bigtable/internal/traced_row_reader.h @@ -15,7 +15,6 @@ #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_INTERNAL_TRACED_ROW_READER_H #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_INTERNAL_TRACED_ROW_READER_H -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include "google/cloud/bigtable/row_reader.h" namespace google { @@ -36,6 +35,5 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace bigtable_internal } // namespace cloud } // namespace google -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_INTERNAL_TRACED_ROW_READER_H diff --git a/google/cloud/bigtable/internal/traced_row_reader_test.cc b/google/cloud/bigtable/internal/traced_row_reader_test.cc index cad809b81496e..a10093febf9f0 100644 --- a/google/cloud/bigtable/internal/traced_row_reader_test.cc +++ b/google/cloud/bigtable/internal/traced_row_reader_test.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include "google/cloud/bigtable/internal/traced_row_reader.h" #include "google/cloud/bigtable/mocks/mock_row_reader.h" #include "google/cloud/internal/make_status.h" @@ -151,4 +150,3 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace bigtable_internal } // namespace cloud } // namespace google -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY diff --git a/google/cloud/bigtable/row_reader_test.cc b/google/cloud/bigtable/row_reader_test.cc index b11f897d62362..1ab61568e94c3 100644 --- a/google/cloud/bigtable/row_reader_test.cc +++ b/google/cloud/bigtable/row_reader_test.cc @@ -90,7 +90,6 @@ TEST(RowReaderTest, OptionsSpan) { } } -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY using ::google::cloud::testing_util::IsActive; TEST(RowReader, CallSpanActiveThroughout) { @@ -121,7 +120,6 @@ TEST(RowReader, CallSpanActiveThroughout) { EXPECT_STATUS_OK(row); } } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY } // anonymous namespace GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/google_cloud_cpp_common.cmake b/google/cloud/google_cloud_cpp_common.cmake index 773857ef720d1..07cdae994b377 100644 --- a/google/cloud/google_cloud_cpp_common.cmake +++ b/google/cloud/google_cloud_cpp_common.cmake @@ -203,9 +203,7 @@ if (opentelemetry IN_LIST GOOGLE_CLOUD_CPP_ENABLE) target_link_libraries(google_cloud_cpp_common PUBLIC opentelemetry-cpp::api) target_compile_definitions( - google_cloud_cpp_common - PUBLIC # Enable OpenTelemetry features in google-cloud-cpp - GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY) + google_cloud_cpp_common) set(GOOGLE_CLOUD_CPP_FIND_OPTIONAL_DEPENDENCIES "find_dependency(opentelemetry-cpp)") set(GOOGLE_CLOUD_CPP_OPENTELEMETRY_API "opentelemetry_api") diff --git a/google/cloud/internal/async_connection_ready_test.cc b/google/cloud/internal/async_connection_ready_test.cc index fbf6feca8ba59..6dfe8a528bd26 100644 --- a/google/cloud/internal/async_connection_ready_test.cc +++ b/google/cloud/internal/async_connection_ready_test.cc @@ -100,8 +100,6 @@ TEST(CompletionQueueTest, SuccessfulWaitingForConnection) { cli_thread.join(); } -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - TEST(CompletionQueueTest, PropagateCallContext) { auto span_catcher = testing_util::InstallSpanCatcher(); @@ -137,8 +135,6 @@ TEST(CompletionQueueTest, PropagateCallContext) { t.join(); } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - } // namespace } // namespace internal GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/internal/async_polling_loop_test.cc b/google/cloud/internal/async_polling_loop_test.cc index 0de2fb563dde3..2ca520c9efb99 100644 --- a/google/cloud/internal/async_polling_loop_test.cc +++ b/google/cloud/internal/async_polling_loop_test.cc @@ -642,7 +642,6 @@ TEST(AsyncPollingLoopTest, ConfigurePollContext) { HasSubstr("operation cancelled")))); } -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY using ::google::cloud::testing_util::EnableTracing; using ::google::cloud::testing_util::IsActive; using ::google::cloud::testing_util::OTelAttribute; @@ -773,8 +772,6 @@ TEST(AsyncPollingLoopTest, TraceCapturesOperationName) { "gl-cpp.LRO_name", "test-op-name"))))); } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - } // namespace } // namespace internal GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/internal/async_read_write_stream_impl_test.cc b/google/cloud/internal/async_read_write_stream_impl_test.cc index f35ddf4925594..908e85294a8a5 100644 --- a/google/cloud/internal/async_read_write_stream_impl_test.cc +++ b/google/cloud/internal/async_read_write_stream_impl_test.cc @@ -215,8 +215,6 @@ TEST(AsyncReadWriteStreamingRpcTest, Error) { EXPECT_THAT(metadata.trailers, IsEmpty()); } -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - using ::google::cloud::testing_util::IsActive; TEST(AsyncReadWriteStreamingRpcTest, SpanActiveAcrossAsyncGrpcOperations) { @@ -330,8 +328,6 @@ TEST(AsyncReadWriteStreamingRpcTest, SpanActiveAcrossAsyncGrpcOperations) { (void)finish.get(); } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - } // namespace } // namespace internal GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/internal/async_read_write_stream_tracing.h b/google/cloud/internal/async_read_write_stream_tracing.h index 8d6be0a09541d..707daa4962fc5 100644 --- a/google/cloud/internal/async_read_write_stream_tracing.h +++ b/google/cloud/internal/async_read_write_stream_tracing.h @@ -15,7 +15,6 @@ #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_ASYNC_READ_WRITE_STREAM_TRACING_H #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_ASYNC_READ_WRITE_STREAM_TRACING_H -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include "google/cloud/internal/async_read_write_stream_impl.h" #include "google/cloud/internal/grpc_opentelemetry.h" #include "google/cloud/version.h" @@ -132,6 +131,5 @@ class AsyncStreamingReadWriteRpcTracing GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace cloud } // namespace google -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_ASYNC_READ_WRITE_STREAM_TRACING_H diff --git a/google/cloud/internal/async_read_write_stream_tracing_test.cc b/google/cloud/internal/async_read_write_stream_tracing_test.cc index 8476e4b649fa4..fcad4608075b8 100644 --- a/google/cloud/internal/async_read_write_stream_tracing_test.cc +++ b/google/cloud/internal/async_read_write_stream_tracing_test.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include "google/cloud/internal/async_read_write_stream_tracing.h" #include "google/cloud/mocks/mock_async_streaming_read_write_rpc.h" #include "google/cloud/internal/make_status.h" @@ -389,5 +388,4 @@ TEST(AsyncStreamingReadWriteRpcTracing, StartedStreamShouldExtractMetadata) { } // namespace internal GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace cloud -} // namespace google -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY +} // namespace google \ No newline at end of file diff --git a/google/cloud/internal/async_rest_polling_loop_test.cc b/google/cloud/internal/async_rest_polling_loop_test.cc index faba03fa52b19..b382b427bf8be 100644 --- a/google/cloud/internal/async_rest_polling_loop_test.cc +++ b/google/cloud/internal/async_rest_polling_loop_test.cc @@ -588,7 +588,6 @@ TEST(AsyncRestPollingLoopTest, PollThenCancelDuringPoll) { HasSubstr("operation cancelled")))); } -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY using ::google::cloud::testing_util::EnableTracing; using ::google::cloud::testing_util::IsActive; using ::google::cloud::testing_util::OTelAttribute; @@ -724,8 +723,6 @@ TEST(AsyncRestPollingLoopTest, TraceCapturesOperationName) { "gl-cpp.LRO_name", "test-op-name"))))); } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - } // namespace GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace rest_internal diff --git a/google/cloud/internal/async_rest_retry_loop_test.cc b/google/cloud/internal/async_rest_retry_loop_test.cc index 1fa7e50cae506..092daf90b63e6 100644 --- a/google/cloud/internal/async_rest_retry_loop_test.cc +++ b/google/cloud/internal/async_rest_retry_loop_test.cc @@ -559,7 +559,6 @@ TEST_F(AsyncRestRetryLoopCancelTest, ShutdownDuringTimer) { Contains(Pair("gcloud-cpp.retry.function", "test-location"))); } -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY using ::google::cloud::testing_util::EnableTracing; using ::google::cloud::testing_util::IsActive; using ::google::cloud::testing_util::SpanNamed; @@ -615,8 +614,6 @@ TEST(AsyncRestRetryLoopTest, CallSpanActiveDuringCancel) { (void)actual.get(); } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - } // namespace GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace rest_internal diff --git a/google/cloud/internal/async_retry_loop_test.cc b/google/cloud/internal/async_retry_loop_test.cc index 679c06f5da4e4..7e200d4eec613 100644 --- a/google/cloud/internal/async_retry_loop_test.cc +++ b/google/cloud/internal/async_retry_loop_test.cc @@ -604,7 +604,6 @@ TEST_F(AsyncRetryLoopCancelTest, ShutdownDuringTimer) { Contains(Pair("gcloud-cpp.retry.function", "test-location"))); } -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY using ::google::cloud::testing_util::EnableTracing; using ::google::cloud::testing_util::IsActive; using ::google::cloud::testing_util::SpanNamed; @@ -658,8 +657,6 @@ TEST(AsyncRetryLoopTest, CallSpanActiveDuringCancel) { (void)actual.get(); } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - } // namespace } // namespace internal GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/internal/async_streaming_read_rpc_impl_test.cc b/google/cloud/internal/async_streaming_read_rpc_impl_test.cc index 31ec5c6eb3309..e8a1fbfaede47 100644 --- a/google/cloud/internal/async_streaming_read_rpc_impl_test.cc +++ b/google/cloud/internal/async_streaming_read_rpc_impl_test.cc @@ -172,8 +172,6 @@ TEST(AsyncStreamingReadRpcTest, Error) { stream.Finish().get()); } -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - using ::google::cloud::testing_util::IsActive; TEST(AsyncStreamingReadRpcTest, SpanActiveAcrossAsyncGrpcOperations) { @@ -262,8 +260,6 @@ TEST(AsyncStreamingReadRpcTest, SpanActiveAcrossAsyncGrpcOperations) { (void)finish.get(); } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - } // namespace } // namespace internal GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/internal/async_streaming_read_rpc_tracing.h b/google/cloud/internal/async_streaming_read_rpc_tracing.h index 71e77f2d02732..2099531b2754d 100644 --- a/google/cloud/internal/async_streaming_read_rpc_tracing.h +++ b/google/cloud/internal/async_streaming_read_rpc_tracing.h @@ -15,7 +15,6 @@ #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_ASYNC_STREAMING_READ_RPC_TRACING_H #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_ASYNC_STREAMING_READ_RPC_TRACING_H -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include "google/cloud/internal/async_streaming_read_rpc.h" #include "google/cloud/internal/grpc_opentelemetry.h" #include "google/cloud/version.h" @@ -108,6 +107,5 @@ class AsyncStreamingReadRpcTracing : public AsyncStreamingReadRpc { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace cloud } // namespace google -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_ASYNC_STREAMING_READ_RPC_TRACING_H diff --git a/google/cloud/internal/async_streaming_read_rpc_tracing_test.cc b/google/cloud/internal/async_streaming_read_rpc_tracing_test.cc index 8879d4882af90..68ae289d66a68 100644 --- a/google/cloud/internal/async_streaming_read_rpc_tracing_test.cc +++ b/google/cloud/internal/async_streaming_read_rpc_tracing_test.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include "google/cloud/internal/async_streaming_read_rpc_tracing.h" #include "google/cloud/internal/make_status.h" #include "google/cloud/internal/opentelemetry.h" @@ -265,5 +264,4 @@ TEST(AsyncStreamingReadRpcTracing, StartedStreamShouldExtractMetadata) { } // namespace internal GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace cloud -} // namespace google -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY +} // namespace google \ No newline at end of file diff --git a/google/cloud/internal/async_streaming_write_rpc_impl_test.cc b/google/cloud/internal/async_streaming_write_rpc_impl_test.cc index 235a2939c22b9..b065dec84d8bf 100644 --- a/google/cloud/internal/async_streaming_write_rpc_impl_test.cc +++ b/google/cloud/internal/async_streaming_write_rpc_impl_test.cc @@ -184,8 +184,6 @@ TEST(AsyncStreamingWriteRpcTest, Error) { stream.Finish().get().status()); } -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - using ::google::cloud::testing_util::IsActive; TEST(AsyncStreamingWriteRpcTest, SpanActiveAcrossAsyncGrpcOperations) { @@ -287,8 +285,6 @@ TEST(AsyncStreamingWriteRpcTest, SpanActiveAcrossAsyncGrpcOperations) { (void)finish.get(); } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - } // namespace } // namespace internal GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/internal/async_streaming_write_rpc_tracing.h b/google/cloud/internal/async_streaming_write_rpc_tracing.h index e962f7ac95c41..de64ccc9306e0 100644 --- a/google/cloud/internal/async_streaming_write_rpc_tracing.h +++ b/google/cloud/internal/async_streaming_write_rpc_tracing.h @@ -15,7 +15,6 @@ #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_ASYNC_STREAMING_WRITE_RPC_TRACING_H #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_ASYNC_STREAMING_WRITE_RPC_TRACING_H -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include "google/cloud/internal/async_streaming_write_rpc.h" #include "google/cloud/internal/grpc_opentelemetry.h" #include "google/cloud/version.h" @@ -122,6 +121,5 @@ class AsyncStreamingWriteRpcTracing GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace cloud } // namespace google -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_ASYNC_STREAMING_WRITE_RPC_TRACING_H diff --git a/google/cloud/internal/async_streaming_write_rpc_tracing_test.cc b/google/cloud/internal/async_streaming_write_rpc_tracing_test.cc index f7906db2982c5..960c0affac56c 100644 --- a/google/cloud/internal/async_streaming_write_rpc_tracing_test.cc +++ b/google/cloud/internal/async_streaming_write_rpc_tracing_test.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include "google/cloud/internal/async_streaming_write_rpc_tracing.h" #include "google/cloud/internal/make_status.h" #include "google/cloud/internal/opentelemetry.h" @@ -293,4 +292,3 @@ TEST(AsyncStreamingWriteRpcTracing, StartedStreamShouldExtractMetadata) { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace cloud } // namespace google -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY diff --git a/google/cloud/internal/call_context.h b/google/cloud/internal/call_context.h index eb6575f0aab47..0134614de518e 100644 --- a/google/cloud/internal/call_context.h +++ b/google/cloud/internal/call_context.h @@ -18,11 +18,9 @@ #include "google/cloud/internal/opentelemetry_context.h" #include "google/cloud/options.h" #include "google/cloud/version.h" -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include #include #include -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include #include @@ -44,9 +42,7 @@ struct CallContext { CallContext() : CallContext(SaveCurrentOptions()) {} ImmutableOptions options; -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY OTelContext otel_context = CurrentOTelContext(); -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY }; /** @@ -58,13 +54,10 @@ class ScopedCallContext { public: explicit ScopedCallContext(CallContext call_context) : options_span_(std::move(call_context.options)) -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY // clang-format off , scoped_otel_context_(std::move(call_context.otel_context)) // clang-format on -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - { - } + {} // `ScopedCallContext` should not be copied/moved. ScopedCallContext(ScopedCallContext const&) = delete; @@ -78,9 +71,7 @@ class ScopedCallContext { private: OptionsSpan options_span_; -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY ScopedOTelContext scoped_otel_context_; -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY }; } // namespace internal diff --git a/google/cloud/internal/call_context_test.cc b/google/cloud/internal/call_context_test.cc index 79e1c2c2c74fb..d05231e8ce817 100644 --- a/google/cloud/internal/call_context_test.cc +++ b/google/cloud/internal/call_context_test.cc @@ -44,7 +44,6 @@ TEST(CallContext, Options) { EXPECT_FALSE(CallContext().options->has()); } -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY using ::testing::ElementsAre; using ::testing::IsEmpty; @@ -67,8 +66,6 @@ TEST(CallContext, OTel) { EXPECT_THAT(CallContext().otel_context, IsEmpty()); } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - } // namespace } // namespace internal GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/internal/grpc_opentelemetry.cc b/google/cloud/internal/grpc_opentelemetry.cc index 127e71dbf5317..ab05520280fee 100644 --- a/google/cloud/internal/grpc_opentelemetry.cc +++ b/google/cloud/internal/grpc_opentelemetry.cc @@ -22,22 +22,18 @@ #include "google/cloud/options.h" #include "absl/strings/match.h" #include -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include #include #include #include #include #include -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY namespace google { namespace cloud { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN namespace internal { -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - namespace { /** @@ -166,7 +162,6 @@ future EndSpan( return EndSpan(*s, std::move(t)); }); } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY } // namespace internal GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/internal/grpc_opentelemetry.h b/google/cloud/internal/grpc_opentelemetry.h index 500e3c67c363f..9ea8bc86a80e2 100644 --- a/google/cloud/internal/grpc_opentelemetry.h +++ b/google/cloud/internal/grpc_opentelemetry.h @@ -22,10 +22,8 @@ #include "google/cloud/options.h" #include "google/cloud/version.h" #include -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include #include -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include #include @@ -34,8 +32,6 @@ namespace cloud { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN namespace internal { -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - /** * Make a span, setting attributes related to gRPC. * @@ -112,8 +108,6 @@ future> EndSpan( }); } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - /** * Returns a traced timer, if OpenTelemetry tracing is enabled. */ @@ -121,14 +115,12 @@ template future> TracedAsyncBackoff( CompletionQueue& cq, Options const& options, std::chrono::duration duration, std::string const& name) { -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY if (TracingEnabled(options)) { auto span = MakeSpan(name); OTelScope scope(span); auto timer = cq.MakeRelativeTimer(duration); return EndSpan(std::move(span), std::move(timer)); } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY (void)options; (void)name; return cq.MakeRelativeTimer(duration); diff --git a/google/cloud/internal/grpc_opentelemetry_test.cc b/google/cloud/internal/grpc_opentelemetry_test.cc index b6484f2f504c3..ee3e44462cb2a 100644 --- a/google/cloud/internal/grpc_opentelemetry_test.cc +++ b/google/cloud/internal/grpc_opentelemetry_test.cc @@ -22,11 +22,9 @@ #include "google/cloud/testing_util/validate_propagator.h" #include #include -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include #include #include -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY namespace google { namespace cloud { @@ -37,7 +35,6 @@ namespace { using ::testing::ByMove; using ::testing::Return; -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY using ::google::cloud::testing_util::DisableTracing; using ::google::cloud::testing_util::EnableTracing; using ::google::cloud::testing_util::InstallSpanCatcher; @@ -336,8 +333,6 @@ TEST(NoOpenTelemetry, TracedAsyncBackoff) { EXPECT_STATUS_OK(f.get()); } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - } // namespace } // namespace internal GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/internal/minimal_iam_credentials_stub.cc b/google/cloud/internal/minimal_iam_credentials_stub.cc index f9b67b4c17f22..265e2711eda9b 100644 --- a/google/cloud/internal/minimal_iam_credentials_stub.cc +++ b/google/cloud/internal/minimal_iam_credentials_stub.cc @@ -161,7 +161,6 @@ class AsyncAccessTokenGeneratorLogging : public MinimalIamCredentialsStub { TracingOptions tracing_options_; }; -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY class AsyncAccessTokenGeneratorTracing : public MinimalIamCredentialsStub { public: explicit AsyncAccessTokenGeneratorTracing( @@ -197,8 +196,6 @@ class AsyncAccessTokenGeneratorTracing : public MinimalIamCredentialsStub { std::shared_ptr propagator_; }; -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - } // namespace std::shared_ptr DecorateMinimalIamCredentialsStub( @@ -209,11 +206,9 @@ std::shared_ptr DecorateMinimalIamCredentialsStub( impl = std::make_shared( std::move(impl), options.get()); } -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY if (TracingEnabled(options)) { impl = std::make_shared(std::move(impl)); } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY return impl; } diff --git a/google/cloud/internal/minimal_iam_credentials_stub_test.cc b/google/cloud/internal/minimal_iam_credentials_stub_test.cc index a5363beef6386..1cd3cab0c1638 100644 --- a/google/cloud/internal/minimal_iam_credentials_stub_test.cc +++ b/google/cloud/internal/minimal_iam_credentials_stub_test.cc @@ -219,7 +219,6 @@ TEST_F(MinimalIamCredentialsStubTest, LoggingComponentNames) { } } -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY using ::google::cloud::testing_util::DisableTracing; using ::google::cloud::testing_util::EnableTracing; using ::google::cloud::testing_util::OTelAttribute; @@ -342,7 +341,6 @@ TEST_F(MinimalIamCredentialsStubTest, SignBlobTracing) { OTelAttribute("grpc.peer", _), OTelAttribute("gl-cpp.status_code", kErrorCode))))); } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY TEST(MakeMinimalIamCredentialsOptions, Default) { auto o = MakeMinimalIamCredentialsOptions( diff --git a/google/cloud/internal/opentelemetry.cc b/google/cloud/internal/opentelemetry.cc index fc21f52abae06..04b0593c1fccc 100644 --- a/google/cloud/internal/opentelemetry.cc +++ b/google/cloud/internal/opentelemetry.cc @@ -15,21 +15,17 @@ #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/opentelemetry_options.h" #include "google/cloud/options.h" -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include #include #include #include #include -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY namespace google { namespace cloud { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN namespace internal { -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - opentelemetry::nostd::shared_ptr GetTracer( Options const&) { auto provider = opentelemetry::trace::Provider::GetTracerProvider(); @@ -147,26 +143,16 @@ std::string CurrentThreadId() { return std::move(os).str(); } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY bool TracingEnabled(Options const& options) { return options.get(); } -#else -bool TracingEnabled(Options const&) { return false; } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY void AddSpanAttribute(Options const& options, std::string const& key, std::string const& value) { if (!TracingEnabled(options)) return; auto span = opentelemetry::trace::Tracer::GetCurrentSpan(); span->SetAttribute(key, value); } -#else -void AddSpanAttribute(Options const&, std::string const&, std::string const&) {} -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY } // namespace internal GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/internal/opentelemetry.h b/google/cloud/internal/opentelemetry.h index 375da5125e7bd..4a830fb8a850a 100644 --- a/google/cloud/internal/opentelemetry.h +++ b/google/cloud/internal/opentelemetry.h @@ -21,25 +21,21 @@ #include "google/cloud/status.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include #include #include #include #include #include -#include -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include #include +#include namespace google { namespace cloud { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN namespace internal { -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - /** * Returns a [tracer] to use for creating [spans]. * @@ -234,7 +230,39 @@ std::string ToString(opentelemetry::trace::SpanId const& span_id); /// Gets the current thread id. std::string CurrentThreadId(); -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY +bool TracingEnabled(Options const& options); + +/// Wraps the sleeper in a span, if tracing is enabled. +template +std::function)> MakeTracedSleeper( + Options const& options, + std::function)> sleeper, + std::string const& name) { + if (TracingEnabled(options)) { + return [name, sleeper = std::move(sleeper)]( + std::chrono::duration d) { + // A sleep of 0 is not an interesting event worth tracing. + if (d == std::chrono::duration::zero()) return sleeper(d); + auto span = MakeSpan(name); + sleeper(d); + span->End(); + }; + } + (void)options; + (void)name; + return sleeper; +} + +/// Adds an attribute to the active span, if tracing is enabled. +void AddSpanAttribute(Options const& options, std::string const& key, + std::string const& value); + +} // namespace internal +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_OPENTELEMETRY_H bool TracingEnabled(Options const& options); @@ -244,7 +272,6 @@ std::function)> MakeTracedSleeper( Options const& options, std::function)> sleeper, std::string const& name) { -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY if (TracingEnabled(options)) { return [name, sleeper = std::move(sleeper)]( std::chrono::duration d) { @@ -255,7 +282,6 @@ std::function)> MakeTracedSleeper( span->End(); }; } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY (void)options; (void)name; return sleeper; diff --git a/google/cloud/internal/opentelemetry_context.cc b/google/cloud/internal/opentelemetry_context.cc index 9afda7f15cec9..44f15067b78d1 100644 --- a/google/cloud/internal/opentelemetry_context.cc +++ b/google/cloud/internal/opentelemetry_context.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include "google/cloud/internal/opentelemetry_context.h" #include @@ -76,4 +75,3 @@ OTelScope::~OTelScope() { DetachOTelContext(context_); } GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace cloud } // namespace google -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY diff --git a/google/cloud/internal/opentelemetry_context.h b/google/cloud/internal/opentelemetry_context.h index 124715826ed8f..c821a63fc18a9 100644 --- a/google/cloud/internal/opentelemetry_context.h +++ b/google/cloud/internal/opentelemetry_context.h @@ -15,7 +15,6 @@ #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_OPENTELEMETRY_CONTEXT_H #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_OPENTELEMETRY_CONTEXT_H -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include "google/cloud/version.h" #include #include @@ -125,6 +124,5 @@ class ScopedOTelContext { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace cloud } // namespace google -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_OPENTELEMETRY_CONTEXT_H diff --git a/google/cloud/internal/opentelemetry_context_test.cc b/google/cloud/internal/opentelemetry_context_test.cc index 06c3a206fe541..dea9890cba137 100644 --- a/google/cloud/internal/opentelemetry_context_test.cc +++ b/google/cloud/internal/opentelemetry_context_test.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include "google/cloud/internal/opentelemetry_context.h" #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/testing_util/opentelemetry_matchers.h" @@ -177,4 +176,3 @@ TEST_F(OTelContextTest, ThreadLocalStorage) { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace cloud } // namespace google -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY diff --git a/google/cloud/internal/opentelemetry_test.cc b/google/cloud/internal/opentelemetry_test.cc index 0de694de1df4c..96358259d1712 100644 --- a/google/cloud/internal/opentelemetry_test.cc +++ b/google/cloud/internal/opentelemetry_test.cc @@ -18,10 +18,8 @@ #include "google/cloud/testing_util/opentelemetry_matchers.h" #include "google/cloud/testing_util/status_matchers.h" #include -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include #include -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY namespace google { namespace cloud { @@ -32,7 +30,6 @@ namespace { using ms = std::chrono::milliseconds; using ::testing::MockFunction; -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY using ::google::cloud::testing_util::DisableTracing; using ::google::cloud::testing_util::EnableTracing; using ::google::cloud::testing_util::InstallSpanCatcher; @@ -447,23 +444,6 @@ TEST(OpenTelemetry, AddSpanAttributeDisabled) { Not(SpanHasAttributes(OTelAttribute("key", "value")))))); } -#else - -TEST(NoOpenTelemetry, TracingEnabled) { - EXPECT_FALSE(TracingEnabled(Options{})); -} - -TEST(NoOpenTelemetry, MakeTracedSleeper) { - MockFunction mock_sleeper; - EXPECT_CALL(mock_sleeper, Call(ms(42))); - - auto sleeper = mock_sleeper.AsStdFunction(); - auto result = MakeTracedSleeper(Options{}, sleeper, "Backoff"); - result(ms(42)); -} - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - } // namespace } // namespace internal GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/internal/rest_carrier.cc b/google/cloud/internal/rest_carrier.cc index 7b700fe20db3a..719b966c3a50f 100644 --- a/google/cloud/internal/rest_carrier.cc +++ b/google/cloud/internal/rest_carrier.cc @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #include "google/cloud/internal/rest_carrier.h" #include "google/cloud/internal/noexcept_action.h" #include "google/cloud/internal/rest_context.h" @@ -44,5 +42,3 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace rest_internal } // namespace cloud } // namespace google - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY diff --git a/google/cloud/internal/rest_carrier.h b/google/cloud/internal/rest_carrier.h index f201ee35960c3..a36e721ac3e94 100644 --- a/google/cloud/internal/rest_carrier.h +++ b/google/cloud/internal/rest_carrier.h @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_REST_CARRIER_H #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_REST_CARRIER_H @@ -53,5 +51,3 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace google #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_REST_CARRIER_H - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY diff --git a/google/cloud/internal/rest_carrier_test.cc b/google/cloud/internal/rest_carrier_test.cc index b059cbe6f7027..62661b8402e4b 100644 --- a/google/cloud/internal/rest_carrier_test.cc +++ b/google/cloud/internal/rest_carrier_test.cc @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #include "google/cloud/internal/rest_carrier.h" #include @@ -42,5 +40,3 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace rest_internal } // namespace cloud } // namespace google - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY diff --git a/google/cloud/internal/rest_opentelemetry.cc b/google/cloud/internal/rest_opentelemetry.cc index 9df10a71c2837..b06ba040589ab 100644 --- a/google/cloud/internal/rest_opentelemetry.cc +++ b/google/cloud/internal/rest_opentelemetry.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include "google/cloud/internal/rest_opentelemetry.h" #include "google/cloud/internal/absl_str_cat_quiet.h" #include "google/cloud/internal/opentelemetry.h" @@ -100,5 +99,3 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace rest_internal } // namespace cloud } // namespace google - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY diff --git a/google/cloud/internal/rest_opentelemetry.h b/google/cloud/internal/rest_opentelemetry.h index 825e70b602701..16c5e74c71991 100644 --- a/google/cloud/internal/rest_opentelemetry.h +++ b/google/cloud/internal/rest_opentelemetry.h @@ -15,7 +15,6 @@ #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_REST_OPENTELEMETRY_H #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_REST_OPENTELEMETRY_H -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include "google/cloud/internal/rest_request.h" #include "google/cloud/internal/trace_propagator.h" #include "google/cloud/options.h" @@ -61,6 +60,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace cloud } // namespace google -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_REST_OPENTELEMETRY_H diff --git a/google/cloud/internal/rest_opentelemetry_test.cc b/google/cloud/internal/rest_opentelemetry_test.cc index 23228a6461cb2..672e60ab86f03 100644 --- a/google/cloud/internal/rest_opentelemetry_test.cc +++ b/google/cloud/internal/rest_opentelemetry_test.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include "google/cloud/internal/rest_opentelemetry.h" #include "google/cloud/testing_util/opentelemetry_matchers.h" #include "google/cloud/testing_util/status_matchers.h" @@ -101,5 +100,3 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace rest_internal } // namespace cloud } // namespace google - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY diff --git a/google/cloud/internal/rest_retry_loop_test.cc b/google/cloud/internal/rest_retry_loop_test.cc index 79e17cc8dc648..2d98af733e4ee 100644 --- a/google/cloud/internal/rest_retry_loop_test.cc +++ b/google/cloud/internal/rest_retry_loop_test.cc @@ -235,7 +235,6 @@ TEST(RestRetryLoopTest, ExhaustedOnStart) { EXPECT_THAT(metadata, Contains(Pair("gcloud-cpp.retry.function", __func__))); } -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY using ::google::cloud::testing_util::DisableTracing; using ::google::cloud::testing_util::EnableTracing; using ::google::cloud::testing_util::SpanNamed; @@ -272,8 +271,6 @@ TEST(RestRetryLoopTest, TracingDisabled) { EXPECT_THAT(spans, IsEmpty()); } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - } // namespace GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace rest_internal diff --git a/google/cloud/internal/retry_loop_test.cc b/google/cloud/internal/retry_loop_test.cc index 2040bbd5a4fc8..e85341d4f4c1a 100644 --- a/google/cloud/internal/retry_loop_test.cc +++ b/google/cloud/internal/retry_loop_test.cc @@ -276,7 +276,6 @@ TEST(RetryLoopTest, ConfigureContext) { /*request=*/0, "error message"); } -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY using ::google::cloud::testing_util::DisableTracing; using ::google::cloud::testing_util::EnableTracing; using ::google::cloud::testing_util::SpanNamed; @@ -313,8 +312,6 @@ TEST(RetryLoopTest, TracingDisabled) { EXPECT_THAT(spans, IsEmpty()); } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - } // namespace } // namespace internal GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/internal/streaming_read_rpc_tracing.h b/google/cloud/internal/streaming_read_rpc_tracing.h index 36125b12051c7..71c885920fd71 100644 --- a/google/cloud/internal/streaming_read_rpc_tracing.h +++ b/google/cloud/internal/streaming_read_rpc_tracing.h @@ -15,7 +15,6 @@ #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_STREAMING_READ_RPC_TRACING_H #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_STREAMING_READ_RPC_TRACING_H -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include "google/cloud/internal/grpc_opentelemetry.h" #include "google/cloud/internal/grpc_request_metadata.h" #include "google/cloud/internal/opentelemetry.h" @@ -77,6 +76,5 @@ class StreamingReadRpcTracing : public StreamingReadRpc { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace cloud } // namespace google -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_STREAMING_READ_RPC_TRACING_H diff --git a/google/cloud/internal/streaming_read_rpc_tracing_test.cc b/google/cloud/internal/streaming_read_rpc_tracing_test.cc index b7f276d42c48b..7f7083adef5ac 100644 --- a/google/cloud/internal/streaming_read_rpc_tracing_test.cc +++ b/google/cloud/internal/streaming_read_rpc_tracing_test.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include "google/cloud/internal/streaming_read_rpc_tracing.h" #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/testing_util/opentelemetry_matchers.h" @@ -165,4 +164,3 @@ TEST(StreamingReadRpcTracingTest, SpanEndsOnDestruction) { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace cloud } // namespace google -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY diff --git a/google/cloud/internal/streaming_write_rpc_tracing.h b/google/cloud/internal/streaming_write_rpc_tracing.h index 695efa7e65620..dc0624e17f77b 100644 --- a/google/cloud/internal/streaming_write_rpc_tracing.h +++ b/google/cloud/internal/streaming_write_rpc_tracing.h @@ -15,7 +15,6 @@ #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_STREAMING_WRITE_RPC_TRACING_H #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_STREAMING_WRITE_RPC_TRACING_H -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include "google/cloud/internal/grpc_opentelemetry.h" #include "google/cloud/internal/grpc_request_metadata.h" #include "google/cloud/internal/opentelemetry.h" @@ -82,6 +81,5 @@ class StreamingWriteRpcTracing GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace cloud } // namespace google -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_STREAMING_WRITE_RPC_TRACING_H diff --git a/google/cloud/internal/streaming_write_rpc_tracing_test.cc b/google/cloud/internal/streaming_write_rpc_tracing_test.cc index d2d37ae363fb4..29dd467b59df7 100644 --- a/google/cloud/internal/streaming_write_rpc_tracing_test.cc +++ b/google/cloud/internal/streaming_write_rpc_tracing_test.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include "google/cloud/internal/streaming_write_rpc_tracing.h" #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/testing_util/opentelemetry_matchers.h" @@ -180,4 +179,3 @@ TEST(StreamingWriteRpcTracingTest, SpanEndsOnDestruction) { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace cloud } // namespace google -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY diff --git a/google/cloud/internal/trace_propagator.cc b/google/cloud/internal/trace_propagator.cc index 8e46cacc2cce9..eafb51a8ef0a3 100644 --- a/google/cloud/internal/trace_propagator.cc +++ b/google/cloud/internal/trace_propagator.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include "google/cloud/internal/trace_propagator.h" #include "google/cloud/internal/absl_str_cat_quiet.h" #include "absl/strings/numbers.h" @@ -103,6 +102,4 @@ MakePropagator() { } // namespace internal GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace cloud -} // namespace google - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY +} // namespace google \ No newline at end of file diff --git a/google/cloud/internal/trace_propagator.h b/google/cloud/internal/trace_propagator.h index 7a70844e83c85..47accb5ec8820 100644 --- a/google/cloud/internal/trace_propagator.h +++ b/google/cloud/internal/trace_propagator.h @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_TRACE_PROPAGATOR_H #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_TRACE_PROPAGATOR_H @@ -50,5 +48,3 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace google #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_TRACE_PROPAGATOR_H - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY diff --git a/google/cloud/internal/trace_propagator_test.cc b/google/cloud/internal/trace_propagator_test.cc index 66e4fba1b3c26..66ee089f2809e 100644 --- a/google/cloud/internal/trace_propagator_test.cc +++ b/google/cloud/internal/trace_propagator_test.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include "google/cloud/internal/trace_propagator.h" #include #include @@ -113,5 +112,4 @@ TEST(CloudTraceContextPropagator, Fields) { } // namespace internal GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace cloud -} // namespace google -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY +} // namespace google \ No newline at end of file diff --git a/google/cloud/internal/traced_stream_range.h b/google/cloud/internal/traced_stream_range.h index e31106e6b6bfc..8342febf24c72 100644 --- a/google/cloud/internal/traced_stream_range.h +++ b/google/cloud/internal/traced_stream_range.h @@ -15,7 +15,6 @@ #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_TRACED_STREAM_RANGE_H #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_TRACED_STREAM_RANGE_H -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/stream_range.h" #include @@ -81,6 +80,5 @@ StreamRange MakeTracedStreamRange( GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace cloud } // namespace google -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_TRACED_STREAM_RANGE_H diff --git a/google/cloud/internal/traced_stream_range_test.cc b/google/cloud/internal/traced_stream_range_test.cc index aef5efd6e5404..a00e253b563a9 100644 --- a/google/cloud/internal/traced_stream_range_test.cc +++ b/google/cloud/internal/traced_stream_range_test.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include "google/cloud/internal/traced_stream_range.h" #include "google/cloud/mocks/mock_stream_range.h" #include "google/cloud/internal/make_status.h" @@ -128,5 +127,4 @@ TEST(TracedStreamRange, SpanInactiveWhileIterating) { } // namespace internal GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace cloud -} // namespace google -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY +} // namespace google \ No newline at end of file diff --git a/google/cloud/internal/tracing_http_payload.cc b/google/cloud/internal/tracing_http_payload.cc index 6f79d864c34b3..b05219f500fd6 100644 --- a/google/cloud/internal/tracing_http_payload.cc +++ b/google/cloud/internal/tracing_http_payload.cc @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #include "google/cloud/internal/tracing_http_payload.h" #include "google/cloud/internal/opentelemetry.h" #include @@ -66,5 +64,3 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace rest_internal } // namespace cloud } // namespace google - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY diff --git a/google/cloud/internal/tracing_http_payload.h b/google/cloud/internal/tracing_http_payload.h index 26af6771ae58b..0b8939ff0ff6c 100644 --- a/google/cloud/internal/tracing_http_payload.h +++ b/google/cloud/internal/tracing_http_payload.h @@ -15,8 +15,6 @@ #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_TRACING_HTTP_PAYLOAD_H #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_TRACING_HTTP_PAYLOAD_H -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #include "google/cloud/internal/http_payload.h" #include #include @@ -48,6 +46,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace cloud } // namespace google -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_TRACING_HTTP_PAYLOAD_H diff --git a/google/cloud/internal/tracing_http_payload_test.cc b/google/cloud/internal/tracing_http_payload_test.cc index 7a309a55c0d66..24c6ad4dbc607 100644 --- a/google/cloud/internal/tracing_http_payload_test.cc +++ b/google/cloud/internal/tracing_http_payload_test.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include "google/cloud/internal/tracing_http_payload.h" #include "google/cloud/internal/rest_opentelemetry.h" #include "google/cloud/testing_util/mock_http_payload.h" @@ -130,5 +129,3 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace rest_internal } // namespace cloud } // namespace google - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY diff --git a/google/cloud/internal/tracing_rest_client.cc b/google/cloud/internal/tracing_rest_client.cc index 0badc6ffeb709..2443282292aee 100644 --- a/google/cloud/internal/tracing_rest_client.cc +++ b/google/cloud/internal/tracing_rest_client.cc @@ -13,7 +13,6 @@ // limitations under the License. #include "google/cloud/internal/tracing_rest_client.h" -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include "google/cloud/internal/absl_str_cat_quiet.h" #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/internal/rest_opentelemetry.h" @@ -247,6 +246,4 @@ std::unique_ptr MakeTracingRestClient( GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace rest_internal } // namespace cloud -} // namespace google - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY +} // namespace google \ No newline at end of file diff --git a/google/cloud/internal/tracing_rest_client_test.cc b/google/cloud/internal/tracing_rest_client_test.cc index 9a9ff8a267b57..ca4fb35e3ccc9 100644 --- a/google/cloud/internal/tracing_rest_client_test.cc +++ b/google/cloud/internal/tracing_rest_client_test.cc @@ -19,11 +19,9 @@ #include "google/cloud/testing_util/opentelemetry_matchers.h" #include "google/cloud/testing_util/status_matchers.h" #include -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include #include #include -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY namespace google { namespace cloud { @@ -48,7 +46,6 @@ std::string MockContents() { return "The quick brown fox jumps over the lazy dog"; } -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY using ::google::cloud::testing_util::EventNamed; using ::google::cloud::testing_util::InstallSpanCatcher; using ::google::cloud::testing_util::OTelAttribute; @@ -391,8 +388,6 @@ TEST(TracingRestClient, NoOpenTelemetry) { EXPECT_THAT(contents, IsOkAndHolds(MockContents())); } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - } // namespace GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace rest_internal diff --git a/google/cloud/internal/tracing_rest_response.cc b/google/cloud/internal/tracing_rest_response.cc index 9e00d853cecd5..f1d15cc326694 100644 --- a/google/cloud/internal/tracing_rest_response.cc +++ b/google/cloud/internal/tracing_rest_response.cc @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #include "google/cloud/internal/tracing_rest_response.h" #include "google/cloud/internal/tracing_http_payload.h" @@ -40,5 +38,3 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace rest_internal } // namespace cloud } // namespace google - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY diff --git a/google/cloud/internal/tracing_rest_response.h b/google/cloud/internal/tracing_rest_response.h index 21f2bd7d9d5ff..177b23e8ce072 100644 --- a/google/cloud/internal/tracing_rest_response.h +++ b/google/cloud/internal/tracing_rest_response.h @@ -15,8 +15,6 @@ #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_TRACING_REST_RESPONSE_H #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_TRACING_REST_RESPONSE_H -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #include "google/cloud/internal/rest_response.h" #include #include @@ -49,6 +47,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace cloud } // namespace google -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_TRACING_REST_RESPONSE_H diff --git a/google/cloud/internal/tracing_rest_response_test.cc b/google/cloud/internal/tracing_rest_response_test.cc index f95f4b6280938..b2151ee63c732 100644 --- a/google/cloud/internal/tracing_rest_response_test.cc +++ b/google/cloud/internal/tracing_rest_response_test.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include "google/cloud/internal/tracing_rest_response.h" #include "google/cloud/internal/rest_opentelemetry.h" #include "google/cloud/testing_util/mock_http_payload.h" @@ -99,5 +98,3 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace rest_internal } // namespace cloud } // namespace google - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY diff --git a/google/cloud/opentelemetry/integration_tests/configure_basic_tracing_integration_test.cc b/google/cloud/opentelemetry/integration_tests/configure_basic_tracing_integration_test.cc index ba8a8e9e8167e..4f88217c7c56f 100644 --- a/google/cloud/opentelemetry/integration_tests/configure_basic_tracing_integration_test.cc +++ b/google/cloud/opentelemetry/integration_tests/configure_basic_tracing_integration_test.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include "google/cloud/opentelemetry/configure_basic_tracing.h" #include "google/cloud/trace/v1/trace_client.h" #include "google/cloud/internal/getenv.h" @@ -159,5 +158,4 @@ TEST(ConfigureBasicTracing, RestoresPrevious) { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace otel } // namespace cloud -} // namespace google -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY +} // namespace google \ No newline at end of file diff --git a/google/cloud/opentelemetry/internal/resource_detector_impl_test.cc b/google/cloud/opentelemetry/internal/resource_detector_impl_test.cc index 6ef69ba3b3513..d30e444c1d1a2 100644 --- a/google/cloud/opentelemetry/internal/resource_detector_impl_test.cc +++ b/google/cloud/opentelemetry/internal/resource_detector_impl_test.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include "google/cloud/opentelemetry/internal/resource_detector_impl.h" #include "google/cloud/internal/absl_str_cat_quiet.h" #include "google/cloud/internal/compute_engine_util.h" @@ -518,4 +517,3 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace otel } // namespace cloud } // namespace google -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY diff --git a/google/cloud/opentelemetry/trace_exporter_test.cc b/google/cloud/opentelemetry/trace_exporter_test.cc index 08802fb19f0f8..bc8cdf8695227 100644 --- a/google/cloud/opentelemetry/trace_exporter_test.cc +++ b/google/cloud/opentelemetry/trace_exporter_test.cc @@ -116,7 +116,6 @@ TEST(TraceExporter, LogsOnError) { HasSubstr("UNAVAILABLE"), HasSubstr("try again later")))); } -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY using ::google::cloud::testing_util::InstallSpanCatcher; using ::google::cloud::testing_util::ScopedEnvironment; using ::testing::IsEmpty; @@ -140,7 +139,6 @@ TEST(TraceExporter, NoInfiniteExportLoop14611) { // Verify that no spans were created. EXPECT_THAT(span_catcher->GetSpans(), IsEmpty()); } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY } // namespace GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/pubsub/integration_tests/blocking_publisher_integration_test.cc b/google/cloud/pubsub/integration_tests/blocking_publisher_integration_test.cc index 8b35712edec5b..06678b5541c6a 100644 --- a/google/cloud/pubsub/integration_tests/blocking_publisher_integration_test.cc +++ b/google/cloud/pubsub/integration_tests/blocking_publisher_integration_test.cc @@ -71,7 +71,7 @@ TEST_F(BlockingPublisherIntegrationTest, Basic) { ASSERT_STATUS_OK(publish); } -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY + using ::google::cloud::testing_util::DisableTracing; using ::google::cloud::testing_util::EnableTracing; @@ -90,7 +90,6 @@ TEST_F(BlockingPublisherIntegrationTest, TracingDisabled) { publisher.Publish(topic_, MessageBuilder().SetData("test data").Build()); ASSERT_STATUS_OK(publish); } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY } // namespace GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/pubsub/internal/batching_publisher_tracing_connection.cc b/google/cloud/pubsub/internal/batching_publisher_tracing_connection.cc index f9631e9d25a9f..eb2f14eb39ba3 100644 --- a/google/cloud/pubsub/internal/batching_publisher_tracing_connection.cc +++ b/google/cloud/pubsub/internal/batching_publisher_tracing_connection.cc @@ -15,16 +15,13 @@ #include "google/cloud/pubsub/internal/batching_publisher_tracing_connection.h" #include "google/cloud/pubsub/publisher_connection.h" #include "google/cloud/internal/opentelemetry.h" -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY namespace google { namespace cloud { namespace pubsub_internal { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY namespace { class BatchingPublisherTracingConnection : public pubsub::PublisherConnection { @@ -73,16 +70,6 @@ MakeBatchingPublisherTracingConnection( std::move(connection)); } -#else // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - -std::shared_ptr -MakeBatchingPublisherTracingConnection( - std::shared_ptr connection) { - return connection; -} - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsub_internal } // namespace cloud diff --git a/google/cloud/pubsub/internal/blocking_publisher_tracing_connection.cc b/google/cloud/pubsub/internal/blocking_publisher_tracing_connection.cc index ec8b244947b42..ef3e98e115654 100644 --- a/google/cloud/pubsub/internal/blocking_publisher_tracing_connection.cc +++ b/google/cloud/pubsub/internal/blocking_publisher_tracing_connection.cc @@ -13,7 +13,6 @@ // limitations under the License. #include "google/cloud/pubsub/internal/blocking_publisher_tracing_connection.h" -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include "google/cloud/pubsub/message.h" #include "google/cloud/pubsub/topic.h" #include "google/cloud/internal/opentelemetry.h" @@ -23,14 +22,12 @@ #include #include #include -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY namespace google { namespace cloud { namespace pubsub_internal { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY namespace { opentelemetry::nostd::shared_ptr StartPublishSpan( @@ -95,16 +92,6 @@ MakeBlockingPublisherTracingConnection( std::move(connection)); } -#else // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - -std::shared_ptr -MakeBlockingPublisherTracingConnection( - std::shared_ptr connection) { - return connection; -} - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsub_internal } // namespace cloud diff --git a/google/cloud/pubsub/internal/blocking_publisher_tracing_connection_test.cc b/google/cloud/pubsub/internal/blocking_publisher_tracing_connection_test.cc index a370c713600c4..62eafd27b7528 100644 --- a/google/cloud/pubsub/internal/blocking_publisher_tracing_connection_test.cc +++ b/google/cloud/pubsub/internal/blocking_publisher_tracing_connection_test.cc @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #include "google/cloud/pubsub/internal/blocking_publisher_tracing_connection.h" #include "google/cloud/pubsub/blocking_publisher_connection.h" #include "google/cloud/pubsub/message.h" @@ -193,5 +191,3 @@ TEST(MakeBlockingPublisherTracingConnectionTest, CreateTracingConnection) { } // namespace pubsub_internal } // namespace cloud } // namespace google - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY diff --git a/google/cloud/pubsub/internal/extend_leases_with_retry.cc b/google/cloud/pubsub/internal/extend_leases_with_retry.cc index 94d12aab022a2..0caa2dbaf47a8 100644 --- a/google/cloud/pubsub/internal/extend_leases_with_retry.cc +++ b/google/cloud/pubsub/internal/extend_leases_with_retry.cc @@ -185,8 +185,6 @@ class ExtendLeasesHandle int attempts_ = 0; }; -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - class TracingLeaseManagement : public LeaseManagement { public: TracingLeaseManagement(std::shared_ptr child, @@ -221,15 +219,6 @@ std::shared_ptr MakeTracingLeaseManagement( std::move(batch_callback)); } -#else // #ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - -std::shared_ptr MakeTracingLeaseManagement( - std::shared_ptr impl, std::shared_ptr) { - return impl; -} - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - } // namespace future ExtendLeasesWithRetry( diff --git a/google/cloud/pubsub/internal/extend_leases_with_retry_test.cc b/google/cloud/pubsub/internal/extend_leases_with_retry_test.cc index 3d06e67ee356b..d5fbd92ea69b3 100644 --- a/google/cloud/pubsub/internal/extend_leases_with_retry_test.cc +++ b/google/cloud/pubsub/internal/extend_leases_with_retry_test.cc @@ -190,8 +190,6 @@ TEST(ExtendLeasesWithRetry, FailureTooManyTransients) { EXPECT_THAT(log_lines, Contains(HasSubstr("ack_id=test-003"))); } -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - TEST(ExtendLeasesWithRetry, SuccessWithOtelEnabled) { auto mock = std::make_shared(); auto mock_cq = std::make_shared(); @@ -231,8 +229,6 @@ TEST(ExtendLeasesWithRetry, SuccessWithOtelEnabled) { EXPECT_STATUS_OK(result.get()); } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsub_internal } // namespace cloud diff --git a/google/cloud/pubsub/internal/flow_controlled_publisher_tracing_connection.cc b/google/cloud/pubsub/internal/flow_controlled_publisher_tracing_connection.cc index 93c0c73cd3f5b..c60bde49a69ad 100644 --- a/google/cloud/pubsub/internal/flow_controlled_publisher_tracing_connection.cc +++ b/google/cloud/pubsub/internal/flow_controlled_publisher_tracing_connection.cc @@ -14,19 +14,15 @@ #include "google/cloud/pubsub/internal/flow_controlled_publisher_tracing_connection.h" #include "google/cloud/pubsub/publisher_connection.h" -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include "google/cloud/internal/opentelemetry.h" #include #include -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY namespace google { namespace cloud { namespace pubsub_internal { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - namespace { class FlowControlledPublisherTracingConnection : public pubsub::PublisherConnection { @@ -75,16 +71,6 @@ MakeFlowControlledPublisherTracingConnection( std::move(connection)); } -#else // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - -std::shared_ptr -MakeFlowControlledPublisherTracingConnection( - std::shared_ptr connection) { - return connection; -} - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsub_internal } // namespace cloud diff --git a/google/cloud/pubsub/internal/flow_controlled_publisher_tracing_connection_test.cc b/google/cloud/pubsub/internal/flow_controlled_publisher_tracing_connection_test.cc index 5a29ff4f9fc74..c9c55d415c516 100644 --- a/google/cloud/pubsub/internal/flow_controlled_publisher_tracing_connection_test.cc +++ b/google/cloud/pubsub/internal/flow_controlled_publisher_tracing_connection_test.cc @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #include "google/cloud/pubsub/internal/flow_controlled_publisher_tracing_connection.h" #include "google/cloud/pubsub/mocks/mock_publisher_connection.h" #include "google/cloud/pubsub/publisher_connection.h" @@ -139,5 +137,3 @@ TEST(MakeFlowControlledPublisherTracingConnectionTest, } // namespace pubsub_internal } // namespace cloud } // namespace google - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY diff --git a/google/cloud/pubsub/internal/message_carrier.cc b/google/cloud/pubsub/internal/message_carrier.cc index 74e6e7b226231..f28eae68e89cb 100644 --- a/google/cloud/pubsub/internal/message_carrier.cc +++ b/google/cloud/pubsub/internal/message_carrier.cc @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #include "google/cloud/pubsub/internal/message_carrier.h" #include "google/cloud/pubsub/message.h" #include "google/cloud/internal/absl_str_cat_quiet.h" @@ -51,6 +49,4 @@ void MessageCarrier::Set(opentelemetry::nostd::string_view key, GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsub_internal } // namespace cloud -} // namespace google - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY +} // namespace google \ No newline at end of file diff --git a/google/cloud/pubsub/internal/message_carrier.h b/google/cloud/pubsub/internal/message_carrier.h index 9e8e9d48d4423..f48744484ad24 100644 --- a/google/cloud/pubsub/internal/message_carrier.h +++ b/google/cloud/pubsub/internal/message_carrier.h @@ -15,8 +15,6 @@ #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_PUBSUB_INTERNAL_MESSAGE_CARRIER_H #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_PUBSUB_INTERNAL_MESSAGE_CARRIER_H -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #include "google/cloud/pubsub/message.h" #include "google/cloud/version.h" #include @@ -60,6 +58,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace cloud } // namespace google -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_PUBSUB_INTERNAL_MESSAGE_CARRIER_H diff --git a/google/cloud/pubsub/internal/message_carrier_test.cc b/google/cloud/pubsub/internal/message_carrier_test.cc index 621e0f11df190..206825129a089 100644 --- a/google/cloud/pubsub/internal/message_carrier_test.cc +++ b/google/cloud/pubsub/internal/message_carrier_test.cc @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #include "google/cloud/pubsub/internal/message_carrier.h" #include "google/cloud/pubsub/message.h" #include @@ -70,6 +68,4 @@ TEST(MessageCarrierTest, GetAttributeNotFound) { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsub_internal } // namespace cloud -} // namespace google - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY +} // namespace google \ No newline at end of file diff --git a/google/cloud/pubsub/internal/message_propagator.cc b/google/cloud/pubsub/internal/message_propagator.cc index d433d8301bf28..dbfd9a242e6b2 100644 --- a/google/cloud/pubsub/internal/message_propagator.cc +++ b/google/cloud/pubsub/internal/message_propagator.cc @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #include "google/cloud/pubsub/internal/message_propagator.h" #include "google/cloud/pubsub/internal/message_carrier.h" #include "google/cloud/pubsub/message.h" @@ -44,6 +42,4 @@ opentelemetry::context::Context ExtractTraceContext( GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsub_internal } // namespace cloud -} // namespace google - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY +} // namespace google \ No newline at end of file diff --git a/google/cloud/pubsub/internal/message_propagator.h b/google/cloud/pubsub/internal/message_propagator.h index a04176c5fed0b..1bbd10c71574c 100644 --- a/google/cloud/pubsub/internal/message_propagator.h +++ b/google/cloud/pubsub/internal/message_propagator.h @@ -15,8 +15,6 @@ #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_PUBSUB_INTERNAL_MESSAGE_PROPAGATOR_H #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_PUBSUB_INTERNAL_MESSAGE_PROPAGATOR_H -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #include "google/cloud/pubsub/internal/message_carrier.h" #include "google/cloud/pubsub/message.h" #include @@ -48,6 +46,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace cloud } // namespace google -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_PUBSUB_INTERNAL_MESSAGE_PROPAGATOR_H diff --git a/google/cloud/pubsub/internal/message_propagator_test.cc b/google/cloud/pubsub/internal/message_propagator_test.cc index d948369b02a50..f9584343eb575 100644 --- a/google/cloud/pubsub/internal/message_propagator_test.cc +++ b/google/cloud/pubsub/internal/message_propagator_test.cc @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #include "google/cloud/pubsub/internal/message_propagator.h" #include "google/cloud/pubsub/internal/message_carrier.h" #include "google/cloud/pubsub/message.h" @@ -77,5 +75,3 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsub_internal } // namespace cloud } // namespace google - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY diff --git a/google/cloud/pubsub/internal/publisher_stub_factory_test.cc b/google/cloud/pubsub/internal/publisher_stub_factory_test.cc index 3619fb4da450b..3c6eb462cbba9 100644 --- a/google/cloud/pubsub/internal/publisher_stub_factory_test.cc +++ b/google/cloud/pubsub/internal/publisher_stub_factory_test.cc @@ -205,7 +205,6 @@ TEST_F(PublisherStubFactory, Logging) { EXPECT_THAT(log.ExtractLines(), Contains(HasSubstr("CreateTopic"))); } -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY using ::google::cloud::testing_util::DisableTracing; using ::google::cloud::testing_util::EnableTracing; using ::google::cloud::testing_util::SpanNamed; @@ -284,7 +283,6 @@ TEST_F(PublisherStubFactory, TracingDisabled) { EXPECT_THAT(span_catcher->GetSpans(), IsEmpty()); } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY // The following tests are for all the rpcs on the stub. TEST_F(PublisherStubFactory, CreateTopic) { diff --git a/google/cloud/pubsub/internal/publisher_tracing_connection.cc b/google/cloud/pubsub/internal/publisher_tracing_connection.cc index f1e19476d35a7..e64ecddca409f 100644 --- a/google/cloud/pubsub/internal/publisher_tracing_connection.cc +++ b/google/cloud/pubsub/internal/publisher_tracing_connection.cc @@ -13,18 +13,14 @@ // limitations under the License. #include "google/cloud/pubsub/internal/publisher_tracing_connection.h" +#include "google/cloud/pubsub/internal/message_propagator.h" #include "google/cloud/pubsub/message.h" #include "google/cloud/pubsub/publisher_connection.h" #include "google/cloud/future.h" -#include "google/cloud/status.h" -#include "google/cloud/version.h" -#include -#include -#include -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY -#include "google/cloud/pubsub/internal/message_propagator.h" #include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/status.h" #include "google/cloud/status_or.h" +#include "google/cloud/version.h" #include #include #include @@ -33,14 +29,15 @@ #include #include #include -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY +#include +#include +#include namespace google { namespace cloud { namespace pubsub_internal { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY namespace { opentelemetry::nostd::shared_ptr StartPublishSpan( @@ -132,16 +129,6 @@ std::shared_ptr MakePublisherTracingConnection( std::move(connection)); } -#else // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - -std::shared_ptr MakePublisherTracingConnection( - pubsub::Topic, // NOLINT(performance-unnecessary-value-param) - std::shared_ptr connection) { - return connection; -} - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsub_internal } // namespace cloud diff --git a/google/cloud/pubsub/internal/publisher_tracing_connection_test.cc b/google/cloud/pubsub/internal/publisher_tracing_connection_test.cc index 44b0d23cee8fe..a86ffe4313c42 100644 --- a/google/cloud/pubsub/internal/publisher_tracing_connection_test.cc +++ b/google/cloud/pubsub/internal/publisher_tracing_connection_test.cc @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #include "google/cloud/pubsub/internal/publisher_tracing_connection.h" #include "google/cloud/pubsub/message.h" #include "google/cloud/pubsub/mocks/mock_publisher_connection.h" @@ -257,5 +255,3 @@ TEST(MakePublisherTracingConnectionTest, CreateTracingConnection) { } // namespace pubsub_internal } // namespace cloud } // namespace google - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY diff --git a/google/cloud/pubsub/internal/pull_ack_handler_factory_test.cc b/google/cloud/pubsub/internal/pull_ack_handler_factory_test.cc index 1116d12b78e99..0d5aa2a3c0467 100644 --- a/google/cloud/pubsub/internal/pull_ack_handler_factory_test.cc +++ b/google/cloud/pubsub/internal/pull_ack_handler_factory_test.cc @@ -93,7 +93,6 @@ TEST(PullAckHandlerTest, AckSimple) { pending.first.set_value(false); } -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY using ::google::cloud::testing_util::DisableTracing; using ::google::cloud::testing_util::EnableTracing; using ::google::cloud::testing_util::SpanHasInstrumentationScope; @@ -177,8 +176,6 @@ TEST(PullAckHandlerTest, TracingDisabled) { EXPECT_THAT(span_catcher->GetSpans(), IsEmpty()); } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - } // namespace GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsub_internal diff --git a/google/cloud/pubsub/internal/pull_lease_manager_factory_test.cc b/google/cloud/pubsub/internal/pull_lease_manager_factory_test.cc index 49d8797c620e1..112b6cf13b088 100644 --- a/google/cloud/pubsub/internal/pull_lease_manager_factory_test.cc +++ b/google/cloud/pubsub/internal/pull_lease_manager_factory_test.cc @@ -89,7 +89,6 @@ TEST(DefaultPullLeaseManager, ExtendLeaseDeadlineSimple) { EXPECT_STATUS_OK(status.get()); } -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY using ::google::cloud::testing_util::DisableTracing; using ::google::cloud::testing_util::EnableTracing; using ::google::cloud::testing_util::SpanHasInstrumentationScope; @@ -168,8 +167,6 @@ TEST(DefaultPullLeaseManager, TracingDisabled) { EXPECT_THAT(span_catcher->GetSpans(), IsEmpty()); } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - } // namespace GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsub_internal diff --git a/google/cloud/pubsub/internal/span.h b/google/cloud/pubsub/internal/span.h index c32e925117d8c..9ff2298df6a7e 100644 --- a/google/cloud/pubsub/internal/span.h +++ b/google/cloud/pubsub/internal/span.h @@ -16,9 +16,7 @@ #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_PUBSUB_INTERNAL_SPAN_H #include "google/cloud/pubsub/version.h" -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include namespace google { @@ -28,12 +26,10 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN /** * Span class stores an OpenTelemetery span which can only be accessed by code - * compiled with GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY. + * compiled with Opentelemetry. */ struct Span { -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY opentelemetry::nostd::shared_ptr span; -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/pubsub/internal/subscriber_stub_factory_test.cc b/google/cloud/pubsub/internal/subscriber_stub_factory_test.cc index 9b0b62ca719d7..e29af3adbc8e5 100644 --- a/google/cloud/pubsub/internal/subscriber_stub_factory_test.cc +++ b/google/cloud/pubsub/internal/subscriber_stub_factory_test.cc @@ -206,7 +206,6 @@ TEST_F(SubscriberStubFactory, Logging) { EXPECT_THAT(log.ExtractLines(), Contains(HasSubstr("CreateSubscription"))); } -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY using ::google::cloud::testing_util::DisableTracing; using ::google::cloud::testing_util::EnableTracing; using ::google::cloud::testing_util::SpanNamed; @@ -286,7 +285,6 @@ TEST_F(SubscriberStubFactory, TracingDisabled) { EXPECT_THAT(span_catcher->GetSpans(), IsEmpty()); } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY } // namespace GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/pubsub/internal/subscriber_tracing_connection.cc b/google/cloud/pubsub/internal/subscriber_tracing_connection.cc index 6e3cd1380efdf..5b9e0b193ce48 100644 --- a/google/cloud/pubsub/internal/subscriber_tracing_connection.cc +++ b/google/cloud/pubsub/internal/subscriber_tracing_connection.cc @@ -17,21 +17,17 @@ #include "google/cloud/pubsub/options.h" #include "google/cloud/grpc_options.h" #include "google/cloud/internal/opentelemetry.h" -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include #include #include #include #include -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY namespace google { namespace cloud { namespace pubsub_internal { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - namespace { opentelemetry::nostd::shared_ptr StartPullSpan() { @@ -133,15 +129,6 @@ std::shared_ptr MakeSubscriberTracingConnection( return std::make_shared(std::move(connection)); } -#else // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - -std::shared_ptr MakeSubscriberTracingConnection( - std::shared_ptr connection) { - return connection; -} - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsub_internal } // namespace cloud diff --git a/google/cloud/pubsub/internal/subscriber_tracing_connection_test.cc b/google/cloud/pubsub/internal/subscriber_tracing_connection_test.cc index 5e2d5cea82fe5..ba560f9613e6f 100644 --- a/google/cloud/pubsub/internal/subscriber_tracing_connection_test.cc +++ b/google/cloud/pubsub/internal/subscriber_tracing_connection_test.cc @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #include "google/cloud/pubsub/internal/subscriber_tracing_connection.h" #include "google/cloud/pubsub/ack_handler.h" #include "google/cloud/pubsub/exactly_once_ack_handler.h" @@ -345,6 +343,4 @@ TEST(SubscriberTracingConnectionTest, options) { } // namespace } // namespace pubsub_internal } // namespace cloud -} // namespace google - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY +} // namespace google \ No newline at end of file diff --git a/google/cloud/pubsub/internal/subscription_session_test.cc b/google/cloud/pubsub/internal/subscription_session_test.cc index 2dd2d6056718c..584c95aebfb3d 100644 --- a/google/cloud/pubsub/internal/subscription_session_test.cc +++ b/google/cloud/pubsub/internal/subscription_session_test.cc @@ -28,13 +28,11 @@ #include "google/cloud/testing_util/opentelemetry_matchers.h" #include "google/cloud/testing_util/scoped_log.h" #include "google/cloud/testing_util/status_matchers.h" -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY +#include #include #include #include #include -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY -#include #include #include #include @@ -203,8 +201,6 @@ TEST(SubscriptionSessionTest, ScheduleCallbacks) { ScheduleCallbacks(/*ack_count=*/100, /*enable_open_telemetry=*/false); } -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - using ::google::cloud::testing_util::InstallSpanCatcher; using ::google::cloud::testing_util::OTelAttribute; using ::google::cloud::testing_util::SpanHasAttributes; @@ -234,8 +230,6 @@ TEST(SubscriptionSessionTest, ScheduleCallbacksWithOtelEnabled) { sc::messaging::kMessagingSystem, "gcp_pubsub"))))); } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - /// @test Verify callbacks are scheduled in the background threads. TEST(SubscriptionSessionTest, ScheduleCallbacksExactlyOnce) { auto mock = std::make_shared(); diff --git a/google/cloud/pubsub/internal/tracing_batch_callback.cc b/google/cloud/pubsub/internal/tracing_batch_callback.cc index e2c29b0c35fb1..8196fcc6fea00 100644 --- a/google/cloud/pubsub/internal/tracing_batch_callback.cc +++ b/google/cloud/pubsub/internal/tracing_batch_callback.cc @@ -17,21 +17,17 @@ #include "google/cloud/pubsub/subscription.h" #include "google/cloud/pubsub/version.h" #include "google/cloud/internal/opentelemetry.h" -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include "google/pubsub/v1/pubsub.pb.h" #include #include #include #include -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY namespace google { namespace cloud { namespace pubsub_internal { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - namespace { opentelemetry::nostd::shared_ptr StartSubscribeSpan( @@ -298,16 +294,6 @@ std::shared_ptr MakeTracingBatchCallback( subscription); } -#else // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - -std::shared_ptr MakeTracingBatchCallback( - std::shared_ptr batch_callback, - pubsub::Subscription const&) { - return batch_callback; -} - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsub_internal } // namespace cloud diff --git a/google/cloud/pubsub/internal/tracing_batch_callback_test.cc b/google/cloud/pubsub/internal/tracing_batch_callback_test.cc index 89058a02e7c56..457c6556837d3 100644 --- a/google/cloud/pubsub/internal/tracing_batch_callback_test.cc +++ b/google/cloud/pubsub/internal/tracing_batch_callback_test.cc @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #include "google/cloud/pubsub/internal/tracing_batch_callback.h" #include "google/cloud/pubsub/internal/message_propagator.h" #include "google/cloud/pubsub/message.h" @@ -523,6 +521,4 @@ TEST(TracingBatchCallback, ExpireThenNack) { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsub_internal } // namespace cloud -} // namespace google - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY +} // namespace google \ No newline at end of file diff --git a/google/cloud/pubsub/internal/tracing_batch_sink.cc b/google/cloud/pubsub/internal/tracing_batch_sink.cc index 16bb4ab75c8a7..962f628cfe7d4 100644 --- a/google/cloud/pubsub/internal/tracing_batch_sink.cc +++ b/google/cloud/pubsub/internal/tracing_batch_sink.cc @@ -13,7 +13,6 @@ // limitations under the License. #include "google/cloud/pubsub/internal/tracing_batch_sink.h" -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include "google/cloud/pubsub/internal/publisher_stub.h" #include "google/cloud/pubsub/internal/tracing_helpers.h" #include "google/cloud/pubsub/options.h" @@ -28,15 +27,12 @@ #include #include #include -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY namespace google { namespace cloud { namespace pubsub_internal { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - namespace { using Spans = std::vector>; @@ -213,15 +209,6 @@ std::shared_ptr MakeTracingBatchSink( std::move(topic), std::move(batch_sink), std::move(opts)); } -#else // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - -std::shared_ptr MakeTracingBatchSink( - pubsub::Topic, std::shared_ptr batch_sink, Options) { - return batch_sink; -} - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsub_internal } // namespace cloud diff --git a/google/cloud/pubsub/internal/tracing_batch_sink_test.cc b/google/cloud/pubsub/internal/tracing_batch_sink_test.cc index d01d6967d84d6..f7641c9cd0c3d 100644 --- a/google/cloud/pubsub/internal/tracing_batch_sink_test.cc +++ b/google/cloud/pubsub/internal/tracing_batch_sink_test.cc @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #include "google/cloud/pubsub/internal/tracing_batch_sink.h" #include "google/cloud/pubsub/message.h" #include "google/cloud/pubsub/options.h" @@ -568,5 +566,3 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsub_internal } // namespace cloud } // namespace google - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY diff --git a/google/cloud/pubsub/internal/tracing_exactly_once_ack_handler.cc b/google/cloud/pubsub/internal/tracing_exactly_once_ack_handler.cc index 075a7a3f5ccad..9f5b0d4f75d93 100644 --- a/google/cloud/pubsub/internal/tracing_exactly_once_ack_handler.cc +++ b/google/cloud/pubsub/internal/tracing_exactly_once_ack_handler.cc @@ -18,13 +18,11 @@ #include "google/cloud/pubsub/version.h" #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/status.h" -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include #include #include #include #include -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include #include #include @@ -34,8 +32,6 @@ namespace cloud { namespace pubsub_internal { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - namespace { class TracingExactlyOnceAckHandler @@ -139,15 +135,6 @@ MakeTracingExactlyOnceAckHandler( span.span); } -#else // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - -std::unique_ptr -MakeTracingExactlyOnceAckHandler( - std::unique_ptr handler, Span const&) { - return handler; -} - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsub_internal } // namespace cloud diff --git a/google/cloud/pubsub/internal/tracing_exactly_once_ack_handler_test.cc b/google/cloud/pubsub/internal/tracing_exactly_once_ack_handler_test.cc index 45490604e319d..8deaff80d2216 100644 --- a/google/cloud/pubsub/internal/tracing_exactly_once_ack_handler_test.cc +++ b/google/cloud/pubsub/internal/tracing_exactly_once_ack_handler_test.cc @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #include "google/cloud/pubsub/internal/tracing_exactly_once_ack_handler.h" #include "google/cloud/pubsub/subscription.h" #include "google/cloud/pubsub/testing/mock_exactly_once_ack_handler_impl.h" @@ -317,5 +315,3 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsub_internal } // namespace cloud } // namespace google - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY diff --git a/google/cloud/pubsub/internal/tracing_helpers.cc b/google/cloud/pubsub/internal/tracing_helpers.cc index a03bab767f426..ead3529441452 100644 --- a/google/cloud/pubsub/internal/tracing_helpers.cc +++ b/google/cloud/pubsub/internal/tracing_helpers.cc @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #include "google/cloud/pubsub/internal/tracing_helpers.h" #include "google/cloud/pubsub/version.h" #include "google/cloud/internal/opentelemetry.h" @@ -70,5 +68,3 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsub_internal } // namespace cloud } // namespace google - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY diff --git a/google/cloud/pubsub/internal/tracing_helpers.h b/google/cloud/pubsub/internal/tracing_helpers.h index 0e867ff4359d7..eaee01ab1143c 100644 --- a/google/cloud/pubsub/internal/tracing_helpers.h +++ b/google/cloud/pubsub/internal/tracing_helpers.h @@ -15,8 +15,6 @@ #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_PUBSUB_INTERNAL_TRACING_HELPERS_H #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_PUBSUB_INTERNAL_TRACING_HELPERS_H -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #include "google/cloud/pubsub/pull_ack_handler.h" #include "google/cloud/pubsub/version.h" #include @@ -53,6 +51,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace cloud } // namespace google -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_PUBSUB_INTERNAL_TRACING_HELPERS_H diff --git a/google/cloud/pubsub/internal/tracing_helpers_test.cc b/google/cloud/pubsub/internal/tracing_helpers_test.cc index 018e0e0c7cc9c..57bed72c2e48c 100644 --- a/google/cloud/pubsub/internal/tracing_helpers_test.cc +++ b/google/cloud/pubsub/internal/tracing_helpers_test.cc @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #include "google/cloud/pubsub/internal/tracing_helpers.h" #include "google/cloud/pubsub/options.h" #include "google/cloud/internal/opentelemetry.h" @@ -185,5 +183,3 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsub_internal } // namespace cloud } // namespace google - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY diff --git a/google/cloud/pubsub/internal/tracing_message_callback.cc b/google/cloud/pubsub/internal/tracing_message_callback.cc index 0eb46b73ccf7d..663cecf0b0dfa 100644 --- a/google/cloud/pubsub/internal/tracing_message_callback.cc +++ b/google/cloud/pubsub/internal/tracing_message_callback.cc @@ -18,18 +18,14 @@ #include "google/cloud/pubsub/subscription.h" #include "google/cloud/pubsub/version.h" #include "google/cloud/internal/opentelemetry.h" -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include #include -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY namespace google { namespace cloud { namespace pubsub_internal { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - namespace { class TracingMessageCallback : public MessageCallback { @@ -70,15 +66,6 @@ std::shared_ptr MakeTracingMessageCallback( opts); } -#else // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - -std::shared_ptr MakeTracingMessageCallback( - std::shared_ptr message_callback, Options const&) { - return message_callback; -} - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsub_internal } // namespace cloud diff --git a/google/cloud/pubsub/internal/tracing_message_callback_test.cc b/google/cloud/pubsub/internal/tracing_message_callback_test.cc index 1d53dc8017c96..d2154d94171ed 100644 --- a/google/cloud/pubsub/internal/tracing_message_callback_test.cc +++ b/google/cloud/pubsub/internal/tracing_message_callback_test.cc @@ -24,13 +24,11 @@ #include "google/cloud/testing_util/is_proto_equal.h" #include "google/cloud/testing_util/opentelemetry_matchers.h" #include "google/cloud/testing_util/status_matchers.h" -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY +#include #include #include #include #include -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY -#include namespace google { namespace cloud { @@ -38,7 +36,6 @@ namespace pubsub_internal { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN namespace { -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY using ::google::cloud::testing_util::InstallSpanCatcher; using ::google::cloud::testing_util::OTelAttribute; using ::google::cloud::testing_util::SpanHasAttributes; @@ -130,30 +127,6 @@ TEST(TracingMessageCallback, AddTracingAckHandler) { SpanNamed("test-sub ack"))); } -#else // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - -using ::testing::IsNull; -using ::testing::Not; - -TEST(TracingMessageCallback, - VerifyMessageCallbackIsNotNullWhenOTelIsNotCompiled) { - auto mock = std::make_shared(); - EXPECT_CALL(*mock, user_callback).Times(1); - auto message_callback = MakeTracingMessageCallback( - std::move(mock), Options{}.set( - pubsub::Subscription("test-project", "test-sub"))); - - EXPECT_THAT(message_callback, Not(IsNull())); - - message_callback->user_callback(MessageCallback::MessageAndHandler{ - pubsub::MessageBuilder().Build(), - std::make_unique(), - "ack-id", - {}}); -} - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - } // namespace GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsub_internal diff --git a/google/cloud/pubsub/internal/tracing_pull_ack_handler.cc b/google/cloud/pubsub/internal/tracing_pull_ack_handler.cc index 84eaf4c48d5b1..3e4720c5564c1 100644 --- a/google/cloud/pubsub/internal/tracing_pull_ack_handler.cc +++ b/google/cloud/pubsub/internal/tracing_pull_ack_handler.cc @@ -17,13 +17,11 @@ #include "google/cloud/pubsub/version.h" #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/status.h" -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include #include #include #include #include -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include #include #include @@ -33,8 +31,6 @@ namespace cloud { namespace pubsub_internal { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - class TracingPullAckHandler : public pubsub::PullAckHandler::Impl { public: explicit TracingPullAckHandler( @@ -134,15 +130,6 @@ std::unique_ptr MakeTracingPullAckHandler( return std::make_unique(std::move(handler)); } -#else // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - -std::unique_ptr MakeTracingPullAckHandler( - std::unique_ptr handler) { - return handler; -} - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsub_internal } // namespace cloud diff --git a/google/cloud/pubsub/internal/tracing_pull_ack_handler_test.cc b/google/cloud/pubsub/internal/tracing_pull_ack_handler_test.cc index a1594f9a9911b..4b613566f222a 100644 --- a/google/cloud/pubsub/internal/tracing_pull_ack_handler_test.cc +++ b/google/cloud/pubsub/internal/tracing_pull_ack_handler_test.cc @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #include "google/cloud/pubsub/internal/tracing_pull_ack_handler.h" #include "google/cloud/pubsub/mocks/mock_pull_ack_handler.h" #include "google/cloud/pubsub/subscription.h" @@ -313,5 +311,3 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsub_internal } // namespace cloud } // namespace google - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY diff --git a/google/cloud/pubsub/internal/tracing_pull_lease_manager.cc b/google/cloud/pubsub/internal/tracing_pull_lease_manager.cc index 8782283a314f9..b9b39ac47d59d 100644 --- a/google/cloud/pubsub/internal/tracing_pull_lease_manager.cc +++ b/google/cloud/pubsub/internal/tracing_pull_lease_manager.cc @@ -19,11 +19,9 @@ #include "google/cloud/internal/async_retry_loop.h" #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/status.h" -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include #include #include -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include #include @@ -32,8 +30,6 @@ namespace cloud { namespace pubsub_internal { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - class TracingPullLeaseManagerImpl : public PullLeaseManagerImpl { public: explicit TracingPullLeaseManagerImpl( @@ -94,16 +90,6 @@ std::shared_ptr MakeTracingPullLeaseManagerImpl( std::move(manager), std::move(ack_id), std::move(subscription)); } -#else // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - -std::shared_ptr MakeTracingPullLeaseManagerImpl( - std::shared_ptr manager, std::string, - pubsub::Subscription) { - return manager; -} - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsub_internal } // namespace cloud diff --git a/google/cloud/pubsub/internal/tracing_pull_lease_manager_test.cc b/google/cloud/pubsub/internal/tracing_pull_lease_manager_test.cc index 711c72765488a..8525cdd36fad8 100644 --- a/google/cloud/pubsub/internal/tracing_pull_lease_manager_test.cc +++ b/google/cloud/pubsub/internal/tracing_pull_lease_manager_test.cc @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #include "google/cloud/pubsub/internal/tracing_pull_lease_manager.h" #include "google/cloud/pubsub/subscription.h" #include "google/cloud/pubsub/testing/mock_pull_lease_manager.h" @@ -280,6 +278,4 @@ TEST(TracingPullLeaseManagerImplTest, ExtendAddsSpanIdAndTraceIdAttribute) { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsub_internal } // namespace cloud -} // namespace google - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY +} // namespace google \ No newline at end of file diff --git a/google/cloud/pubsub/publisher_connection_test.cc b/google/cloud/pubsub/publisher_connection_test.cc index 0d6ab900ed5a5..bcccf0574fa6c 100644 --- a/google/cloud/pubsub/publisher_connection_test.cc +++ b/google/cloud/pubsub/publisher_connection_test.cc @@ -340,7 +340,6 @@ TEST(PublisherConnectionTest, HandleTransientEnabledRetry) { EXPECT_EQ("test-message-id-0", *response); } -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY using ::google::cloud::testing_util::DisableTracing; using ::google::cloud::testing_util::EnableTracing; using ::google::cloud::testing_util::InstallSpanCatcher; @@ -402,7 +401,6 @@ TEST(MakePublisherConnectionTest, TracingDisabled) { EXPECT_THAT(span_catcher->GetSpans(), IsEmpty()); } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY } // namespace GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/pubsub/subscriber_connection_test.cc b/google/cloud/pubsub/subscriber_connection_test.cc index 299e2afa72504..6f8ff64a8c28d 100644 --- a/google/cloud/pubsub/subscriber_connection_test.cc +++ b/google/cloud/pubsub/subscriber_connection_test.cc @@ -164,7 +164,7 @@ TEST(SubscriberConnectionTest, MakeSubscriberConnectionSetupsMetadata) { ASSERT_STATUS_OK(response.get()); } -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY + using ::google::cloud::testing_util::DisableTracing; using ::google::cloud::testing_util::EnableTracing; using ::google::cloud::testing_util::InstallSpanCatcher; @@ -271,7 +271,7 @@ TEST(MakeSubscriberConnectionTest, TracingDisabledForUnaryPull) { EXPECT_THAT(spans, IsEmpty()); } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY + } // namespace GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/spanner/internal/spanner_stub_factory_test.cc b/google/cloud/spanner/internal/spanner_stub_factory_test.cc index 65b1c3c45514c..b6315d1de8c26 100644 --- a/google/cloud/spanner/internal/spanner_stub_factory_test.cc +++ b/google/cloud/spanner/internal/spanner_stub_factory_test.cc @@ -112,7 +112,6 @@ TEST(DecorateSpannerStub, Logging) { Contains(AllOf(HasSubstr("CreateSession"), HasSubstr("fail")))); } -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY using ::google::cloud::testing_util::DisableTracing; using ::google::cloud::testing_util::EnableTracing; using ::google::cloud::testing_util::SpanNamed; @@ -168,7 +167,6 @@ TEST(DecorateSpannerStub, TracingDisabled) { EXPECT_THAT(span_catcher->GetSpans(), IsEmpty()); } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY } // namespace GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/storage/client_test.cc b/google/cloud/storage/client_test.cc index 07ebb8a424bbc..4ac15c0170eba 100644 --- a/google/cloud/storage/client_test.cc +++ b/google/cloud/storage/client_test.cc @@ -196,7 +196,6 @@ TEST_F(ClientTest, LoggingDecoratorsRestClient) { ElementsAre("RestStub", "LoggingStub", "StorageConnectionImpl")); } -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY using ::google::cloud::testing_util::DisableTracing; using ::google::cloud::testing_util::EnableTracing; @@ -239,8 +238,6 @@ TEST_F(ClientTest, OTelDisableTracing) { ElementsAre("RestStub", "LoggingStub", "StorageConnectionImpl")); } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #include "google/cloud/internal/disable_deprecation_warnings.inc" TEST_F(ClientTest, DeprecatedButNotDecommissioned) { diff --git a/google/cloud/storage/internal/async/connection_tracing.cc b/google/cloud/storage/internal/async/connection_tracing.cc index 66b89607f4031..57526c2b995c5 100644 --- a/google/cloud/storage/internal/async/connection_tracing.cc +++ b/google/cloud/storage/internal/async/connection_tracing.cc @@ -27,8 +27,6 @@ namespace cloud { namespace storage_internal { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - namespace { class AsyncConnectionTracing : public storage_experimental::AsyncConnection { @@ -233,16 +231,6 @@ MakeTracingAsyncConnection( return std::make_unique(std::move(impl)); } -#else - -std::shared_ptr -MakeTracingAsyncConnection( - std::shared_ptr impl) { - return impl; -} - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace storage_internal } // namespace cloud diff --git a/google/cloud/storage/internal/async/connection_tracing_test.cc b/google/cloud/storage/internal/async/connection_tracing_test.cc index 72bbfaaddf676..a5a0e21c8d71f 100644 --- a/google/cloud/storage/internal/async/connection_tracing_test.cc +++ b/google/cloud/storage/internal/async/connection_tracing_test.cc @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #include "google/cloud/storage/internal/async/connection_tracing.h" #include "google/cloud/storage/async/object_descriptor_connection.h" #include "google/cloud/storage/async/reader_connection.h" @@ -744,5 +742,3 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace storage_internal } // namespace cloud } // namespace google - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY diff --git a/google/cloud/storage/internal/async/object_descriptor_connection_tracing.cc b/google/cloud/storage/internal/async/object_descriptor_connection_tracing.cc index d5c841698a98c..9d95f8cd34d0a 100644 --- a/google/cloud/storage/internal/async/object_descriptor_connection_tracing.cc +++ b/google/cloud/storage/internal/async/object_descriptor_connection_tracing.cc @@ -17,9 +17,7 @@ #include "google/cloud/storage/internal/async/reader_connection_tracing.h" #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/version.h" -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include namespace google { @@ -27,8 +25,6 @@ namespace cloud { namespace storage_internal { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - namespace { namespace sc = ::opentelemetry::semconv; @@ -81,8 +77,6 @@ MakeTracingObjectDescriptorConnection( std::move(span), std::move(impl)); } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace storage_internal } // namespace cloud diff --git a/google/cloud/storage/internal/async/object_descriptor_connection_tracing.h b/google/cloud/storage/internal/async/object_descriptor_connection_tracing.h index cff3325993113..8e81c2ff6570b 100644 --- a/google/cloud/storage/internal/async/object_descriptor_connection_tracing.h +++ b/google/cloud/storage/internal/async/object_descriptor_connection_tracing.h @@ -16,24 +16,18 @@ #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_INTERNAL_ASYNC_OBJECT_DESCRIPTOR_CONNECTION_TRACING_H #include "google/cloud/storage/async/object_descriptor_connection.h" -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include "google/cloud/internal/opentelemetry.h" -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY namespace google { namespace cloud { namespace storage_internal { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - std::shared_ptr MakeTracingObjectDescriptorConnection( opentelemetry::nostd::shared_ptr span, std::shared_ptr impl); -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace storage_internal } // namespace cloud diff --git a/google/cloud/storage/internal/async/object_descriptor_connection_tracing_test.cc b/google/cloud/storage/internal/async/object_descriptor_connection_tracing_test.cc index f0ecb56b9b5f3..2a82fb788776b 100644 --- a/google/cloud/storage/internal/async/object_descriptor_connection_tracing_test.cc +++ b/google/cloud/storage/internal/async/object_descriptor_connection_tracing_test.cc @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #include "google/cloud/storage/internal/async/object_descriptor_connection_tracing.h" #include "google/cloud/storage/async/object_descriptor_connection.h" #include "google/cloud/storage/mocks/mock_async_object_descriptor_connection.h" @@ -155,5 +153,3 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace storage_internal } // namespace cloud } // namespace google - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY diff --git a/google/cloud/storage/internal/async/object_descriptor_reader_tracing.cc b/google/cloud/storage/internal/async/object_descriptor_reader_tracing.cc index 4a5868fc55d1d..f070ed5286825 100644 --- a/google/cloud/storage/internal/async/object_descriptor_reader_tracing.cc +++ b/google/cloud/storage/internal/async/object_descriptor_reader_tracing.cc @@ -17,9 +17,7 @@ #include "google/cloud/storage/internal/async/object_descriptor_reader.h" #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/version.h" -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include namespace google { @@ -27,8 +25,6 @@ namespace cloud { namespace storage_internal { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - namespace { namespace sc = ::opentelemetry::semconv; @@ -78,15 +74,6 @@ MakeTracingObjectDescriptorReader(std::shared_ptr impl) { return std::make_unique(std::move(impl)); } -#else // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - -std::unique_ptr -MakeTracingObjectDescriptorReader(std::shared_ptr impl) { - return std::make_unique(std::move(impl)); -} - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace storage_internal } // namespace cloud diff --git a/google/cloud/storage/internal/async/object_descriptor_reader_tracing_test.cc b/google/cloud/storage/internal/async/object_descriptor_reader_tracing_test.cc index 47728cb4d2531..5b759637e3596 100644 --- a/google/cloud/storage/internal/async/object_descriptor_reader_tracing_test.cc +++ b/google/cloud/storage/internal/async/object_descriptor_reader_tracing_test.cc @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #include "google/cloud/storage/internal/async/object_descriptor_reader_tracing.h" #include "google/cloud/storage/testing/canonical_errors.h" #include "google/cloud/opentelemetry_options.h" @@ -99,5 +97,3 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace storage_internal } // namespace cloud } // namespace google - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY diff --git a/google/cloud/storage/internal/async/reader_connection_tracing.cc b/google/cloud/storage/internal/async/reader_connection_tracing.cc index c912c7b9d138c..f549116e16f8d 100644 --- a/google/cloud/storage/internal/async/reader_connection_tracing.cc +++ b/google/cloud/storage/internal/async/reader_connection_tracing.cc @@ -13,8 +13,6 @@ // limitations under the License. #include "google/cloud/storage/internal/async/reader_connection_tracing.h" - -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include "google/cloud/internal/opentelemetry.h" #include #include @@ -104,5 +102,3 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace storage_internal } // namespace cloud } // namespace google - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY diff --git a/google/cloud/storage/internal/async/reader_connection_tracing.h b/google/cloud/storage/internal/async/reader_connection_tracing.h index ed74f7756bfc3..46bac9b365839 100644 --- a/google/cloud/storage/internal/async/reader_connection_tracing.h +++ b/google/cloud/storage/internal/async/reader_connection_tracing.h @@ -15,8 +15,6 @@ #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_INTERNAL_ASYNC_READER_CONNECTION_TRACING_H #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_INTERNAL_ASYNC_READER_CONNECTION_TRACING_H -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #include "google/cloud/storage/async/reader_connection.h" #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/options.h" @@ -38,6 +36,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace cloud } // namespace google -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_INTERNAL_ASYNC_READER_CONNECTION_TRACING_H diff --git a/google/cloud/storage/internal/async/reader_connection_tracing_test.cc b/google/cloud/storage/internal/async/reader_connection_tracing_test.cc index 1f3db109b9746..e7aa366acb375 100644 --- a/google/cloud/storage/internal/async/reader_connection_tracing_test.cc +++ b/google/cloud/storage/internal/async/reader_connection_tracing_test.cc @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #include "google/cloud/storage/internal/async/reader_connection_tracing.h" #include "google/cloud/storage/mocks/mock_async_reader_connection.h" #include "google/cloud/storage/testing/canonical_errors.h" @@ -204,5 +202,3 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace storage_internal } // namespace cloud } // namespace google - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY diff --git a/google/cloud/storage/internal/async/rewriter_connection_tracing.cc b/google/cloud/storage/internal/async/rewriter_connection_tracing.cc index 197b7bfe4cf7a..a7417863e55c9 100644 --- a/google/cloud/storage/internal/async/rewriter_connection_tracing.cc +++ b/google/cloud/storage/internal/async/rewriter_connection_tracing.cc @@ -21,8 +21,6 @@ namespace cloud { namespace storage_internal { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - namespace { using google::cloud::internal::EndSpan; @@ -76,17 +74,6 @@ MakeTracingAsyncRewriterConnection( std::move(span)); } -#else - -std::shared_ptr -MakeTracingAsyncRewriterConnection( - std::shared_ptr impl, - bool /*enabled*/) { - return impl; -} - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace storage_internal } // namespace cloud diff --git a/google/cloud/storage/internal/async/rewriter_connection_tracing_test.cc b/google/cloud/storage/internal/async/rewriter_connection_tracing_test.cc index 4055895577386..b7f568d564f5b 100644 --- a/google/cloud/storage/internal/async/rewriter_connection_tracing_test.cc +++ b/google/cloud/storage/internal/async/rewriter_connection_tracing_test.cc @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #include "google/cloud/storage/internal/async/rewriter_connection_tracing.h" #include "google/cloud/storage/mocks/mock_async_rewriter_connection.h" #include "google/cloud/storage/testing/canonical_errors.h" @@ -156,6 +154,4 @@ TEST(RewriterTracingConnection, Disabled) { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace storage_internal } // namespace cloud -} // namespace google - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY +} // namespace google \ No newline at end of file diff --git a/google/cloud/storage/internal/async/writer_connection_tracing.cc b/google/cloud/storage/internal/async/writer_connection_tracing.cc index 56f18a7b6681e..e0b3d4b14cc92 100644 --- a/google/cloud/storage/internal/async/writer_connection_tracing.cc +++ b/google/cloud/storage/internal/async/writer_connection_tracing.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include "google/cloud/storage/internal/async/writer_connection_tracing.h" #include "google/cloud/internal/opentelemetry.h" #include @@ -153,5 +152,3 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace storage_internal } // namespace cloud } // namespace google - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY diff --git a/google/cloud/storage/internal/async/writer_connection_tracing.h b/google/cloud/storage/internal/async/writer_connection_tracing.h index 92ca8838a6d73..2f7e3ab9d650f 100644 --- a/google/cloud/storage/internal/async/writer_connection_tracing.h +++ b/google/cloud/storage/internal/async/writer_connection_tracing.h @@ -15,8 +15,6 @@ #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_INTERNAL_ASYNC_WRITER_CONNECTION_TRACING_H #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_INTERNAL_ASYNC_WRITER_CONNECTION_TRACING_H -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #include "google/cloud/storage/async/writer_connection.h" #include "google/cloud/version.h" #include @@ -38,6 +36,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace cloud } // namespace google -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_INTERNAL_ASYNC_WRITER_CONNECTION_TRACING_H diff --git a/google/cloud/storage/internal/async/writer_connection_tracing_test.cc b/google/cloud/storage/internal/async/writer_connection_tracing_test.cc index c0fcc6e55b179..234c34f4c3b28 100644 --- a/google/cloud/storage/internal/async/writer_connection_tracing_test.cc +++ b/google/cloud/storage/internal/async/writer_connection_tracing_test.cc @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #include "google/cloud/storage/internal/async/writer_connection_tracing.h" #include "google/cloud/storage/mocks/mock_async_writer_connection.h" #include "google/cloud/storage/testing/canonical_errors.h" @@ -255,5 +253,3 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace storage_internal } // namespace cloud } // namespace google - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY diff --git a/google/cloud/storage/internal/connection_impl_test.cc b/google/cloud/storage/internal/connection_impl_test.cc index 4de482b5ebe87..fd0e59c531c44 100644 --- a/google/cloud/storage/internal/connection_impl_test.cc +++ b/google/cloud/storage/internal/connection_impl_test.cc @@ -637,7 +637,6 @@ TEST(RetryClientTest, UploadFinalChunkQueryTooManyMissingPayloads) { ASSERT_THAT(response, Not(IsOk())); } -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY using ::google::cloud::testing_util::EnableTracing; using ::google::cloud::testing_util::InstallSpanCatcher; using ::google::cloud::testing_util::SpanNamed; @@ -695,7 +694,6 @@ TEST(RetryClientTest, BackoffSpansUploadChunk) { SpanNamed("Backoff"), SpanNamed("storage::Client::WriteObject/UploadChunk"))); } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY } // namespace } // namespace internal diff --git a/google/cloud/storage/internal/retry_object_read_source_test.cc b/google/cloud/storage/internal/retry_object_read_source_test.cc index dca08aeabfe08..f264e3e743539 100644 --- a/google/cloud/storage/internal/retry_object_read_source_test.cc +++ b/google/cloud/storage/internal/retry_object_read_source_test.cc @@ -489,7 +489,6 @@ TEST(RetryObjectReadSourceTest, DiscardDataForDecompressiveTranscoding) { Contains(Pair("x-test-only", "download 3 r1"))); } -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY using ::google::cloud::testing_util::DisableTracing; using ::google::cloud::testing_util::EnableTracing; using ::google::cloud::testing_util::SpanNamed; @@ -600,8 +599,6 @@ TEST(RetryObjectReadSourceTest, TracingDisabled) { EXPECT_THAT(spans, IsEmpty()); } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - } // namespace } // namespace internal GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/storage/internal/storage_stub_factory_test.cc b/google/cloud/storage/internal/storage_stub_factory_test.cc index e7464a9254e34..4505906939c7e 100644 --- a/google/cloud/storage/internal/storage_stub_factory_test.cc +++ b/google/cloud/storage/internal/storage_stub_factory_test.cc @@ -258,7 +258,6 @@ TEST_F(StorageStubFactory, QueryWriteStatus) { EXPECT_THAT(log.ExtractLines(), Contains(HasSubstr("QueryWriteStatus"))); } -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY using ::google::cloud::testing_util::DisableTracing; using ::google::cloud::testing_util::EnableTracing; using ::google::cloud::testing_util::SpanNamed; @@ -315,7 +314,6 @@ TEST_F(StorageStubFactory, TracingDisabled) { EXPECT_THAT(span_catcher->GetSpans(), IsEmpty()); } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY } // namespace GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/storage/internal/tracing_connection.cc b/google/cloud/storage/internal/tracing_connection.cc index a282a1133cc08..2f8711dc99831 100644 --- a/google/cloud/storage/internal/tracing_connection.cc +++ b/google/cloud/storage/internal/tracing_connection.cc @@ -26,8 +26,6 @@ namespace cloud { namespace storage_internal { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - TracingConnection::TracingConnection(std::shared_ptr impl) : impl_(std::move(impl)) {} @@ -507,15 +505,6 @@ std::shared_ptr MakeTracingClient( return std::make_shared(std::move(impl)); } -#else - -std::shared_ptr MakeTracingClient( - std::shared_ptr impl) { - return impl; -} - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace storage_internal } // namespace cloud diff --git a/google/cloud/storage/internal/tracing_connection.h b/google/cloud/storage/internal/tracing_connection.h index c59ec011d91ec..66ece3f37f4c7 100644 --- a/google/cloud/storage/internal/tracing_connection.h +++ b/google/cloud/storage/internal/tracing_connection.h @@ -27,8 +27,6 @@ namespace cloud { namespace storage_internal { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - class TracingConnection : public storage::internal::StorageConnection { public: explicit TracingConnection(std::shared_ptr impl); @@ -184,8 +182,6 @@ class TracingConnection : public storage::internal::StorageConnection { std::shared_ptr impl_; }; -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - std::shared_ptr MakeTracingClient( std::shared_ptr impl); diff --git a/google/cloud/storage/internal/tracing_connection_test.cc b/google/cloud/storage/internal/tracing_connection_test.cc index 9e952293db9eb..bda9bc46d0a2d 100644 --- a/google/cloud/storage/internal/tracing_connection_test.cc +++ b/google/cloud/storage/internal/tracing_connection_test.cc @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #include "google/cloud/storage/internal/tracing_connection.h" #include "google/cloud/storage/object_read_stream.h" #include "google/cloud/storage/testing/canonical_errors.h" @@ -1491,5 +1489,3 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace storage_internal } // namespace cloud } // namespace google - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY diff --git a/google/cloud/storage/internal/tracing_object_read_source.cc b/google/cloud/storage/internal/tracing_object_read_source.cc index 4dc148b1937fa..f6f642a9cd132 100644 --- a/google/cloud/storage/internal/tracing_object_read_source.cc +++ b/google/cloud/storage/internal/tracing_object_read_source.cc @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #include "google/cloud/storage/internal/tracing_object_read_source.h" #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/status.h" @@ -80,5 +78,3 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace storage_internal } // namespace cloud } // namespace google - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY diff --git a/google/cloud/storage/internal/tracing_object_read_source.h b/google/cloud/storage/internal/tracing_object_read_source.h index 2914d33584627..2c608f6982565 100644 --- a/google/cloud/storage/internal/tracing_object_read_source.h +++ b/google/cloud/storage/internal/tracing_object_read_source.h @@ -15,8 +15,6 @@ #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_INTERNAL_TRACING_OBJECT_READ_SOURCE_H #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_INTERNAL_TRACING_OBJECT_READ_SOURCE_H -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #include "google/cloud/storage/internal/object_read_source.h" #include "google/cloud/storage/version.h" #include "google/cloud/internal/opentelemetry.h" @@ -57,6 +55,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace cloud } // namespace google -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_INTERNAL_TRACING_OBJECT_READ_SOURCE_H diff --git a/google/cloud/storage/internal/tracing_object_read_source_test.cc b/google/cloud/storage/internal/tracing_object_read_source_test.cc index 56edc4e4974b0..43869203758fe 100644 --- a/google/cloud/storage/internal/tracing_object_read_source_test.cc +++ b/google/cloud/storage/internal/tracing_object_read_source_test.cc @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - #include "google/cloud/storage/internal/tracing_object_read_source.h" #include "google/cloud/storage/testing/canonical_errors.h" #include "google/cloud/storage/testing/mock_client.h" @@ -205,5 +203,3 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace storage_internal } // namespace cloud } // namespace google - -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY diff --git a/google/cloud/stream_range_test.cc b/google/cloud/stream_range_test.cc index 885688127a18c..bced62056bc11 100644 --- a/google/cloud/stream_range_test.cc +++ b/google/cloud/stream_range_test.cc @@ -273,8 +273,6 @@ TEST(StreamRange, ReaderDestructorOptionsSpan) { // happen with `CurrentOptions()` matching those at `StreamRange` ctor time. } -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - using ::google::cloud::testing_util::IsActive; class FakeReader { @@ -318,8 +316,6 @@ TEST(StreamRange, CallSpanActiveThroughout) { // the active span matching that at `StreamRange` ctor time. } -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY - } // namespace GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace cloud From 533552f75c1907cf917aea106b131059723ca169 Mon Sep 17 00:00:00 2001 From: mpeddada1 Date: Wed, 17 Dec 2025 21:01:39 +0000 Subject: [PATCH 2/8] run checker --- google/cloud/google_cloud_cpp_common.cmake | 3 +- .../async_read_write_stream_tracing_test.cc | 2 +- .../async_streaming_read_rpc_tracing_test.cc | 2 +- google/cloud/internal/opentelemetry.h | 34 ------------------- google/cloud/internal/trace_propagator.cc | 2 +- .../cloud/internal/trace_propagator_test.cc | 2 +- .../internal/traced_stream_range_test.cc | 2 +- google/cloud/internal/tracing_rest_client.cc | 2 +- ...onfigure_basic_tracing_integration_test.cc | 2 +- .../blocking_publisher_integration_test.cc | 1 - .../cloud/pubsub/internal/message_carrier.cc | 2 +- .../pubsub/internal/message_carrier_test.cc | 2 +- .../pubsub/internal/message_propagator.cc | 2 +- .../subscriber_tracing_connection_test.cc | 2 +- .../internal/tracing_batch_callback_test.cc | 2 +- .../tracing_pull_lease_manager_test.cc | 2 +- .../pubsub/subscriber_connection_test.cc | 3 -- .../async/rewriter_connection_tracing_test.cc | 2 +- 18 files changed, 15 insertions(+), 54 deletions(-) diff --git a/google/cloud/google_cloud_cpp_common.cmake b/google/cloud/google_cloud_cpp_common.cmake index 07cdae994b377..9d7f7c531c8f2 100644 --- a/google/cloud/google_cloud_cpp_common.cmake +++ b/google/cloud/google_cloud_cpp_common.cmake @@ -202,8 +202,7 @@ if (opentelemetry IN_LIST GOOGLE_CLOUD_CPP_ENABLE) if (opentelemetry-cpp_FOUND) target_link_libraries(google_cloud_cpp_common PUBLIC opentelemetry-cpp::api) - target_compile_definitions( - google_cloud_cpp_common) + target_compile_definitions(google_cloud_cpp_common) set(GOOGLE_CLOUD_CPP_FIND_OPTIONAL_DEPENDENCIES "find_dependency(opentelemetry-cpp)") set(GOOGLE_CLOUD_CPP_OPENTELEMETRY_API "opentelemetry_api") diff --git a/google/cloud/internal/async_read_write_stream_tracing_test.cc b/google/cloud/internal/async_read_write_stream_tracing_test.cc index fcad4608075b8..3ea59eab6990d 100644 --- a/google/cloud/internal/async_read_write_stream_tracing_test.cc +++ b/google/cloud/internal/async_read_write_stream_tracing_test.cc @@ -388,4 +388,4 @@ TEST(AsyncStreamingReadWriteRpcTracing, StartedStreamShouldExtractMetadata) { } // namespace internal GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace cloud -} // namespace google \ No newline at end of file +} // namespace google diff --git a/google/cloud/internal/async_streaming_read_rpc_tracing_test.cc b/google/cloud/internal/async_streaming_read_rpc_tracing_test.cc index 68ae289d66a68..52113a5ccb225 100644 --- a/google/cloud/internal/async_streaming_read_rpc_tracing_test.cc +++ b/google/cloud/internal/async_streaming_read_rpc_tracing_test.cc @@ -264,4 +264,4 @@ TEST(AsyncStreamingReadRpcTracing, StartedStreamShouldExtractMetadata) { } // namespace internal GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace cloud -} // namespace google \ No newline at end of file +} // namespace google diff --git a/google/cloud/internal/opentelemetry.h b/google/cloud/internal/opentelemetry.h index 4a830fb8a850a..bd4ffe84ee42f 100644 --- a/google/cloud/internal/opentelemetry.h +++ b/google/cloud/internal/opentelemetry.h @@ -263,37 +263,3 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace google #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_OPENTELEMETRY_H - -bool TracingEnabled(Options const& options); - -/// Wraps the sleeper in a span, if tracing is enabled. -template -std::function)> MakeTracedSleeper( - Options const& options, - std::function)> sleeper, - std::string const& name) { - if (TracingEnabled(options)) { - return [name, sleeper = std::move(sleeper)]( - std::chrono::duration d) { - // A sleep of 0 is not an interesting event worth tracing. - if (d == std::chrono::duration::zero()) return sleeper(d); - auto span = MakeSpan(name); - sleeper(d); - span->End(); - }; - } - (void)options; - (void)name; - return sleeper; -} - -/// Adds an attribute to the active span, if tracing is enabled. -void AddSpanAttribute(Options const& options, std::string const& key, - std::string const& value); - -} // namespace internal -GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END -} // namespace cloud -} // namespace google - -#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_OPENTELEMETRY_H diff --git a/google/cloud/internal/trace_propagator.cc b/google/cloud/internal/trace_propagator.cc index eafb51a8ef0a3..856f314330d41 100644 --- a/google/cloud/internal/trace_propagator.cc +++ b/google/cloud/internal/trace_propagator.cc @@ -102,4 +102,4 @@ MakePropagator() { } // namespace internal GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace cloud -} // namespace google \ No newline at end of file +} // namespace google diff --git a/google/cloud/internal/trace_propagator_test.cc b/google/cloud/internal/trace_propagator_test.cc index 66ee089f2809e..c6c9e17b773a5 100644 --- a/google/cloud/internal/trace_propagator_test.cc +++ b/google/cloud/internal/trace_propagator_test.cc @@ -112,4 +112,4 @@ TEST(CloudTraceContextPropagator, Fields) { } // namespace internal GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace cloud -} // namespace google \ No newline at end of file +} // namespace google diff --git a/google/cloud/internal/traced_stream_range_test.cc b/google/cloud/internal/traced_stream_range_test.cc index a00e253b563a9..e0dafd3a66a49 100644 --- a/google/cloud/internal/traced_stream_range_test.cc +++ b/google/cloud/internal/traced_stream_range_test.cc @@ -127,4 +127,4 @@ TEST(TracedStreamRange, SpanInactiveWhileIterating) { } // namespace internal GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace cloud -} // namespace google \ No newline at end of file +} // namespace google diff --git a/google/cloud/internal/tracing_rest_client.cc b/google/cloud/internal/tracing_rest_client.cc index 2443282292aee..0c258007841fe 100644 --- a/google/cloud/internal/tracing_rest_client.cc +++ b/google/cloud/internal/tracing_rest_client.cc @@ -246,4 +246,4 @@ std::unique_ptr MakeTracingRestClient( GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace rest_internal } // namespace cloud -} // namespace google \ No newline at end of file +} // namespace google diff --git a/google/cloud/opentelemetry/integration_tests/configure_basic_tracing_integration_test.cc b/google/cloud/opentelemetry/integration_tests/configure_basic_tracing_integration_test.cc index 4f88217c7c56f..63cecebcaba3a 100644 --- a/google/cloud/opentelemetry/integration_tests/configure_basic_tracing_integration_test.cc +++ b/google/cloud/opentelemetry/integration_tests/configure_basic_tracing_integration_test.cc @@ -158,4 +158,4 @@ TEST(ConfigureBasicTracing, RestoresPrevious) { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace otel } // namespace cloud -} // namespace google \ No newline at end of file +} // namespace google diff --git a/google/cloud/pubsub/integration_tests/blocking_publisher_integration_test.cc b/google/cloud/pubsub/integration_tests/blocking_publisher_integration_test.cc index 06678b5541c6a..750011f6b5513 100644 --- a/google/cloud/pubsub/integration_tests/blocking_publisher_integration_test.cc +++ b/google/cloud/pubsub/integration_tests/blocking_publisher_integration_test.cc @@ -71,7 +71,6 @@ TEST_F(BlockingPublisherIntegrationTest, Basic) { ASSERT_STATUS_OK(publish); } - using ::google::cloud::testing_util::DisableTracing; using ::google::cloud::testing_util::EnableTracing; diff --git a/google/cloud/pubsub/internal/message_carrier.cc b/google/cloud/pubsub/internal/message_carrier.cc index f28eae68e89cb..c3efd005dd22d 100644 --- a/google/cloud/pubsub/internal/message_carrier.cc +++ b/google/cloud/pubsub/internal/message_carrier.cc @@ -49,4 +49,4 @@ void MessageCarrier::Set(opentelemetry::nostd::string_view key, GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsub_internal } // namespace cloud -} // namespace google \ No newline at end of file +} // namespace google diff --git a/google/cloud/pubsub/internal/message_carrier_test.cc b/google/cloud/pubsub/internal/message_carrier_test.cc index 206825129a089..d212013d047d7 100644 --- a/google/cloud/pubsub/internal/message_carrier_test.cc +++ b/google/cloud/pubsub/internal/message_carrier_test.cc @@ -68,4 +68,4 @@ TEST(MessageCarrierTest, GetAttributeNotFound) { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsub_internal } // namespace cloud -} // namespace google \ No newline at end of file +} // namespace google diff --git a/google/cloud/pubsub/internal/message_propagator.cc b/google/cloud/pubsub/internal/message_propagator.cc index dbfd9a242e6b2..2b032a4c455f5 100644 --- a/google/cloud/pubsub/internal/message_propagator.cc +++ b/google/cloud/pubsub/internal/message_propagator.cc @@ -42,4 +42,4 @@ opentelemetry::context::Context ExtractTraceContext( GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsub_internal } // namespace cloud -} // namespace google \ No newline at end of file +} // namespace google diff --git a/google/cloud/pubsub/internal/subscriber_tracing_connection_test.cc b/google/cloud/pubsub/internal/subscriber_tracing_connection_test.cc index ba560f9613e6f..1ebf2feb8a2b6 100644 --- a/google/cloud/pubsub/internal/subscriber_tracing_connection_test.cc +++ b/google/cloud/pubsub/internal/subscriber_tracing_connection_test.cc @@ -343,4 +343,4 @@ TEST(SubscriberTracingConnectionTest, options) { } // namespace } // namespace pubsub_internal } // namespace cloud -} // namespace google \ No newline at end of file +} // namespace google diff --git a/google/cloud/pubsub/internal/tracing_batch_callback_test.cc b/google/cloud/pubsub/internal/tracing_batch_callback_test.cc index 457c6556837d3..36034f7f5ca44 100644 --- a/google/cloud/pubsub/internal/tracing_batch_callback_test.cc +++ b/google/cloud/pubsub/internal/tracing_batch_callback_test.cc @@ -521,4 +521,4 @@ TEST(TracingBatchCallback, ExpireThenNack) { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsub_internal } // namespace cloud -} // namespace google \ No newline at end of file +} // namespace google diff --git a/google/cloud/pubsub/internal/tracing_pull_lease_manager_test.cc b/google/cloud/pubsub/internal/tracing_pull_lease_manager_test.cc index 8525cdd36fad8..aee9b815276c9 100644 --- a/google/cloud/pubsub/internal/tracing_pull_lease_manager_test.cc +++ b/google/cloud/pubsub/internal/tracing_pull_lease_manager_test.cc @@ -278,4 +278,4 @@ TEST(TracingPullLeaseManagerImplTest, ExtendAddsSpanIdAndTraceIdAttribute) { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsub_internal } // namespace cloud -} // namespace google \ No newline at end of file +} // namespace google diff --git a/google/cloud/pubsub/subscriber_connection_test.cc b/google/cloud/pubsub/subscriber_connection_test.cc index 6f8ff64a8c28d..364b4a5431b77 100644 --- a/google/cloud/pubsub/subscriber_connection_test.cc +++ b/google/cloud/pubsub/subscriber_connection_test.cc @@ -164,7 +164,6 @@ TEST(SubscriberConnectionTest, MakeSubscriberConnectionSetupsMetadata) { ASSERT_STATUS_OK(response.get()); } - using ::google::cloud::testing_util::DisableTracing; using ::google::cloud::testing_util::EnableTracing; using ::google::cloud::testing_util::InstallSpanCatcher; @@ -271,8 +270,6 @@ TEST(MakeSubscriberConnectionTest, TracingDisabledForUnaryPull) { EXPECT_THAT(spans, IsEmpty()); } - - } // namespace GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace pubsub diff --git a/google/cloud/storage/internal/async/rewriter_connection_tracing_test.cc b/google/cloud/storage/internal/async/rewriter_connection_tracing_test.cc index b7f568d564f5b..417eabf621e71 100644 --- a/google/cloud/storage/internal/async/rewriter_connection_tracing_test.cc +++ b/google/cloud/storage/internal/async/rewriter_connection_tracing_test.cc @@ -154,4 +154,4 @@ TEST(RewriterTracingConnection, Disabled) { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace storage_internal } // namespace cloud -} // namespace google \ No newline at end of file +} // namespace google From 2ef4c77e322eb0d4795ad1f847035779ea4454d7 Mon Sep 17 00:00:00 2001 From: mpeddada1 Date: Wed, 17 Dec 2025 21:16:43 +0000 Subject: [PATCH 3/8] clean up cmake --- google/cloud/google_cloud_cpp_common.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/google/cloud/google_cloud_cpp_common.cmake b/google/cloud/google_cloud_cpp_common.cmake index 9d7f7c531c8f2..8e067558e8fb5 100644 --- a/google/cloud/google_cloud_cpp_common.cmake +++ b/google/cloud/google_cloud_cpp_common.cmake @@ -202,7 +202,6 @@ if (opentelemetry IN_LIST GOOGLE_CLOUD_CPP_ENABLE) if (opentelemetry-cpp_FOUND) target_link_libraries(google_cloud_cpp_common PUBLIC opentelemetry-cpp::api) - target_compile_definitions(google_cloud_cpp_common) set(GOOGLE_CLOUD_CPP_FIND_OPTIONAL_DEPENDENCIES "find_dependency(opentelemetry-cpp)") set(GOOGLE_CLOUD_CPP_OPENTELEMETRY_API "opentelemetry_api") From e9fb6815756434d7a4d1158d8fbd2555493faba5 Mon Sep 17 00:00:00 2001 From: mpeddada1 Date: Wed, 17 Dec 2025 21:43:05 +0000 Subject: [PATCH 4/8] remove ifdef in otel_matcher --- google/cloud/testing_util/opentelemetry_matchers.cc | 2 -- google/cloud/testing_util/opentelemetry_matchers.h | 2 -- 2 files changed, 4 deletions(-) diff --git a/google/cloud/testing_util/opentelemetry_matchers.cc b/google/cloud/testing_util/opentelemetry_matchers.cc index 29298e7c5f4cb..2dbc5c0f1139a 100644 --- a/google/cloud/testing_util/opentelemetry_matchers.cc +++ b/google/cloud/testing_util/opentelemetry_matchers.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include "google/cloud/testing_util/opentelemetry_matchers.h" #include "google/cloud/internal/absl_str_join_quiet.h" #include "google/cloud/internal/opentelemetry.h" @@ -223,4 +222,3 @@ Options DisableTracing(Options options) { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace cloud } // namespace google -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY diff --git a/google/cloud/testing_util/opentelemetry_matchers.h b/google/cloud/testing_util/opentelemetry_matchers.h index 95fe7aeba92b3..885eb5fdcafa7 100644 --- a/google/cloud/testing_util/opentelemetry_matchers.h +++ b/google/cloud/testing_util/opentelemetry_matchers.h @@ -15,7 +15,6 @@ #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_TESTING_UTIL_OPENTELEMETRY_MATCHERS_H #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_TESTING_UTIL_OPENTELEMETRY_MATCHERS_H -#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #include "google/cloud/future.h" #include "google/cloud/internal/opentelemetry_context.h" #include "google/cloud/options.h" @@ -403,6 +402,5 @@ class PromiseWithOTelContext { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace cloud } // namespace google -#endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_TESTING_UTIL_OPENTELEMETRY_MATCHERS_H From 2e0fa5b6668a10716cc8695d836fefa7708cccea Mon Sep 17 00:00:00 2001 From: mpeddada1 Date: Wed, 17 Dec 2025 21:50:28 +0000 Subject: [PATCH 5/8] tracing_rest_client change --- google/cloud/internal/tracing_rest_client.cc | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/google/cloud/internal/tracing_rest_client.cc b/google/cloud/internal/tracing_rest_client.cc index 0c258007841fe..94aa7f807abfe 100644 --- a/google/cloud/internal/tracing_rest_client.cc +++ b/google/cloud/internal/tracing_rest_client.cc @@ -230,20 +230,3 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace rest_internal } // namespace cloud } // namespace google - -#else - -namespace google { -namespace cloud { -namespace rest_internal { -GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN - -std::unique_ptr MakeTracingRestClient( - std::unique_ptr client) { - return client; -} - -GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END -} // namespace rest_internal -} // namespace cloud -} // namespace google From 9534286109c37d29509d66ab49979acf703aa501 Mon Sep 17 00:00:00 2001 From: mpeddada1 Date: Wed, 17 Dec 2025 22:10:21 +0000 Subject: [PATCH 6/8] remove lingering else --- .../cloud/internal/grpc_opentelemetry_test.cc | 14 --------- .../internal/tracing_rest_client_test.cc | 30 ------------------- 2 files changed, 44 deletions(-) diff --git a/google/cloud/internal/grpc_opentelemetry_test.cc b/google/cloud/internal/grpc_opentelemetry_test.cc index ee3e44462cb2a..2ad4667b69d0a 100644 --- a/google/cloud/internal/grpc_opentelemetry_test.cc +++ b/google/cloud/internal/grpc_opentelemetry_test.cc @@ -319,20 +319,6 @@ TEST(OpenTelemetry, TracedAsyncBackoffPreservesContext) { SpanNamed("parent"))); } -#else - -TEST(NoOpenTelemetry, TracedAsyncBackoff) { - auto const duration = std::chrono::nanoseconds(100); - auto mock_cq = std::make_shared(); - EXPECT_CALL(*mock_cq, MakeRelativeTimer(duration)) - .WillOnce(Return(ByMove(make_ready_future( - make_status_or(std::chrono::system_clock::now()))))); - CompletionQueue cq(mock_cq); - - auto f = TracedAsyncBackoff(cq, Options{}, duration, "Async Backoff"); - EXPECT_STATUS_OK(f.get()); -} - } // namespace } // namespace internal GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END diff --git a/google/cloud/internal/tracing_rest_client_test.cc b/google/cloud/internal/tracing_rest_client_test.cc index ca4fb35e3ccc9..4b8e2819e43cb 100644 --- a/google/cloud/internal/tracing_rest_client_test.cc +++ b/google/cloud/internal/tracing_rest_client_test.cc @@ -356,36 +356,6 @@ TEST(TracingRestClient, CachedConnection) { "gl-cpp.cached_connection", true)), SpanHasEvents(EventNamed("gl-cpp.curl.connected"))))); } - -#else - -TEST(TracingRestClient, NoOpenTelemetry) { - auto impl = std::make_unique(); - EXPECT_CALL(*impl, Delete).WillOnce([](RestContext&, RestRequest const&) { - auto response = std::make_unique(); - EXPECT_CALL(*response, StatusCode) - .WillRepeatedly(Return(HttpStatusCode::kOk)); - EXPECT_CALL(*response, Headers).WillRepeatedly(Return(MockHeaders())); - EXPECT_CALL(std::move(*response), ExtractPayload).WillOnce([] { - return MakeMockHttpPayloadSuccess(MockContents()); - }); - return std::unique_ptr(std::move(response)); - }); - - auto constexpr kUrl = "https://storage.googleapis.com/storage/v1/b/my-bucket"; - RestRequest request(kUrl); - request.AddHeader("x-test-header-3", "value3"); - - auto client = MakeTracingRestClient(std::move(impl)); - rest_internal::RestContext context; - auto r = client->Delete(context, request); - ASSERT_STATUS_OK(r); - auto response = *std::move(r); - ASSERT_THAT(response, NotNull()); - EXPECT_THAT(response->StatusCode(), Eq(HttpStatusCode::kOk)); - EXPECT_THAT(response->Headers(), ElementsAreArray(MockHeaders())); - auto contents = ReadAll(std::move(*response).ExtractPayload()); - EXPECT_THAT(contents, IsOkAndHolds(MockContents())); } } // namespace From 033793475c7f4429a3020fe7f78187604e30c5f9 Mon Sep 17 00:00:00 2001 From: mpeddada1 Date: Thu, 18 Dec 2025 02:28:24 +0000 Subject: [PATCH 7/8] fix clang-tidy-pr --- google/cloud/bigtable/internal/data_tracing_connection.cc | 7 ------- google/cloud/internal/tracing_rest_client_test.cc | 1 - 2 files changed, 8 deletions(-) diff --git a/google/cloud/bigtable/internal/data_tracing_connection.cc b/google/cloud/bigtable/internal/data_tracing_connection.cc index c8440821e7434..d97f825eb4fde 100644 --- a/google/cloud/bigtable/internal/data_tracing_connection.cc +++ b/google/cloud/bigtable/internal/data_tracing_connection.cc @@ -214,13 +214,6 @@ std::shared_ptr MakeDataTracingConnection( return std::make_shared(std::move(conn)); } -#else - -std::shared_ptr MakeDataTracingConnection( - std::shared_ptr conn) { - return conn; -} - GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace bigtable_internal } // namespace cloud diff --git a/google/cloud/internal/tracing_rest_client_test.cc b/google/cloud/internal/tracing_rest_client_test.cc index 4b8e2819e43cb..9e5994bd4dae3 100644 --- a/google/cloud/internal/tracing_rest_client_test.cc +++ b/google/cloud/internal/tracing_rest_client_test.cc @@ -356,7 +356,6 @@ TEST(TracingRestClient, CachedConnection) { "gl-cpp.cached_connection", true)), SpanHasEvents(EventNamed("gl-cpp.curl.connected"))))); } -} } // namespace GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END From 84edb9db00116af37a93aae0b7cbdc4e7346465d Mon Sep 17 00:00:00 2001 From: mpeddada1 Date: Thu, 18 Dec 2025 16:34:09 +0000 Subject: [PATCH 8/8] additional clean up --- .../golden_kitchen_sink_tracing_connection_test.cc | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/generator/integration_tests/tests/golden_kitchen_sink_tracing_connection_test.cc b/generator/integration_tests/tests/golden_kitchen_sink_tracing_connection_test.cc index 707b3cb8106cd..72646886eee35 100644 --- a/generator/integration_tests/tests/golden_kitchen_sink_tracing_connection_test.cc +++ b/generator/integration_tests/tests/golden_kitchen_sink_tracing_connection_test.cc @@ -375,18 +375,6 @@ TEST(MakeGoldenKitchenSinkTracingConnection, TracingDisabled) { EXPECT_THAT(spans, IsEmpty()); } -#else - -TEST(MakeGoldenKitchenSinkTracingConnection, NoOpenTelemetry) { - auto mock = std::make_shared(); - EXPECT_CALL(*mock, DoNothing) - .WillOnce(Return(internal::AbortedError("fail"))); - - auto under_test = MakeGoldenKitchenSinkTracingConnection(mock); - auto result = under_test->DoNothing({}); - EXPECT_THAT(result, StatusIs(StatusCode::kAborted)); -} - } // namespace GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace golden_v1_internal