Skip to content

Commit 6f41459

Browse files
committed
Merge branch 'fix/doc_comment_api' of https://github.com/zurex/opentelemetry-cpp into fix/doc_comment_api
2 parents 9296f1f + 79cc519 commit 6f41459

File tree

131 files changed

+4423
-2482
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+4423
-2482
lines changed

.github/workflows/ci.yml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,33 @@ jobs:
5757
run: |
5858
./ci/do_ci.sh cmake.test
5959
60+
cmake_fetch_content_test:
61+
name: CMake FetchContent usage with opentelemetry-cpp
62+
runs-on: ubuntu-24.04
63+
env:
64+
CXX_STANDARD: '17'
65+
BUILD_TYPE: 'Debug'
66+
steps:
67+
- name: Harden the runner (Audit all outbound calls)
68+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
69+
with:
70+
egress-policy: audit
71+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
72+
with:
73+
submodules: 'recursive'
74+
- name: setup
75+
run: |
76+
sudo -E ./ci/setup_ci_environment.sh
77+
sudo -E ./ci/setup_cmake.sh
78+
sudo -E ./ci/setup_googletest.sh
79+
- name: Install abseil, protobuf, and grpc with apt
80+
run: |
81+
sudo -E apt-get update
82+
sudo -E apt-get install -y libabsl-dev libprotobuf-dev libgrpc++-dev protobuf-compiler protobuf-compiler-grpc
83+
- name: run fetch content cmake test
84+
run: |
85+
./ci/do_ci.sh cmake.fetch_content.test
86+
6087
cmake_gcc_maintainer_sync_test:
6188
name: CMake gcc 14 (maintainer mode, sync)
6289
runs-on: ubuntu-24.04
@@ -1104,7 +1131,7 @@ jobs:
11041131
CXX: /usr/bin/g++-10
11051132
run: ./ci/do_ci.sh code.coverage
11061133
- name: upload report
1107-
uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d # v5.4.2
1134+
uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3
11081135
with:
11091136
files: /home/runner/build/coverage.info
11101137

.github/workflows/codeql-analysis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ jobs:
3939
sudo -E ./ci/setup_googletest.sh
4040
sudo -E ./ci/setup_ci_environment.sh
4141
- name: Initialize CodeQL
42-
uses: github/codeql-action/init@28deaeda66b76a05916b6923827895f2b14ab387 # v3.28.16
42+
uses: github/codeql-action/init@ff0a06e83cb2de871e5a09832bc6a81e7276941f # v3.28.18
4343
with:
4444
languages: cpp
4545
- name: Autobuild
46-
uses: github/codeql-action/autobuild@28deaeda66b76a05916b6923827895f2b14ab387 # v3.28.16
46+
uses: github/codeql-action/autobuild@ff0a06e83cb2de871e5a09832bc6a81e7276941f # v3.28.18
4747
- name: Perform CodeQL Analysis
48-
uses: github/codeql-action/analyze@28deaeda66b76a05916b6923827895f2b14ab387 # v3.28.16
48+
uses: github/codeql-action/analyze@ff0a06e83cb2de871e5a09832bc6a81e7276941f # v3.28.18

.github/workflows/dependencies_image.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
3030
-
3131
name: Build Image
32-
uses: docker/build-push-action@14487ce63c7a62a4a324b0bfb37086795e31c6c1 # v6.16.0
32+
uses: docker/build-push-action@1dc73863535b631f98b2378be8619f83b136f4a0 # v6.17.0
3333
with:
3434
builder: ${{ steps.buildx.outputs.name }}
3535
context: ci/

.github/workflows/fossa.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919

2020
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2121

22-
- uses: fossas/fossa-action@c0a7d013f84c8ee5e910593186598625513cc1e4 # v1.6.0
22+
- uses: fossas/fossa-action@3ebcea1862c6ffbd5cf1b4d0bd6b3fe7bd6f2cac # v1.7.0
2323
with:
2424
api-key: ${{secrets.FOSSA_API_KEY}}
2525
team: OpenTelemetry

.github/workflows/ossf-scorecard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ jobs:
4747
# Upload the results to GitHub's code scanning dashboard (optional).
4848
# Commenting out will disable upload of results to your repo's Code Scanning dashboard
4949
- name: "Upload to code-scanning"
50-
uses: github/codeql-action/upload-sarif@28deaeda66b76a05916b6923827895f2b14ab387 # v3.28.16
50+
uses: github/codeql-action/upload-sarif@ff0a06e83cb2de871e5a09832bc6a81e7276941f # v3.28.18
5151
with:
5252
sarif_file: results.sarif

CHANGELOG.md

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

1616
## [Unreleased]
1717

