Skip to content

Commit 2e07267

Browse files
authored
Merge branch 'main' into fix/doc_comment_api
2 parents 00a4b13 + 29ac517 commit 2e07267

File tree

98 files changed

+3766
-2160
lines changed

Some content is hidden

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

98 files changed

+3766
-2160
lines changed

.github/workflows/ci.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,28 @@ 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+
steps:
66+
- name: Harden the runner (Audit all outbound calls)
67+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
68+
with:
69+
egress-policy: audit
70+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
71+
with:
72+
submodules: 'recursive'
73+
- name: setup
74+
run: |
75+
sudo -E ./ci/setup_ci_environment.sh
76+
sudo -E ./ci/setup_cmake.sh
77+
sudo -E ./ci/setup_googletest.sh
78+
- name: run fetch content cmake test
79+
run: |
80+
./ci/do_ci.sh cmake.fetch_content.test
81+
6082
cmake_gcc_maintainer_sync_test:
6183
name: CMake gcc 14 (maintainer mode, sync)
6284
runs-on: ubuntu-24.04
@@ -1104,7 +1126,7 @@ jobs:
11041126
CXX: /usr/bin/g++-10
11051127
run: ./ci/do_ci.sh code.coverage
11061128
- name: upload report
1107-
uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d # v5.4.2
1129+
uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3
11081130
with:
11091131
files: /home/runner/build/coverage.info
11101132

.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@60168efe1c415ce0f5521ea06d5c2062adbeed1b # v3.28.17
42+
uses: github/codeql-action/init@ff0a06e83cb2de871e5a09832bc6a81e7276941f # v3.28.18
4343
with:
4444
languages: cpp
4545
- name: Autobuild
46-
uses: github/codeql-action/autobuild@60168efe1c415ce0f5521ea06d5c2062adbeed1b # v3.28.17
46+
uses: github/codeql-action/autobuild@ff0a06e83cb2de871e5a09832bc6a81e7276941f # v3.28.18
4747
- name: Perform CodeQL Analysis
48-
uses: github/codeql-action/analyze@60168efe1c415ce0f5521ea06d5c2062adbeed1b # v3.28.17
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@60168efe1c415ce0f5521ea06d5c2062adbeed1b # v3.28.17
50+
uses: github/codeql-action/upload-sarif@ff0a06e83cb2de871e5a09832bc6a81e7276941f # v3.28.18
5151
with:
5252
sarif_file: results.sarif

CHANGELOG.md

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

1616
## [Unreleased]
1717

18+
* [Metrics SDK] Use nostd::function_ref in AttributesHashMap
19+
[#3393](https://github.com/open-telemetry/opentelemetry-cpp/pull/3393)
20+
1821
* [SDK] Base2 exponential histogram aggregation
1922
[#3175](https://github.com/open-telemetry/opentelemetry-cpp/pull/3346)
2023

@@ -36,6 +39,22 @@ Increment the:
3639
* [SDK] Optimize PeriodicExportingMetricReader thread usage
3740
[#3383](https://github.com/open-telemetry/opentelemetry-cpp/pull/3383)
3841

42+
* [SDK] Aggregate identical metrics instruments and detect duplicates
43+
[#3358](https://github.com/open-telemetry/opentelemetry-cpp/pull/3358)
44+
45+
* [INSTALL] Add CMake components to the opentelemetry-cpp package
46+
[#3320](https://github.com/open-telemetry/opentelemetry-cpp/pull/3220)
47+
[#3368](https://github.com/open-telemetry/opentelemetry-cpp/pull/3368)
48+
49+
* [BUILD] Upgrade opentelemetry-proto to 1.6.0
50+
[#3407](https://github.com/open-telemetry/opentelemetry-cpp/pull/3407)
51+
52+
* [BUILD] Upgrade nlohmann_json to 3.12.0
53+
[#3406](https://github.com/open-telemetry/opentelemetry-cpp/pull/3406)
54+
55+
* [CMAKE] Add generated protobuf headers to the opentelemetry_proto target
56+
[#3400](https://github.com/open-telemetry/opentelemetry-cpp/pull/3400)
57+
3958
## [1.20 2025-04-01]
4059

4160
* [BUILD] Update opentelemetry-proto version

CMakeLists.txt

Lines changed: 10 additions & 33 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)
@@ -922,39 +924,14 @@ include(cmake/opentelemetry-build-external-component.cmake)
922924
include(cmake/patch-imported-config.cmake)
923925

924926
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)
927+
# Install the cmake config and version files
928+
otel_install_cmake_config()
929+
930+
# Install the components and associated files
931+
otel_install_components()
932+
933+
# Install the thirdparty dependency definition file
934+
otel_install_thirdparty_definitions()
958935

959936
if(BUILD_PACKAGE)
960937
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)