Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/clang-tidy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
matrix:
include:
- cmake_options: all-options-abiv1-preview
warning_limit: 309
warning_limit: 278
- cmake_options: all-options-abiv2-preview
warning_limit: 319
warning_limit: 288
env:
CC: /usr/bin/clang-22
CXX: /usr/bin/clang++-22
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ Increment the:

## [Unreleased]

* [CODE HEALTH] Move api/test and sdk/test classes into anonymous namespace
[#4217](https://github.com/open-telemetry/opentelemetry-cpp/pull/4217)

* [CMAKE] Fix and test WITH_API_ONLY option
[#4201](https://github.com/open-telemetry/opentelemetry-cpp/pull/4201)

Expand Down
5 changes: 5 additions & 0 deletions api/test/nostd/shared_ptr_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

using opentelemetry::nostd::shared_ptr;

namespace
{

class A
{
public:
Expand Down Expand Up @@ -237,3 +240,5 @@ TEST(SharedPtrTest, Sort)
{
SharedPtrTest_Sort();
}

} // namespace
5 changes: 5 additions & 0 deletions api/test/nostd/unique_ptr_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

using opentelemetry::nostd::unique_ptr;

namespace
{

class A
{
public:
Expand Down Expand Up @@ -174,3 +177,5 @@ TEST(UniquePtrTest, Comparison)
EXPECT_EQ(ptr3, nullptr);
EXPECT_EQ(nullptr, ptr3);
}

} // namespace
5 changes: 5 additions & 0 deletions api/test/nostd/variant_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

namespace nostd = opentelemetry::nostd;

namespace
{

class DestroyCounter
{
public:
Expand Down Expand Up @@ -120,3 +123,5 @@ TEST(VariantTest, Construction)
nostd::variant<bool, const char *, std::string> v{"abc"};
EXPECT_EQ(v.index(), 1);
}

} // namespace
5 changes: 5 additions & 0 deletions api/test/singleton/singleton_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ static void reset_counts()
unknown_span_count = 0;
}

namespace
{

class MyTracer : public trace::Tracer
{
public:
Expand Down Expand Up @@ -458,3 +461,5 @@ TEST(SingletonTest, Uniqueness)
EXPECT_EQ(span_h_f2_count, 0);
EXPECT_EQ(unknown_span_count, 0);
}

} // namespace
5 changes: 5 additions & 0 deletions sdk/test/common/global_log_handle_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
#include "opentelemetry/sdk/common/attribute_utils.h"
#include "opentelemetry/sdk/common/global_log_handler.h"

namespace
{

class CustomLogHandler : public opentelemetry::sdk::common::internal_log::LogHandler
{
public:
Expand Down Expand Up @@ -76,3 +79,5 @@ TEST(GlobalLogHandleTest, CustomLogHandler)
opentelemetry::sdk::common::internal_log::GlobalLogHandler::SetLogHandler(backup_log_handle);
opentelemetry::sdk::common::internal_log::GlobalLogHandler::SetLogLevel(backup_log_level);
}

} // namespace
5 changes: 5 additions & 0 deletions sdk/test/logs/batch_log_record_processor_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ using namespace opentelemetry::sdk::common;

namespace nostd = opentelemetry::nostd;

namespace
{

class MockLogRecordable final : public opentelemetry::sdk::logs::Recordable
{
public:
Expand Down Expand Up @@ -474,3 +477,5 @@ TEST_F(BatchLogRecordProcessorTest, TestOptionsReadFromMultipleEnvVars)
unsetenv("OTEL_BLRP_EXPORT_TIMEOUT");
unsetenv("OTEL_BLRP_MAX_EXPORT_BATCH_SIZE");
}

} // namespace
5 changes: 5 additions & 0 deletions sdk/test/logs/log_record_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ TEST(ReadWriteLogRecord, SetAndGet)
ASSERT_EQ(record.GetTimestamp().time_since_epoch(), now.time_since_epoch());
}

namespace
{

// Define a basic Logger class
class TestBodyLogger : public opentelemetry::logs::Logger
{
Expand Down Expand Up @@ -343,3 +346,5 @@ TEST(LogBody, BodyConversation)
}
}
}

} // namespace
5 changes: 5 additions & 0 deletions sdk/test/logs/logger_config_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ const std::array<instrumentation_scope::InstrumentationScope *, 5> instrumentati
&test_scope_1, &test_scope_2, &test_scope_3, &test_scope_4, &test_scope_5,
};

