Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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: 57
warning_limit: 49
- cmake_options: all-options-abiv2-preview
warning_limit: 59
warning_limit: 51
env:
CC: /usr/bin/clang-18
CXX: /usr/bin/clang++-18
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ Increment the:
* [CODE HEALTH] Cleanup nostd variant access in API and SDK
[#3965](https://github.com/open-telemetry/opentelemetry-cpp/pull/3965)

* [CODE HEALTH] Fix clang-tidy narrowing-conversions warnings in tests
[#3987](https://github.com/open-telemetry/opentelemetry-cpp/pull/3987)

* Enable WITH_OTLP_RETRY_PREVIEW by default
[#3953](https://github.com/open-telemetry/opentelemetry-cpp/pull/3953)

Expand Down
6 changes: 3 additions & 3 deletions exporters/otlp/test/otlp_metrics_serialization_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ TEST(OtlpMetricSerializationTest, Counter)
EXPECT_EQ(sum.is_monotonic(), true);
for (size_t i = 0; i < 1; i++)
{
const auto &proto_number_point = sum.data_points(i);
const auto &proto_number_point = sum.data_points(static_cast<int>(i));
EXPECT_EQ(proto_number_point.as_double(), i == 0 ? 10.2 : 20.2);
}

Expand Down Expand Up @@ -308,7 +308,7 @@ TEST(OtlpMetricSerializationTest, Histogram)
proto::metrics::v1::AggregationTemporality::AGGREGATION_TEMPORALITY_CUMULATIVE);
for (size_t i = 0; i < 1; i++)
{
const auto &proto_number_point = histogram.data_points(i);
const auto &proto_number_point = histogram.data_points(static_cast<int>(i));
EXPECT_EQ(proto_number_point.sum(), i == 0 ? 100.2 : 200.2);
}

Expand Down Expand Up @@ -381,7 +381,7 @@ TEST(OtlpMetricSerializationTest, ObservableGauge)
otlp_exporter::OtlpMetricUtils::ConvertGaugeMetric(data, &gauge);
for (size_t i = 0; i < 1; i++)
{
const auto &proto_number_point = gauge.data_points(i);
const auto &proto_number_point = gauge.data_points(static_cast<int>(i));
EXPECT_EQ(proto_number_point.as_double(), i == 0 ? 30.2 : 50.2);
}

Expand Down
8 changes: 4 additions & 4 deletions sdk/test/metrics/aggregation_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,8 @@ TEST(Aggregation, Base2ExponentialHistogramAggregationMerge)
const int expected_scale =
aggr_point.scale_ < default_point.scale_ ? aggr_point.scale_ : default_point.scale_;
const int expected_max_buckets = aggr_point.max_buckets_ < default_point.max_buckets_
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit - better to fix the type of the test variables to match those compared

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed in the latest commit. changed expected_max_buckets to size_t and updated the test_merge lambda parameter to match, so no cast needed.

? aggr_point.max_buckets_
: default_point.max_buckets_;
? static_cast<int>(aggr_point.max_buckets_)
: static_cast<int>(default_point.max_buckets_);
const int expected_zero_count = 0;

auto merged_from_default = aggr.Merge(*default_aggr);
Expand All @@ -438,8 +438,8 @@ TEST(Aggregation, Base2ExponentialHistogramAggregationMerge)
const int expected_scale =
aggr_point.scale_ < zero_point.scale_ ? aggr_point.scale_ : zero_point.scale_;
const int expected_max_buckets = aggr_point.max_buckets_ < zero_point.max_buckets_
? aggr_point.max_buckets_
: zero_point.max_buckets_;
? static_cast<int>(aggr_point.max_buckets_)
: static_cast<int>(zero_point.max_buckets_);
const int expected_zero_count = 1;

auto merged_from_zero = aggr.Merge(zero_aggr);
Expand Down
6 changes: 3 additions & 3 deletions sdk/test/metrics/metric_test_stress.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ TEST(HistogramStress, UnsignedInt64)
//
// Start logging threads
//
int record_thread_count = std::thread::hardware_concurrency() - 1;
int record_thread_count = static_cast<int>(std::thread::hardware_concurrency()) - 1;
if (record_thread_count <= 0)
{
record_thread_count = 1;
Expand Down Expand Up @@ -160,12 +160,12 @@ TEST(HistogramStress, UnsignedInt64)
int64_t collected_bucket_sum = 0;
for (const auto &count : actual.counts_)
{
collected_bucket_sum += count;
collected_bucket_sum += static_cast<int64_t>(count);
}
ASSERT_EQ(collected_bucket_sum, actual.count_);

collected_sum += opentelemetry::nostd::get<int64_t>(actual.sum_);
collected_count += actual.count_;
collected_count += static_cast<int64_t>(actual.count_);
}

ASSERT_EQ(expected_count, collected_count);
Expand Down
Loading