18+
* [BUILD] Error out when building DLL without MSVC
19+
[#3438](https://github.com/open-telemetry/opentelemetry-cpp/pull/3438)
20+
21+
* [Metrics SDK] Use nostd::function_ref in AttributesHashMap
22+
[#3393](https://github.com/open-telemetry/opentelemetry-cpp/pull/3393)
23+
1824
* [SDK] Base2 exponential histogram aggregation
1925
[#3175](https://github.com/open-telemetry/opentelemetry-cpp/pull/3346)
2026

@@ -33,6 +39,56 @@ Increment the:
3339
* [API] Add Enabled method to Tracer
3440
[#3357](https://github.com/open-telemetry/opentelemetry-cpp/pull/3357)
3541

42+
* [SDK] Optimize PeriodicExportingMetricReader thread usage
43+
[#3383](https://github.com/open-telemetry/opentelemetry-cpp/pull/3383)
44+
45+
* [SDK] Aggregate identical metrics instruments and detect duplicates
46+
[#3358](https://github.com/open-telemetry/opentelemetry-cpp/pull/3358)
47+
48+
* [INSTALL] Add CMake components to the opentelemetry-cpp package
49+
[#3320](https://github.com/open-telemetry/opentelemetry-cpp/pull/3220)
50+
[#3368](https://github.com/open-telemetry/opentelemetry-cpp/pull/3368)
51+
52+
* [BUILD] Upgrade opentelemetry-proto to 1.6.0
53+
[#3407](https://github.com/open-telemetry/opentelemetry-cpp/pull/3407)
54+
55+
* [BUILD] Upgrade nlohmann_json to 3.12.0
56+
[#3406](https://github.com/open-telemetry/opentelemetry-cpp/pull/3406)
57+
58+
* [CMAKE] Add generated protobuf headers to the opentelemetry_proto target
59+
[#3400](https://github.com/open-telemetry/opentelemetry-cpp/pull/3400)
60+
61+
* [CMAKE] Remove include_directories usage and rely on target properties
62+
[#3426](https://github.com/open-telemetry/opentelemetry-cpp/pull/3426)
63+
64+
* [SEMANTIC CONVENTIONS] Upgrade to semantic conventions 1.34.0
65+
[#3428](https://github.com/open-telemetry/opentelemetry-cpp/pull/3428)
66+
67+
* [EXPORTER] ostream log exporter, fixed memory ownership issues
68+
[#3417](https://github.com/open-telemetry/opentelemetry-cpp/pull/3417)
69+
70+
* [TEST] Test all components in a CMake super build
71+
[#3433](https://github.com/open-telemetry/opentelemetry-cpp/pull/3433)
72+
73+
Important changes:
74+
75+
* [EXPORTER] ostream log exporter, fixed memory ownership issues
76+
[#3417](https://github.com/open-telemetry/opentelemetry-cpp/pull/3417)
77+
78+
* In the SDK, the following classes implementation has changed:
79+
80+
* opentelemetry::sdk::logs::ReadableLogRecord
81+
* opentelemetry::sdk::logs::ReadWriteLogRecord
82+
83+
* An application implementing a custom log record exporter,
84+
that reuses these classes from the opentelemetry-cpp SDK,
85+
will need code adjustments, in particular for methods:
86+
87+
* GetBody()
88+
* GetAttributes()
89+
90+
* Applications not using these SDK classes directly are not affected.
91+
3692
## [1.20 2025-04-01]
3793

3894
* [BUILD] Update opentelemetry-proto version

CMakeLists.txt

Lines changed: 10 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,8 @@ if(prometheus-cpp_FOUND)
849849
endif()
850850
message(STATUS "---------------------------------------------")
851851

852+
include("${PROJECT_SOURCE_DIR}/cmake/otel-install-functions.cmake")
853+
852854
include(CMakePackageConfigHelpers)
853855

854856
if(DEFINED OPENTELEMETRY_BUILD_DLL)
@@ -865,8 +867,6 @@ if(DEFINED OPENTELEMETRY_BUILD_DLL)
865867
add_definitions(-DOPENTELEMETRY_BUILD_EXPORT_DLL)
866868
endif()
867869

868-
include_directories(api/include)
869-
870870
add_subdirectory(api)
871871

872872
if(WITH_OPENTRACING)
@@ -899,9 +899,6 @@ endif()
899899

900900
if(NOT WITH_API_ONLY)
901901
set(BUILD_TESTING ${BUILD_TESTING})
902-
include_directories(sdk/include)
903-
include_directories(sdk)
904-
include_directories(ext/include)
905902

906903
add_subdirectory(sdk)
907904
add_subdirectory(ext)
@@ -922,39 +919,14 @@ include(cmake/opentelemetry-build-external-component.cmake)
922919
include(cmake/patch-imported-config.cmake)
923920

924921
if(OPENTELEMETRY_INSTALL)
925-
# Export cmake config and support find_packages(opentelemetry-cpp CONFIG)
926-
# Write config file for find_packages(opentelemetry-cpp CONFIG)
927-
set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}")
928-
configure_package_config_file(
929-
"${CMAKE_CURRENT_LIST_DIR}/cmake/templates/opentelemetry-cpp-config.cmake.in"
930-
"${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}/${PROJECT_NAME}-config.cmake"
931-
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
932-
PATH_VARS OPENTELEMETRY_ABI_VERSION_NO OPENTELEMETRY_VERSION PROJECT_NAME
933-
INCLUDE_INSTALL_DIR CMAKE_INSTALL_LIBDIR)
934-
935-
# Write version file for find_packages(opentelemetry-cpp CONFIG)
936-
write_basic_package_version_file(
937-
"${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}/${PROJECT_NAME}-config-version.cmake"
938-
VERSION ${OPENTELEMETRY_VERSION}
939-
COMPATIBILITY ExactVersion)
940-
941-
# Write the "BUILT_WITH_<dependency" flags for use in the
942-
# opentelemetry-cpp-config.cmake
943-
configure_file(
944-
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/thirdparty-built-with-flags.cmake.in"
945-
"${CMAKE_CURRENT_BINARY_DIR}/thirdparty-built-with-flags.cmake"
946-
@ONLY)
947-
948-
install(
949-
FILES
950-
"${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}/${PROJECT_NAME}-config.cmake"
951-
"${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}/${PROJECT_NAME}-config-version.cmake"
952-
"${CMAKE_CURRENT_BINARY_DIR}/thirdparty-built-with-flags.cmake"
953-
"${CMAKE_CURRENT_LIST_DIR}/cmake/component-definitions.cmake"
954-
"${CMAKE_CURRENT_LIST_DIR}/cmake/thirdparty-dependency-definitions.cmake"
955-
"${CMAKE_CURRENT_LIST_DIR}/cmake/find-package-support-functions.cmake"
956-
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
957-
COMPONENT cmake-config)
922+
# Install the cmake config and version files
923+
otel_install_cmake_config()
924+
925+
# Install the components and associated files
926+
otel_install_components()
927+
928+
# Install the thirdparty dependency definition file
929+
otel_install_thirdparty_definitions()
958930

959931
if(BUILD_PACKAGE)
960932
include(cmake/package.cmake)

INSTALL.md

Lines changed: 52 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -151,21 +151,55 @@ If building and installing Protobuf and gRPC manually with cmake the
151151
$
152152
```
153153

154-
### Incorporating into an existing CMake Project
154+
### Incorporating into an external CMake Project
155155

156-
To use the library from a CMake project, you can locate it directly with
157-
`find_package` and use the imported targets from generated package
158-
configurations. As of now, this will import targets for both API and SDK. In
159-
future, there may be separate packages for API and SDK which can be installed
160-
and imported separately according to need.
156+
There are two approaches to incoporate `opentelemetry-cpp` into
157+
an external CMake project:
161158

162-
```cmake
163-
# CMakeLists.txt
164-
find_package(opentelemetry-cpp CONFIG REQUIRED)
165-
...
166-
target_include_directories(foo PRIVATE ${OPENTELEMETRY_CPP_INCLUDE_DIRS})
167-
target_link_libraries(foo PRIVATE ${OPENTELEMETRY_CPP_LIBRARIES})
168-
```
159+
1. Build and install `opentelemetry-cpp` then use `find_package`
160+
to import its targets
161+
162+
```cmake
163+
# Find all installed components and link all imported targets
164+
find_package(opentelemetry-cpp CONFIG REQUIRED)
165+
...
166+
target_include_directories(foo PRIVATE ${OPENTELEMETRY_CPP_INCLUDE_DIRS})
167+
target_link_libraries(foo PRIVATE ${OPENTELEMETRY_CPP_LIBRARIES})
168+
```
169+
170+
```cmake
171+
# Find a specific component and link its imported target(s)
172+
find_package(opentelemetry-cpp CONFIG REQUIRED COMPONENTS api)
173+
...
174+
target_link_libraries(foo PRIVATE opentelemetry-cpp::api)
175+
```
176+
177+
2. Use CMake's [FetchContent](https://cmake.org/cmake/help/latest/module/FetchContent.html)
178+
module to fetch and build `opentelemetry-cpp` then make its targets available
179+
180+
```cmake
181+
# Fetch from an existing clone and build
182+
include(FetchContent)
183+
FetchContent_Declare(opentelemetry-cpp SOURCE_DIR "<path/to/opentelemetry-cpp>")
184+
FetchContent_MakeAvailable(opentelemetry-cpp)
185+
...
186+
target_link_libraries(foo PRIVATE opentelemetry-cpp::api)
187+
```
188+
189+
```cmake
190+
# Clone and build opentelemetry-cpp from a git tag
191+
include(FetchContent)
192+
FetchContent_Declare(
193+
opentelemetry-cpp
194+
GIT_REPOSITORY https://github.com/open-telemetry/opentelemetry-cpp.git
195+
GIT_TAG v1.20.0)
196+
FetchContent_MakeAvailable(opentelemetry-cpp)
197+
...
198+
target_link_libraries(foo PRIVATE opentelemetry-cpp::api)
199+
```
200+
201+
In both cases the project's built or imported CMake targets will be
202+
available in the `opentelemetry-cpp` namespace (ie: `opentelemetry-cpp::api`)
169203

170204
#### Using opentelemetry-cpp package components
171205

@@ -187,13 +221,17 @@ target_link_libraries(foo_lib PRIVATE opentelemetry-cpp::api)
187221
# foo_app/CMakeLists.txt
188222
find_package(opentelemetry-cpp CONFIG REQUIRED COMPONENTS api sdk exporters_otlp_grpc)
189223
add_executable(foo_app main.cpp)
190-
target_link_libraries(foo_app PRIVATE foo_lib opentelemetry-cpp::api opentelemetry-cpp::sdk opentelemetry-cpp::otlp_grpc_exporter )
224+
target_link_libraries(foo_app PRIVATE foo_lib opentelemetry-cpp::api opentelemetry-cpp::trace opentelemetry-cpp::otlp_grpc_exporter )
191225
```
192226

193227
The following table provides the mapping between components and targets. Components
194228
and targets available in the installation depends on the opentelemetry-cpp package
195229
build configuration.
196230

231+
> **Note:** components `exporters_elasticsearch` and `exporters_etw`
232+
may be moved out of the core package and to `opentelemetry-cpp-contrib`
233+
in a future release
234+
197235
| Component | Targets |
198236
|----------------------------|--------------------------------------------------------------------------------------------------|
199237
| **api** | opentelemetry-cpp::api |

MODULE.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ bazel_dep(name = "abseil-cpp", version = "20240116.1", repo_name = "com_google_a
1212
bazel_dep(name = "bazel_skylib", version = "1.5.0")
1313
bazel_dep(name = "curl", version = "8.8.0")
1414
bazel_dep(name = "grpc", version = "1.63.1.bcr.1", repo_name = "com_github_grpc_grpc")
15-
bazel_dep(name = "nlohmann_json", version = "3.11.3", repo_name = "github_nlohmann_json")
16-
bazel_dep(name = "opentelemetry-proto", version = "1.5.0", repo_name = "com_github_opentelemetry_proto")
15+
bazel_dep(name = "nlohmann_json", version = "3.12.0", repo_name = "github_nlohmann_json")
16+
bazel_dep(name = "opentelemetry-proto", version = "1.6.0", repo_name = "com_github_opentelemetry_proto")
1717
bazel_dep(name = "opentracing-cpp", version = "1.6.0", repo_name = "com_github_opentracing")
1818
bazel_dep(name = "platforms", version = "0.0.8")
1919
bazel_dep(name = "prometheus-cpp", version = "1.3.0", repo_name = "com_github_jupp0r_prometheus_cpp")

api/CMakeLists.txt

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,20 @@ target_include_directories(
99

1010
set_target_properties(opentelemetry_api PROPERTIES EXPORT_NAME api)
1111

12-
if(OPENTELEMETRY_INSTALL)
13-
install(
14-
TARGETS opentelemetry_api
15-
EXPORT "${PROJECT_NAME}-api-target"
16-
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
17-
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
18-
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT api)
19-
20-
install(
21-
DIRECTORY include/opentelemetry
22-
DESTINATION include
23-
COMPONENT api
24-
FILES_MATCHING
25-
PATTERN "*.h")
26-
27-
install(
28-
EXPORT "${PROJECT_NAME}-api-target"
29-
FILE "${PROJECT_NAME}-api-target.cmake"
30-
NAMESPACE "${PROJECT_NAME}::"
31-
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
32-
COMPONENT api)
12+
otel_add_component(
13+
COMPONENT
14+
api
15+
TARGETS
16+
opentelemetry_api
17+
FILES_DIRECTORY
18+
"include/opentelemetry"
19+
FILES_DESTINATION
20+
"include"
21+
FILES_MATCHING
22+
PATTERN
23+
"*.h")
3324

25+
if(OPENTELEMETRY_INSTALL)
3426
unset(TARGET_DEPS)
3527
endif()
3628

0 commit comments

Comments
 (0)