namespace
{

// Test fixture for VerifyDefaultConfiguratorBehavior
class DefaultLoggerConfiguratorTestFixture
: public ::testing::TestWithParam<instrumentation_scope::InstrumentationScope *>
Expand Down Expand Up @@ -125,3 +128,5 @@ TEST(LoggerConfig, ScopeConfiguratorPreservesCustomConfig)
INSTANTIATE_TEST_SUITE_P(InstrumentationScopes,
DefaultLoggerConfiguratorTestFixture,
::testing::ValuesIn(instrumentation_scopes));

} // namespace
5 changes: 5 additions & 0 deletions sdk/test/metrics/attributes_hashmap_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ TEST(AttributesHashMap, BasicTests)
EXPECT_EQ(count, hash_map.Size());
}

namespace
{

class MetricAttributeMapHashForCollision
{
public:
Expand Down Expand Up @@ -223,3 +226,5 @@ TEST(AttributesHashMap, OverflowCardinalityLimitBehavior)
EXPECT_NE(map_copy.Get(attr), nullptr);
}
}

} // namespace
5 changes: 5 additions & 0 deletions sdk/test/metrics/cardinality_limit_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ TEST(CardinalityLimit, AttributesHashMapBasicTests)
}
}

namespace
{

class WritableMetricStorageCardinalityLimitTestFixture
: public ::testing::TestWithParam<AggregationTemporality>
{};
Expand Down Expand Up @@ -183,3 +186,5 @@ TEST(CardinalityLimitOverflowAttribute, MatchesSpecLiteral)
EXPECT_EQ(entry.first, "otel.metric.overflow");
EXPECT_EQ(nostd::get<bool>(entry.second), true);
}

} // namespace
5 changes: 5 additions & 0 deletions sdk/test/metrics/circular_buffer_counter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

using namespace opentelemetry::sdk::metrics;

namespace
{

class AdaptingIntegerArrayTest : public testing::TestWithParam<uint64_t>
{};

Expand Down Expand Up @@ -149,3 +152,5 @@ TEST(AdaptingCircularBufferCounterTest, Clear)
counter.Clear();
EXPECT_TRUE(counter.Empty());
}

} // namespace
5 changes: 5 additions & 0 deletions sdk/test/metrics/meter_config_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ const std::array<instrumentation_scope::InstrumentationScope *, 5> instrumentati
&test_scope_1, &test_scope_2, &test_scope_3, &test_scope_4, &test_scope_5,
};

namespace
{

// Test fixture for VerifyDefaultConfiguratorBehavior
class DefaultMeterConfiguratorTestFixture
: public ::testing::TestWithParam<instrumentation_scope::InstrumentationScope *>
Expand All @@ -91,3 +94,5 @@ TEST_P(DefaultMeterConfiguratorTestFixture, VerifyDefaultConfiguratorBehavior)
INSTANTIATE_TEST_SUITE_P(InstrumentationScopes,
DefaultMeterConfiguratorTestFixture,
::testing::ValuesIn(instrumentation_scopes));

} // namespace
5 changes: 5 additions & 0 deletions sdk/test/metrics/metric_test_stress.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ using namespace opentelemetry;
using namespace opentelemetry::sdk::instrumentationscope;
using namespace opentelemetry::sdk::metrics;

namespace
{

class MockMetricExporterForStress : public opentelemetry::sdk::metrics::PushMetricExporter
{
public:
Expand Down Expand Up @@ -175,3 +178,5 @@ TEST(HistogramStress, UnsignedInt64)
ASSERT_EQ(expected_count, collected_count);
ASSERT_EQ(*expected_sum, collected_sum);
}

} // namespace
5 changes: 5 additions & 0 deletions sdk/test/metrics/multi_metric_storage_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
using namespace opentelemetry;
using namespace opentelemetry::sdk::metrics;

