Skip to content

Commit 2e2f1a1

Browse files
committed
merged from upstream
2 parents 143602a + 5f3a216 commit 2e2f1a1

22 files changed

Lines changed: 1013 additions & 49 deletions

.devcontainer/Dockerfile.dev

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,24 @@ ENV THIRD_PARTY_BUILD_TYPE=${THIRD_PARTY_BUILD_TYPE}
1515

1616
COPY ci /opt/ci
1717

18-
RUN apt update && apt install -y wget \
18+
RUN apt update && apt install -y wget gnupg lsb-release software-properties-common && \
19+
wget -qO- https://apt.llvm.org/llvm.sh | bash -s -- 22 && \
20+
apt install -y \
1921
ninja-build \
20-
llvm-20-dev \
21-
libclang-20-dev \
22-
clang-tidy-20 \
22+
llvm-22-dev \
23+
libclang-22-dev \
24+
clang-22 \
25+
clang-tidy-22 \
2326
shellcheck \
2427
sudo \
2528
cmake
2629

27-
RUN update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-20 200 && \
28-
update-alternatives --install /usr/bin/llvm-config llvm-config /usr/bin/llvm-config-20 200 && \
30+
RUN update-alternatives --install /usr/bin/clang clang /usr/bin/clang-22 200 && \
31+
update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-22 200 && \
32+
update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-22 200 && \
33+
update-alternatives --install /usr/bin/llvm-config llvm-config /usr/bin/llvm-config-22 200 && \
34+
update-alternatives --config clang && \
35+
update-alternatives --config clang++ && \
2936
update-alternatives --config clang-tidy && \
3037
update-alternatives --config llvm-config
3138

.github/workflows/clang-tidy.yaml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ permissions:
1111

1212
jobs:
1313
clang-tidy:
14-
runs-on: ubuntu-latest
14+
runs-on: ubuntu-24.04
1515
strategy:
1616
fail-fast: false
1717
matrix:
1818
include:
1919
- cmake_options: all-options-abiv1-preview
20-
warning_limit: 29
20+
warning_limit: 879
2121
- cmake_options: all-options-abiv2-preview
22-
warning_limit: 29
22+
warning_limit: 882
2323
env:
24-
CC: /usr/bin/clang-18
25-
CXX: /usr/bin/clang++-18
24+
CC: /usr/bin/clang-22
25+
CXX: /usr/bin/clang++-22
2626
CXX_STANDARD: '14' # Run clang-tidy on the minimum supported c++ standard
2727
steps:
2828
- name: Harden the runner (Audit all outbound calls)
@@ -53,18 +53,19 @@ jobs:
5353
libgtest-dev \
5454
libbenchmark-dev
5555
56-
- name: Install rapidyaml
57-
run: |
58-
sudo -E ./ci/install_thirdparty.sh --install-dir /usr/local --tags-file third_party_release --packages "ryml"
59-
60-
- name: Install clang-tidy-20
56+
- name: Install clang-22 toolchain
6157
run: |
62-
sudo apt install -y clang-tidy-20
63-
sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-20 200
58+
wget -qO- https://apt.llvm.org/llvm.sh | sudo bash -s -- 22
59+
sudo apt install -y clang-22 clang-tidy-22
60+
sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-22 200
6461
sudo update-alternatives --config clang-tidy
6562
echo "Using clang-tidy version: $(clang-tidy --version)"
6663
echo "clang-tidy installed at: $(which clang-tidy)"
6764
65+
- name: Install rapidyaml
66+
run: |
67+
sudo -E ./ci/install_thirdparty.sh --install-dir /usr/local --tags-file third_party_release --packages "ryml"
68+
6869
- name: Build and run clang-tidy
6970
id: build
7071
env:

.github/workflows/iwyu.yml

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ permissions:
1212

1313
jobs:
1414
iwyu:
15-
runs-on: ubuntu-latest
15+
runs-on: ubuntu-24.04
1616
strategy:
1717
fail-fast: false
1818
matrix:
1919
include:
2020
- cmake_options: all-options-abiv1
21-
warning_limit: 0
21+
warning_limit: 161
2222
- cmake_options: all-options-abiv1-preview
23-
warning_limit: 0
23+
warning_limit: 190
2424
- cmake_options: all-options-abiv2-preview
25-
warning_limit: 0
25+
warning_limit: 187
2626

2727
steps:
2828
- name: Harden the runner (Audit all outbound calls)
@@ -37,6 +37,7 @@ jobs:
3737
- name: setup dependencies
3838
run: |
3939
sudo apt update -y
40+
wget -qO- https://apt.llvm.org/llvm.sh | sudo bash -s -- 22
4041
sudo apt install -y --no-install-recommends --no-install-suggests \
4142
build-essential \
4243
ninja-build \
@@ -50,9 +51,11 @@ jobs:
5051
libgmock-dev \
5152
libgtest-dev \
5253
libbenchmark-dev \
53-
llvm-dev \
54-
libclang-dev \
54+
llvm-22-dev \
55+
libclang-22-dev \
56+
clang-22 \
5557
cmake
58+
sudo update-alternatives --install /usr/bin/llvm-config llvm-config /usr/bin/llvm-config-22 200
5659
5760
- name: Install rapidyaml
5861
run: |
@@ -62,22 +65,13 @@ jobs:
6265
run: |
6366
sudo ./ci/install_iwyu.sh
6467
65-
- name: Prepare CMake
68+
- name: Build with include-what-you-use
6669
env:
67-
CC: clang
68-
CXX: clang++
70+
OTELCPP_CMAKE_CACHE_FILE: ${{ matrix.cmake_options }}.cmake
71+
BUILD_DIR: build-${{ matrix.cmake_options }}
6972
run: |
70-
TOPDIR=`pwd`
71-
cmake -B build-${{ matrix.cmake_options }} \
72-
-C ./test_common/cmake/${{ matrix.cmake_options }}.cmake \
73-
-DCMAKE_CXX_STANDARD=14 \
74-
-DWITH_STL=CXX14 \
75-
-DCMAKE_CXX_FLAGS="-Wno-deprecated-declarations" \
76-
-DCMAKE_CXX_INCLUDE_WHAT_YOU_USE="include-what-you-use;-w;-Xiwyu;--mapping_file=${TOPDIR}/.iwyu.imp;"
77-
78-
- name: iwyu_tool
79-
run: |
80-
cmake --build build-${{ matrix.cmake_options }} -- -j$(nproc) -k 2>&1 | tee -a iwyu-${{ matrix.cmake_options }}.log
73+
./ci/do_ci.sh cmake.iwyu.test
74+
cp "${BUILD_DIR}/opentelemetry-cpp-iwyu-${{ matrix.cmake_options }}.log" iwyu-${{ matrix.cmake_options }}.log
8175
8276
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
8377
if: success() || failure()

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ Increment the:
1515

