Skip to content

Commit 1fc10b0

Browse files
authored
Merge branch 'main' into fix_lifetime_in_log_record
2 parents a3cffa7 + 25f7a13 commit 1fc10b0

File tree

297 files changed

+4104
-601
lines changed

Some content is hidden

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

297 files changed

+4104
-601
lines changed

.devcontainer/Dockerfile.dev

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright The OpenTelemetry Authors
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
FROM otel/cpp_format_tools
5+
6+
ARG GRPC_VERSION=v1.55.0
7+
ARG PROTOBUF_VERSION=23.4
8+
ARG ABSEIL_CPP_VERSION=20240116.1
9+
10+
ENV PROTOBUF_VERSION=${PROTOBUF_VERSION}
11+
ENV ABSEIL_CPP_VERSION=${ABSEIL_CPP_VERSION}
12+
13+
COPY ci /opt/ci
14+
15+
RUN apt update && apt install -y wget \
16+
ninja-build \
17+
libcurl4-openssl-dev \
18+
markdownlint
19+
20+
RUN cd /opt/ci && bash setup_cmake.sh
21+
RUN cd /opt/ci && bash setup_ci_environment.sh
22+
RUN cd /opt && bash ci/setup_googletest.sh \
23+
&& bash ci/setup_grpc.sh -r ${GRPC_VERSION}
24+
25+
ADD https://github.com/bazelbuild/bazelisk/releases/download/v1.22.1/bazelisk-linux-amd64 /usr/local/bin
26+
27+
RUN git config --global core.autocrlf input \
28+
&& chmod +x /usr/local/bin/bazelisk-linux-amd64

.devcontainer/devcontainer.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright The OpenTelemetry Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
4+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.162.0/containers/javascript-node
5+
{
6+
"name": "opentelemetry-cpp",
7+
"build": {
8+
"context": "..",
9+
"dockerfile": "Dockerfile.dev",
10+
"args": {
11+
"GRPC_VERSION": "v1.55.0",
12+
"PROTOBUF_VERSION": "23.4",
13+
"ABSEIL_CPP_VERSION":"20240116.1"
14+
}
15+
},
16+
"settings": {
17+
"terminal.integrated.shell.linux": "/bin/sh"
18+
},
19+
"extensions": [
20+
"ms-vscode.cpptools",
21+
"ms-azuretools.vscode-docker",
22+
"ms-vscode.cpptools-extension-pack"
23+
],
24+
25+
"remoteUser": "root"
26+
}

.github/dependabot.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,8 @@ updates:
66
interval: "daily"
77
labels:
88
- "GHA"
9+
10+
- package-ecosystem: "devcontainers"
11+
directory: "/"
12+
schedule:
13+
interval: daily

.github/workflows/iwyu.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ jobs:
3131
libgtest-dev \
3232
libbenchmark-dev
3333
34+
- name: setup grpc
35+
run: |
36+
sudo ./ci/setup_grpc.sh
37+
3438
- name: Prepare CMake
3539
run: |
3640
TOPDIR=`pwd`
@@ -41,12 +45,14 @@ jobs:
4145
-DCMAKE_CXX_INCLUDE_WHAT_YOU_USE="include-what-you-use;-w;-Xiwyu;--mapping_file=${TOPDIR}/.iwyu.imp;" \
4246
-DBUILD_TESTING=ON \
4347
-DBUILD_W3CTRACECONTEXT_TEST=ON \
44-
-DWITH_OTLP_GRPC=OFF \
48+
-DWITH_OTLP_GRPC=ON \
4549
-DWITH_OTLP_HTTP=ON \
4650
-DWITH_OTLP_FILE=ON \
51+
-DWITH_OPENTRACING=ON \
4752
-DWITH_OTLP_HTTP_COMPRESSION=ON \
53+
-DWITH_THREAD_INSTRUMENTATION=ON \
4854
-DWITH_ZIPKIN=ON \
49-
-DWITH_PROMETHEUS=OFF \
55+
-DWITH_PROMETHEUS=ON \
5056
..
5157
5258
- name: iwyu_tool
@@ -67,7 +73,7 @@ jobs:
6773
readonly WARNING_COUNT=`grep -c "include-what-you-use reported diagnostics:" iwyu.log`
6874
echo "include-what-you-use reported ${WARNING_COUNT} warning(s)"
6975
# Acceptable limit, to decrease over time down to 0
70-
readonly WARNING_LIMIT=180
76+
readonly WARNING_LIMIT=10
7177
# FAIL the build if WARNING_COUNT > WARNING_LIMIT
7278
if [ $WARNING_COUNT -gt $WARNING_LIMIT ] ; then
7379
exit 1

