Skip to content

Commit

Permalink
Merge branch 'main' into fix_resource_detector_access
Browse files Browse the repository at this point in the history
  • Loading branch information
dbarker authored Jan 16, 2025
2 parents 3c9a37c + 465cb4a commit 6b92e07
Show file tree
Hide file tree
Showing 118 changed files with 2,609 additions and 284 deletions.
28 changes: 28 additions & 0 deletions .devcontainer/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

FROM otel/cpp_format_tools

ARG GRPC_VERSION=v1.55.0
ARG PROTOBUF_VERSION=23.4
ARG ABSEIL_CPP_VERSION=20240116.1

ENV PROTOBUF_VERSION=${PROTOBUF_VERSION}
ENV ABSEIL_CPP_VERSION=${ABSEIL_CPP_VERSION}

COPY ci /opt/ci

RUN apt update && apt install -y wget \
ninja-build \
libcurl4-openssl-dev \
markdownlint

RUN cd /opt/ci && bash setup_cmake.sh
RUN cd /opt/ci && bash setup_ci_environment.sh
RUN cd /opt && bash ci/setup_googletest.sh \
&& bash ci/setup_grpc.sh -r ${GRPC_VERSION}

ADD https://github.com/bazelbuild/bazelisk/releases/download/v1.22.1/bazelisk-linux-amd64 /usr/local/bin

RUN git config --global core.autocrlf input \
&& chmod +x /usr/local/bin/bazelisk-linux-amd64
26 changes: 26 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.162.0/containers/javascript-node
{
"name": "opentelemetry-cpp",
"build": {
"context": "..",
"dockerfile": "Dockerfile.dev",
"args": {
"GRPC_VERSION": "v1.55.0",
"PROTOBUF_VERSION": "23.4",
"ABSEIL_CPP_VERSION":"20240116.1"
}
},
"settings": {
"terminal.integrated.shell.linux": "/bin/sh"
},
"extensions": [
"ms-vscode.cpptools",
"ms-azuretools.vscode-docker",
"ms-vscode.cpptools-extension-pack"
],

"remoteUser": "root"
}
5 changes: 5 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ updates:
interval: "daily"
labels:
- "GHA"

