diff --git a/.github/workflows/clang-tidy.yaml b/.github/workflows/clang-tidy.yaml index 4abf4c27c4..e20dca847f 100644 --- a/.github/workflows/clang-tidy.yaml +++ b/.github/workflows/clang-tidy.yaml @@ -19,7 +19,7 @@ jobs: - cmake_options: all-options-abiv1-preview warning_limit: 31 - cmake_options: all-options-abiv2-preview - warning_limit: 33 + warning_limit: 31 env: CC: /usr/bin/clang-18 CXX: /usr/bin/clang++-18 diff --git a/CHANGELOG.md b/CHANGELOG.md index a9a9c1da79..7d588b8735 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -70,6 +70,9 @@ Increment the: * [CODE HEALTH] Fix clang-tidy misc-no-recursion warnings [#4009](https://github.com/open-telemetry/opentelemetry-cpp/pull/4009) +* [CODE HEALTH] Fix clang-tidy narrowing-conversions warnings in sync_instruments + [#4013](https://github.com/open-telemetry/opentelemetry-cpp/pull/4013) + Important changes: * Enable WITH_OTLP_RETRY_PREVIEW by default diff --git a/sdk/src/metrics/sync_instruments.cc b/sdk/src/metrics/sync_instruments.cc index 4eac12bb83..ab40ad7336 100644 --- a/sdk/src/metrics/sync_instruments.cc +++ b/sdk/src/metrics/sync_instruments.cc @@ -460,7 +460,7 @@ void LongHistogram::Record(uint64_t value, return; } auto context = opentelemetry::context::Context{}; - return storage_->RecordLong(value, attributes, context); + return storage_->RecordLong(static_cast(value), attributes, context); } void LongHistogram::Record(uint64_t value) noexcept @@ -472,7 +472,7 @@ void LongHistogram::Record(uint64_t value) noexcept return; } auto context = opentelemetry::context::Context{}; - return storage_->RecordLong(value, context); + return storage_->RecordLong(static_cast(value), context); } #endif diff --git a/sdk/test/metrics/sync_instruments_test.cc b/sdk/test/metrics/sync_instruments_test.cc index 263441d38c..b07a44f041 100644 --- a/sdk/test/metrics/sync_instruments_test.cc +++ b/sdk/test/metrics/sync_instruments_test.cc @@ -163,6 +163,11 @@ TEST(SyncInstruments, LongHistogram) opentelemetry::context::Context{}); histogram.Record(10, opentelemetry::common::KeyValueIterableView({}), opentelemetry::context::Context{}); + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + histogram.Record(10ULL); + histogram.Record(10ULL, opentelemetry::common::KeyValueIterableView({})); +#endif } TEST(SyncInstruments, DoubleHistogram)