1616
## [Unreleased]
1717

18+
* [API] Fix `Logger::Enabled()`
19+
[#2667](https://github.com/open-telemetry/opentelemetry-cpp/issues/2667)
20+
1821
* [CONFIGURATION] File configuration - composable samplers
1922
[#3966](https://github.com/open-telemetry/opentelemetry-cpp/issues/3966)
2023
* [SDK] Fix PeriodicExportingMetricReader shutdown race on destruction

CONTRIBUTING.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,22 @@ bash ci/do_ci.sh cmake.exporter.otprotocol.test
127127
This command initiates the CI pipeline, executing tests specifically for the
128128
**cmake.exporter.otprotocol** module.
129129

130+
To reproduce CI's `include-what-you-use` warnings locally, run from inside
131+
the dev container (where IWYU is preinstalled):
132+
133+
```bash
134+
OTELCPP_CMAKE_CACHE_FILE=all-options-abiv1-preview.cmake \
135+
bash ci/do_ci.sh cmake.iwyu.test
136+
```
137+
138+
The target defaults to `clang-22`/`clang++-22` to match the LLVM version
139+
the dev container's IWYU was built against. Export `CC`/`CXX` to override
140+
if you need a different compiler.
141+
142+
Set `OTELCPP_CMAKE_CACHE_FILE` to any of `all-options-abiv1.cmake`,
143+
`all-options-abiv1-preview.cmake`, or `all-options-abiv2-preview.cmake`
144+
to match each CI matrix entry.
145+
130146
#### Troubleshooting
131147

132148
If you encounter issues:

api/include/opentelemetry/logs/logger.h

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@
33

44
#pragma once
55

6-
#include <atomic>
6+
#include <stdint.h>
7+
#include <type_traits>
8+
#include <utility>
79

810
#include "opentelemetry/version.h"
11+
#include "opentelemetry/context/context.h"
12+
#include "opentelemetry/logs/event_id.h"
913
#include "opentelemetry/logs/logger_type_traits.h"
1014
#include "opentelemetry/logs/severity.h"
1115
#include "opentelemetry/nostd/string_view.h"
@@ -273,6 +277,29 @@ class Logger
273277
// OpenTelemetry C++ user-facing Logs API
274278
//
275279

280+
#if OPENTELEMETRY_ABI_VERSION_NO >= 2
281+
inline bool Enabled(const opentelemetry::context::Context &context,
282+
Severity severity = Severity::kInvalid) const noexcept
283+
{
284+
if OPENTELEMETRY_LIKELY_CONDITION (!Enabled(severity))
285+
{
286+
return false;
287+
}
288+
return EnabledImplementation(context, severity);
289+
}
290+
291+
inline bool Enabled(const opentelemetry::context::Context &context,
292+
Severity severity,
293+
const EventId &event_id) const noexcept
294+
{
295+
if OPENTELEMETRY_LIKELY_CONDITION (!Enabled(severity))
296+
{
297+
return false;
298+
}
299+
return EnabledImplementation(context, severity, event_id);
300+
}
301+
#endif // OPENTELEMETRY_ABI_VERSION_NO >= 2
302+
276303
inline bool Enabled(Severity severity, const EventId &event_id) const noexcept
277304
{
278305
if OPENTELEMETRY_LIKELY_CONDITION (!Enabled(severity))
@@ -466,7 +493,6 @@ class Logger
466493
//
467494

468495
protected:
469-
// TODO: discuss with community about naming for internal methods.
470496
virtual bool EnabledImplementation(Severity /*severity*/,
471497
const EventId & /*event_id*/) const noexcept
472498
{
@@ -478,6 +504,21 @@ class Logger
478504
return false;
479505
}
480506

507+
#if OPENTELEMETRY_ABI_VERSION_NO >= 2
508+
virtual bool EnabledImplementation(const opentelemetry::context::Context & /*context*/,
509+
Severity /*severity*/) const noexcept
510+
{
511+
return false;
512+
}
513+
514+
virtual bool EnabledImplementation(const opentelemetry::context::Context & /*context*/,
515+
Severity /*severity*/,
516+
const EventId & /*event_id*/) const noexcept
517+
{
518+
return false;
519+
}
520+
#endif // OPENTELEMETRY_ABI_VERSION_NO >= 2
521+
481522
void SetMinimumSeverity(uint8_t severity_or_max) noexcept
482523
{
483524
minimum_severity_ = severity_or_max;

0 commit comments

Comments
 (0)