.iwyu.imp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
{ "include": ["<gtest/gtest-param-test.h>", "private", "<gtest/gtest.h>", "public"] },
2020
{ "include": ["<gtest/gtest_pred_impl.h>", "private", "<gtest/gtest.h>", "public"] },
2121
{ "include": ["<gtest/gtest-typed-test.h>", "private", "<gtest/gtest.h>", "public"] },
22+
{ "include": ["<gtest/gtest-assertion-result.h>", "private", "<gtest/gtest.h>", "public"] },
2223

2324
# We prefer to include <gmock/gmock.h> for simplicity
2425
{ "include": ["<gmock/gmock-function-mocker.h>", "private", "<gmock/gmock.h>", "public"] },

CHANGELOG.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,75 @@ Increment the:
2424
* [EXPORTER] Fix scope attributes missing from otlp traces metrics
2525
[#3185](https://github.com/open-telemetry/opentelemetry-cpp/pull/3185)
2626

27+
* [EXPORTER] Fix throw in OtlpGrpcMetricExporter with shared grpc client
28+
[#3243](https://github.com/open-telemetry/opentelemetry-cpp/pull/3243)
29+
30+
* [SDK] Better control of threads executed by opentelemetry-cpp
31+
[#3175](https://github.com/open-telemetry/opentelemetry-cpp/pull/3175)
32+
33+
* [SDK] Enable deriving from ResourceDetector to create a Resource
34+
[#3247](https://github.com/open-telemetry/opentelemetry-cpp/pull/3247)
35+
36+
* [EXPORTER] Support handling retry-able errors for OTLP/HTTP
37+
[#3223](https://github.com/open-telemetry/opentelemetry-cpp/pull/3223)
38+
39+
New features:
40+
41+
* [SDK] Better control of threads executed by opentelemetry-cpp
42+
[#3175](https://github.com/open-telemetry/opentelemetry-cpp/pull/3175)
43+
44+
* This feature provides a way for applications,
45+
when configuring the SDK and exporters,
46+
to participate in the execution path
47+
of internal opentelemetry-cpp threads.
48+
49+
* The opentelemetry-cpp library provides the following:
50+
51+
* a new ThreadInstrumentation interface,
52+
* new runtime options structures, to optionally configure the SDK:
53+
* BatchSpanProcessorRuntimeOptions
54+
* PeriodicExportingMetricReaderRuntimeOptions
55+
* BatchLogRecordProcessorRuntimeOptions
56+
* new runtime options structures,
57+
to optionally configure the OTLP HTTP exporters:
58+
* OtlpHttpExporterRuntimeOptions
59+
* OtlpHttpMetricExporterRuntimeOptions
60+
* OtlpHttpLogRecordExporterRuntimeOptions
61+
* new ThreadInstrumentation parameters,
62+
to optionally configure the CURL HttpClient
63+
* new runtime options structures,
64+
to optionally configure the OTLP FILE exporters:
65+
* OtlpFileExporterRuntimeOptions
66+
* OtlpFileMetricExporterRuntimeOptions
67+
* OtlpFileLogRecordExporterRuntimeOptions
68+
* new runtime options structure,
69+
to optionally configure the OTLP FILE client:
70+
* OtlpFileClientRuntimeOptions
71+
72+
* Using the optional runtime options structures,
73+
an application can subclass the ThreadInstrumentation interface,
74+
and be notified of specific events of interest during the execution
75+
of an internal opentelemetry-cpp thread.
76+
77+
* This allows an application to call, for example:
78+
79+
* pthread_setaffinity_np(), for better performances,
80+
* setns(), to control the network namespace used by HTTP CURL connections
81+
* pthread_setname_np(), for better observability from the operating system
82+
* many more specific apis, as needed
83+
84+
* See the documentation for ThreadInstrumentation for details.
85+
86+
* A new example program, example_otlp_instrumented_http,
87+
shows how to use the feature,
88+
and add application logic in the thread execution code path.
89+
90+
* Note that this feature is experimental,
91+
protected by a WITH_THREAD_INSTRUMENTATION_PREVIEW
92+
flag in CMake. Various runtime options structures,
93+
as well as the thread instrumentation interface,
94+
may change without notice before this feature is declared stable.
95+
2796
## [1.18 2024-11-25]
2897

2998
* [EXPORTER] Fix crash in ElasticsearchLogRecordExporter

CMakeLists.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,9 @@ if(NOT WITH_STL STREQUAL "OFF")
212212
endif()
213213
endif()
214214

215+
option(WITH_OTLP_RETRY_PREVIEW
216+
"Whether to enable experimental retry functionality" OFF)
217+
215218
option(WITH_OTLP_GRPC_SSL_MTLS_PREVIEW
216219
"Whether to enable mTLS support fro gRPC" OFF)
217220

@@ -300,6 +303,10 @@ option(WITH_ASYNC_EXPORT_PREVIEW "Whether to enable async export" OFF)
300303
option(WITH_METRICS_EXEMPLAR_PREVIEW
301304
"Whether to enable exemplar within metrics" OFF)
302305

306+
# Experimental, so behind feature flag by default
307+
option(WITH_THREAD_INSTRUMENTATION_PREVIEW
308+
"Whether to enable thread instrumentation" OFF)
309+
303310
option(OPENTELEMETRY_SKIP_DYNAMIC_LOADING_TESTS
304311
"Whether to build test libraries that are always linked as shared libs"
305312
OFF)
@@ -365,11 +372,16 @@ if(WITH_PROMETHEUS)
365372
if(EXISTS ${PROJECT_SOURCE_DIR}/third_party/prometheus-cpp/.git)
366373
set(SAVED_ENABLE_TESTING ${ENABLE_TESTING})
367374
set(SAVED_CMAKE_CXX_CLANG_TIDY ${CMAKE_CXX_CLANG_TIDY})
375+
set(SAVED_CMAKE_CXX_INCLUDE_WHAT_YOU_USE
376+
${CMAKE_CXX_INCLUDE_WHAT_YOU_USE})
368377
set(ENABLE_TESTING OFF)
369378
set(CMAKE_CXX_CLANG_TIDY "")
379+
set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE "")
370380
add_subdirectory(third_party/prometheus-cpp)
371381
set(ENABLE_TESTING ${SAVED_ENABLE_TESTING})
372382
set(CMAKE_CXX_CLANG_TIDY ${SAVED_CMAKE_CXX_CLANG_TIDY})
383+
set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE
384+
${SAVED_CMAKE_CXX_INCLUDE_WHAT_YOU_USE})
373385
else()
374386
message(
375387
FATAL_ERROR
@@ -711,8 +723,13 @@ if(WITH_OPENTRACING)
711723
if(EXISTS "${PROJECT_SOURCE_DIR}/${OPENTRACING_DIR}/.git")
712724
set(SAVED_BUILD_TESTING ${BUILD_TESTING})
713725
set(BUILD_TESTING OFF)
726+
set(SAVED_CMAKE_CXX_INCLUDE_WHAT_YOU_USE
727+
${CMAKE_CXX_INCLUDE_WHAT_YOU_USE})
728+
set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE "")
714729
add_subdirectory(${OPENTRACING_DIR})
715730
set(BUILD_TESTING ${SAVED_BUILD_TESTING})
731+
set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE
732+
${SAVED_CMAKE_CXX_INCLUDE_WHAT_YOU_USE})
716733
else()
717734
message(
718735
FATAL_ERROR

CONTRIBUTING.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,91 @@ bazel build //examples/simple:example_simple
6060
bazel-bin/examples/simple/example_simple
6161
```
6262

63+
### DevContainer Setup for Project
64+
65+
This guide provides instructions on how to set up and use the development
66+
container (`devcontainer`) environment to streamline testing and development
67+
for this project. With the DevContainer, you can work in a consistent environment
68+
configured with all the necessary dependencies and tools.
69+
70+
#### Prerequisites
71+
72+
Before getting started, ensure you have the following installed:
73+
74+
* **Docker**: DevContainers require Docker for containerization.
75+
* **Visual Studio Code (VSCode)** with the **Remote - Containers** extension.
76+
77+
#### Getting Started
78+
79+
* **Open the Project in DevContainer**:
80+
81+
Open the project in VSCode. When prompted to "Reopen in Container," select
82+
this option. If you’re not prompted, you can manually open the container by
83+
selecting **Remote-Containers: Reopen in Container** from the command palette
84+
(`F1` or `Ctrl+Shift+P`).
85+
86+
* **Container Setup**:
87+
88+
The DevContainer environment will automatically build based on the configuration
89+
files provided (e.g., `.devcontainer/devcontainer.json`). This setup will install
90+
required dependencies, tools, and environment variables needed for the project.
91+
92+
#### Available Commands
93+
94+
Once inside the DevContainer, you can use the following commands to run tests
95+
and CI workflows.
96+
97+
##### 1. Run Tests with Bazelisk
98+
99+
To run tests with Bazelisk using specific compilation options, use:
100+
101+
```bash
102+
bazelisk-linux-amd64 test --copt=-DENABLE_LOGS_PREVIEW
103+
--test_output=errors --cache_test_results=no --copt=-DENABLE_TEST //exporters/otlp/...
104+
```
105+
106+
###### Command Breakdown
107+
108+
* `--copt=-DENABLE_LOGS_PREVIEW`: Enables preview logs.
109+
* `--test_output=errors`: Shows only the errors in the test output.
110+
* `--cache_test_results=no`: Forces Bazel to re-run tests without caching.
111+
* `--copt=-DENABLE_TEST`: Enables testing capabilities for the target code.
112+
* `//exporters/otlp/...`: Specifies the test target path.
113+
114+
##### 2. Run CI Script
115+
116+
You can also run the CI script provided to perform testing with the
117+
following command as an
118+
example:
119+
120+
```bash
121+
bash ci/do_ci.sh cmake.exporter.otprotocol.test
122+
```
123+
124+
This command initiates the CI pipeline, executing tests specifically for the
125+
**cmake.exporter.otprotocol** module.
126+
127+
#### Troubleshooting
128+
129+
If you encounter issues:
130+
131+
* **Rebuild the DevContainer**: From the command palette, run
132+
**Remote-Containers: Rebuild Container** to reinitialize the environment.
133+
* **Check Bazelisk and CI Script Logs**: Inspect logs for any configuration or
134+
dependency issues.
135+
136+
#### Additional Notes
137+
138+
* You can adjust compiler options (`--copt`) as needed to test additional flags
139+
or enable/disable specific features.
140+
* The test results will be displayed in the terminal within the DevContainer for
141+
easy debugging.
142+
143+
#### Resources
144+
145+
* **Bazelisk Documentation**: [https://github.com/bazelbuild/bazelisk](https://github.com/bazelbuild/bazelisk)
146+
* **VSCode DevContainer Documentation**: [https://code.visualstudio.com/docs/remote/containers](https://code.visualstudio.com/docs/remote/containers)
147+
63148
## Pull Requests
64149

65150
### How to Send Pull Requests

api/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ target_compile_definitions(
116116
opentelemetry_api
117117
INTERFACE OPENTELEMETRY_ABI_VERSION_NO=${OPENTELEMETRY_ABI_VERSION_NO})
118118

119+
if(WITH_OTLP_RETRY_PREVIEW)
120+
target_compile_definitions(opentelemetry_api
121+
INTERFACE ENABLE_OTLP_RETRY_PREVIEW)
122+
endif()
123+
119124
if(WITH_OTLP_GRPC_SSL_MTLS_PREVIEW)
120125
target_compile_definitions(opentelemetry_api
121126
INTERFACE ENABLE_OTLP_GRPC_SSL_MTLS_PREVIEW)
@@ -126,6 +131,11 @@ if(WITH_METRICS_EXEMPLAR_PREVIEW)
126131
INTERFACE ENABLE_METRICS_EXEMPLAR_PREVIEW)
127132
endif()
128133

134+
if(WITH_THREAD_INSTRUMENTATION_PREVIEW)
135+
target_compile_definitions(opentelemetry_api
136+
INTERFACE ENABLE_THREAD_INSTRUMENTATION_PREVIEW)
137+
endif()
138+
129139
if(WITH_OTLP_HTTP_COMPRESSION)
130140
target_compile_definitions(opentelemetry_api
131141
INTERFACE ENABLE_OTLP_COMPRESSION_PREVIEW)

api/include/opentelemetry/logs/severity.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
#pragma once
55

6+
#include <cstdint>
7+
68
#include "opentelemetry/nostd/string_view.h"
79
#include "opentelemetry/version.h"
810

0 commit comments

Comments
 (0)