namespace
{

class TestMetricStorage : public SyncWritableMetricStorage
{
public:
Expand Down Expand Up @@ -62,3 +65,5 @@ TEST(MultiMetricStorageTest, BasicTests)
EXPECT_EQ(static_cast<TestMetricStorage *>(storage.get())->num_calls_long, 3);
EXPECT_EQ(static_cast<TestMetricStorage *>(storage.get())->num_calls_double, 1);
}

} // namespace
5 changes: 5 additions & 0 deletions sdk/test/metrics/periodic_exporting_metric_reader_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ using namespace opentelemetry;
using namespace opentelemetry::sdk::instrumentationscope;
using namespace opentelemetry::sdk::metrics;

namespace
{

class MockPushMetricExporter : public PushMetricExporter
{
public:
Expand Down Expand Up @@ -168,3 +171,5 @@ TEST(PeriodicExportingMetricReaderOptions, UsesDefault)
EXPECT_EQ(options.export_interval_millis, std::chrono::milliseconds(60000));
EXPECT_EQ(options.export_timeout_millis, std::chrono::milliseconds(30000));
}

} // namespace
5 changes: 5 additions & 0 deletions sdk/test/metrics/sum_aggregation_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,9 @@ TEST(CounterToSumFilterAttributesWithCardinalityLimit, Double)
}
}

namespace
{

class UpDownCounterToSumFixture : public ::testing::TestWithParam<bool>
{};

Expand Down Expand Up @@ -471,3 +474,5 @@ INSTANTIATE_TEST_SUITE_P(UpDownCounterToSum,
UpDownCounterToSumFixture,
::testing::Values(true, false));
#endif

} // namespace
5 changes: 5 additions & 0 deletions sdk/test/metrics/sync_metric_storage_histogram_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
using namespace opentelemetry::sdk::metrics;
using namespace opentelemetry::common;

namespace
{

class WritableMetricStorageHistogramTestFixture
: public ::testing::TestWithParam<AggregationTemporality>
{};
Expand Down Expand Up @@ -538,3 +541,5 @@ INSTANTIATE_TEST_SUITE_P(WritableMetricStorageHistogramTestBase2ExponentialDoubl
WritableMetricStorageHistogramTestFixture,
::testing::Values(AggregationTemporality::kCumulative,
AggregationTemporality::kDelta));

} // namespace
5 changes: 5 additions & 0 deletions sdk/test/resource/resource_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ using namespace opentelemetry::sdk::resource;
namespace nostd = opentelemetry::nostd;
namespace semconv = opentelemetry::semconv;

namespace
{

class TestResource : public Resource
{
public:
Expand Down Expand Up @@ -292,3 +295,5 @@ TEST(ResourceTest, DerivedResourceDetector)
EXPECT_EQ(resource.GetSchemaURL(), detector.schema_url);
EXPECT_TRUE(received_attributes.find("key") != received_attributes.end());
}

} // namespace
5 changes: 5 additions & 0 deletions sdk/test/trace/simple_processor_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ TEST(SimpleProcessor, ToInMemorySpanExporter)
EXPECT_TRUE(processor.Shutdown());
}

namespace
{

// An exporter that does nothing but record (and give back ) the # of times Shutdown was called.
class RecordShutdownExporter final : public SpanExporter
{
Expand Down Expand Up @@ -141,3 +144,5 @@ TEST(SimpleSpanProcessor, ForceFlushFail)
std::unique_ptr<SpanExporter>{new FailShutDownForceFlushExporter()});
EXPECT_EQ(false, processor.ForceFlush());
}

} // namespace
5 changes: 5 additions & 0 deletions sdk/test/trace/tracer_config_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ const std::array<instrumentation_scope::InstrumentationScope *, 5> instrumentati
&test_scope_1, &test_scope_2, &test_scope_3, &test_scope_4, &test_scope_5,
};

namespace
{

// Test fixture for VerifyDefaultConfiguratorBehavior
class DefaultTracerConfiguratorTestFixture
: public ::testing::TestWithParam<instrumentation_scope::InstrumentationScope *>
Expand All @@ -91,3 +94,5 @@ TEST_P(DefaultTracerConfiguratorTestFixture, VerifyDefaultConfiguratorBehavior)
INSTANTIATE_TEST_SUITE_P(InstrumentationScopes,
DefaultTracerConfiguratorTestFixture,
::testing::ValuesIn(instrumentation_scopes));

} // namespace
Loading