- package-ecosystem: "devcontainers"
directory: "/"
schedule:
interval: daily
12 changes: 9 additions & 3 deletions .github/workflows/iwyu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ jobs:
libgtest-dev \
libbenchmark-dev
- name: setup grpc
run: |
sudo ./ci/setup_grpc.sh
- name: Prepare CMake
run: |
TOPDIR=`pwd`
Expand All @@ -41,12 +45,14 @@ jobs:
-DCMAKE_CXX_INCLUDE_WHAT_YOU_USE="include-what-you-use;-w;-Xiwyu;--mapping_file=${TOPDIR}/.iwyu.imp;" \
-DBUILD_TESTING=ON \
-DBUILD_W3CTRACECONTEXT_TEST=ON \
-DWITH_OTLP_GRPC=OFF \
-DWITH_OTLP_GRPC=ON \
-DWITH_OTLP_HTTP=ON \
-DWITH_OTLP_FILE=ON \
-DWITH_OPENTRACING=ON \
-DWITH_OTLP_HTTP_COMPRESSION=ON \
-DWITH_THREAD_INSTRUMENTATION=ON \
-DWITH_ZIPKIN=ON \
-DWITH_PROMETHEUS=OFF \
-DWITH_PROMETHEUS=ON \
..
- name: iwyu_tool
Expand All @@ -67,7 +73,7 @@ jobs:
readonly WARNING_COUNT=`grep -c "include-what-you-use reported diagnostics:" iwyu.log`
echo "include-what-you-use reported ${WARNING_COUNT} warning(s)"
# Acceptable limit, to decrease over time down to 0
readonly WARNING_LIMIT=180
readonly WARNING_LIMIT=10
# FAIL the build if WARNING_COUNT > WARNING_LIMIT
if [ $WARNING_COUNT -gt $WARNING_LIMIT ] ; then
exit 1
Expand Down
63 changes: 63 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,69 @@ Increment the:
* [EXPORTER] Fix scope attributes missing from otlp traces metrics
[#3185](https://github.com/open-telemetry/opentelemetry-cpp/pull/3185)

* [EXPORTER] Fix throw in OtlpGrpcMetricExporter with shared grpc client
[#3243](https://github.com/open-telemetry/opentelemetry-cpp/pull/3243)

* [SDK] Better control of threads executed by opentelemetry-cpp
[#3175](https://github.com/open-telemetry/opentelemetry-cpp/pull/3175)

New features:

* [SDK] Better control of threads executed by opentelemetry-cpp
[#3175](https://github.com/open-telemetry/opentelemetry-cpp/pull/3175)

* This feature provides a way for applications,
when configuring the SDK and exporters,
to participate in the execution path
of internal opentelemetry-cpp threads.

* The opentelemetry-cpp library provides the following:

* a new ThreadInstrumentation interface,
* new runtime options structures, to optionally configure the SDK:
* BatchSpanProcessorRuntimeOptions
* PeriodicExportingMetricReaderRuntimeOptions
* BatchLogRecordProcessorRuntimeOptions
* new runtime options structures,
to optionally configure the OTLP HTTP exporters:
* OtlpHttpExporterRuntimeOptions
* OtlpHttpMetricExporterRuntimeOptions
* OtlpHttpLogRecordExporterRuntimeOptions
* new ThreadInstrumentation parameters,
to optionally configure the CURL HttpClient
* new runtime options structures,
to optionally configure the OTLP FILE exporters:
* OtlpFileExporterRuntimeOptions
* OtlpFileMetricExporterRuntimeOptions
* OtlpFileLogRecordExporterRuntimeOptions
* new runtime options structure,
to optionally configure the OTLP FILE client:
* OtlpFileClientRuntimeOptions

* Using the optional runtime options structures,
an application can subclass the ThreadInstrumentation interface,
and be notified of specific events of interest during the execution
of an internal opentelemetry-cpp thread.

* This allows an application to call, for example:

* pthread_setaffinity_np(), for better performances,
* setns(), to control the network namespace used by HTTP CURL connections
* pthread_setname_np(), for better observability from the operating system
* many more specific apis, as needed

* See the documentation for ThreadInstrumentation for details.

* A new example program, example_otlp_instrumented_http,
shows how to use the feature,
and add application logic in the thread execution code path.

* Note that this feature is experimental,
protected by a WITH_THREAD_INSTRUMENTATION_PREVIEW
flag in CMake. Various runtime options structures,
as well as the thread instrumentation interface,
may change without notice before this feature is declared stable.

## [1.18 2024-11-25]

* [EXPORTER] Fix crash in ElasticsearchLogRecordExporter
Expand Down
14 changes: 14 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,10 @@ option(WITH_ASYNC_EXPORT_PREVIEW "Whether to enable async export" OFF)
option(WITH_METRICS_EXEMPLAR_PREVIEW
"Whether to enable exemplar within metrics" OFF)

# Experimental, so behind feature flag by default
option(WITH_THREAD_INSTRUMENTATION_PREVIEW
"Whether to enable thread instrumentation" OFF)

option(OPENTELEMETRY_SKIP_DYNAMIC_LOADING_TESTS
"Whether to build test libraries that are always linked as shared libs"
OFF)
Expand Down Expand Up @@ -365,11 +369,16 @@ if(WITH_PROMETHEUS)
if(EXISTS ${PROJECT_SOURCE_DIR}/third_party/prometheus-cpp/.git)
set(SAVED_ENABLE_TESTING ${ENABLE_TESTING})
set(SAVED_CMAKE_CXX_CLANG_TIDY ${CMAKE_CXX_CLANG_TIDY})
set(SAVED_CMAKE_CXX_INCLUDE_WHAT_YOU_USE
${CMAKE_CXX_INCLUDE_WHAT_YOU_USE})
set(ENABLE_TESTING OFF)
set(CMAKE_CXX_CLANG_TIDY "")
set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE "")
add_subdirectory(third_party/prometheus-cpp)
set(ENABLE_TESTING ${SAVED_ENABLE_TESTING})
set(CMAKE_CXX_CLANG_TIDY ${SAVED_CMAKE_CXX_CLANG_TIDY})
set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE
${SAVED_CMAKE_CXX_INCLUDE_WHAT_YOU_USE})
else()
message(
FATAL_ERROR
Expand Down Expand Up @@ -711,8 +720,13 @@ if(WITH_OPENTRACING)
if(EXISTS "${PROJECT_SOURCE_DIR}/${OPENTRACING_DIR}/.git")
set(SAVED_BUILD_TESTING ${BUILD_TESTING})
set(BUILD_TESTING OFF)
set(SAVED_CMAKE_CXX_INCLUDE_WHAT_YOU_USE
${CMAKE_CXX_INCLUDE_WHAT_YOU_USE})
set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE "")
add_subdirectory(${OPENTRACING_DIR})
set(BUILD_TESTING ${SAVED_BUILD_TESTING})
set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE
${SAVED_CMAKE_CXX_INCLUDE_WHAT_YOU_USE})
else()
message(
FATAL_ERROR
Expand Down
85 changes: 85 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,91 @@ bazel build //examples/simple:example_simple
bazel-bin/examples/simple/example_simple
```

### DevContainer Setup for Project

This guide provides instructions on how to set up and use the development
container (`devcontainer`) environment to streamline testing and development
for this project. With the DevContainer, you can work in a consistent environment
configured with all the necessary dependencies and tools.

#### Prerequisites

Before getting started, ensure you have the following installed:

* **Docker**: DevContainers require Docker for containerization.
* **Visual Studio Code (VSCode)** with the **Remote - Containers** extension.

#### Getting Started

* **Open the Project in DevContainer**:

Open the project in VSCode. When prompted to "Reopen in Container," select
this option. If you’re not prompted, you can manually open the container by
selecting **Remote-Containers: Reopen in Container** from the command palette
(`F1` or `Ctrl+Shift+P`).

* **Container Setup**:

The DevContainer environment will automatically build based on the configuration
files provided (e.g., `.devcontainer/devcontainer.json`). This setup will install
required dependencies, tools, and environment variables needed for the project.

#### Available Commands

Once inside the DevContainer, you can use the following commands to run tests
and CI workflows.

##### 1. Run Tests with Bazelisk

To run tests with Bazelisk using specific compilation options, use:

```bash
bazelisk-linux-amd64 test --copt=-DENABLE_LOGS_PREVIEW
--test_output=errors --cache_test_results=no --copt=-DENABLE_TEST //exporters/otlp/...
```

###### Command Breakdown

* `--copt=-DENABLE_LOGS_PREVIEW`: Enables preview logs.
* `--test_output=errors`: Shows only the errors in the test output.
* `--cache_test_results=no`: Forces Bazel to re-run tests without caching.
* `--copt=-DENABLE_TEST`: Enables testing capabilities for the target code.
* `//exporters/otlp/...`: Specifies the test target path.

##### 2. Run CI Script

You can also run the CI script provided to perform testing with the
following command as an
example:

```bash
bash ci/do_ci.sh cmake.exporter.otprotocol.test
```

This command initiates the CI pipeline, executing tests specifically for the
**cmake.exporter.otprotocol** module.

#### Troubleshooting

If you encounter issues:

* **Rebuild the DevContainer**: From the command palette, run
**Remote-Containers: Rebuild Container** to reinitialize the environment.
* **Check Bazelisk and CI Script Logs**: Inspect logs for any configuration or
dependency issues.

#### Additional Notes

* You can adjust compiler options (`--copt`) as needed to test additional flags
or enable/disable specific features.
* The test results will be displayed in the terminal within the DevContainer for
easy debugging.

#### Resources

* **Bazelisk Documentation**: [https://github.com/bazelbuild/bazelisk](https://github.com/bazelbuild/bazelisk)
* **VSCode DevContainer Documentation**: [https://code.visualstudio.com/docs/remote/containers](https://code.visualstudio.com/docs/remote/containers)

## Pull Requests

### How to Send Pull Requests
Expand Down
5 changes: 5 additions & 0 deletions api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ if(WITH_METRICS_EXEMPLAR_PREVIEW)
INTERFACE ENABLE_METRICS_EXEMPLAR_PREVIEW)
endif()

if(WITH_THREAD_INSTRUMENTATION_PREVIEW)
target_compile_definitions(opentelemetry_api
INTERFACE ENABLE_THREAD_INSTRUMENTATION_PREVIEW)
endif()

if(WITH_OTLP_HTTP_COMPRESSION)
target_compile_definitions(opentelemetry_api
INTERFACE ENABLE_OTLP_COMPRESSION_PREVIEW)
Expand Down
5 changes: 4 additions & 1 deletion ci/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Building and running tests as a developer

CI tests can be run on docker by invoking the script `./ci/run_docker.sh
./ci/do_ci.sh {TARGET}` where the targets are:
./ci/do_ci.sh {TARGET}`or inside
[devcontainer](../CONTRIBUTING.md#devcontainer-setup-for-project)
by invoking the script
`./ci/do_ci.sh {TARGET}` where the targets are:

* `cmake.test`: build cmake targets and run tests.
* `cmake.maintainer.test`: build with cmake and test, in maintainer mode.
Expand Down
Loading

0 comments on commit 6b92e07

Please sign in to comment.