Skip to content

Commit

Permalink
Merge pull request #323 from open-telemetry/main
Browse files Browse the repository at this point in the history
[pull] main from open-telemetry:main
  • Loading branch information
lalitb authored Jan 22, 2025
2 parents 95baed7 + 031307b commit 7bba715
Show file tree
Hide file tree
Showing 54 changed files with 1,876 additions and 143 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
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ jobs:
sudo -E ./ci/setup_googletest.sh
sudo -E ./ci/setup_ci_environment.sh
sudo -E ./ci/install_protobuf.sh
- name: setup grpc
run: |
sudo ./ci/setup_grpc.sh
- name: run cmake gcc (maintainer mode, sync)
env:
CC: /usr/bin/gcc-14
Expand Down Expand Up @@ -111,6 +114,9 @@ jobs:
sudo -E ./ci/setup_googletest.sh
sudo -E ./ci/setup_ci_environment.sh
sudo -E ./ci/install_protobuf.sh
- name: setup grpc
run: |
sudo ./ci/setup_grpc.sh
- name: run cmake gcc (maintainer mode, async)
env:
CC: /usr/bin/gcc-14
Expand Down Expand Up @@ -144,6 +150,9 @@ jobs:
sudo -E ./ci/setup_googletest.sh
sudo -E ./ci/setup_ci_environment.sh
sudo -E ./ci/install_protobuf.sh
- name: setup grpc
run: |
sudo ./ci/setup_grpc.sh
- name: run cmake clang (maintainer mode, sync)
env:
CC: /usr/bin/clang-18
Expand Down Expand Up @@ -177,6 +186,9 @@ jobs:
sudo -E ./ci/setup_googletest.sh
sudo -E ./ci/setup_ci_environment.sh
sudo -E ./ci/install_protobuf.sh
- name: setup grpc
run: |
sudo ./ci/setup_grpc.sh
- name: run cmake clang (maintainer mode, async)
env:
CC: /usr/bin/clang-18
Expand Down Expand Up @@ -210,6 +222,9 @@ jobs:
sudo -E ./ci/setup_googletest.sh
sudo -E ./ci/setup_ci_environment.sh
sudo -E ./ci/install_protobuf.sh
- name: setup grpc
run: |
sudo ./ci/setup_grpc.sh
- name: run cmake clang (maintainer mode, abiv2)
env:
CC: /usr/bin/clang-18
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ Increment the:
* [SDK] Better control of threads executed by opentelemetry-cpp
[#3175](https://github.com/open-telemetry/opentelemetry-cpp/pull/3175)

* [SDK] Enable deriving from ResourceDetector to create a Resource
[#3247](https://github.com/open-telemetry/opentelemetry-cpp/pull/3247)

* [EXPORTER] Support handling retry-able errors for OTLP/HTTP
[#3223](https://github.com/open-telemetry/opentelemetry-cpp/pull/3223)

* [EXPORTER] Support handling retry-able errors for OTLP/gRPC
[#3219](https://github.com/open-telemetry/opentelemetry-cpp/pull/3219)

New features:

* [SDK] Better control of threads executed by opentelemetry-cpp
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ if(NOT WITH_STL STREQUAL "OFF")
endif()
endif()

option(WITH_OTLP_RETRY_PREVIEW
"Whether to enable experimental retry functionality" OFF)

option(WITH_OTLP_GRPC_SSL_MTLS_PREVIEW
"Whether to enable mTLS support fro gRPC" OFF)

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 @@ -116,6 +116,11 @@ target_compile_definitions(
opentelemetry_api
INTERFACE OPENTELEMETRY_ABI_VERSION_NO=${OPENTELEMETRY_ABI_VERSION_NO})

if(WITH_OTLP_RETRY_PREVIEW)
target_compile_definitions(opentelemetry_api
INTERFACE ENABLE_OTLP_RETRY_PREVIEW)
endif()

if(WITH_OTLP_GRPC_SSL_MTLS_PREVIEW)
target_compile_definitions(opentelemetry_api
INTERFACE ENABLE_OTLP_GRPC_SSL_MTLS_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
8 changes: 8 additions & 0 deletions ci/do_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ elif [[ "$1" == "cmake.maintainer.sync.test" ]]; then
rm -rf *
cmake "${CMAKE_OPTIONS[@]}" \
-DWITH_OTLP_HTTP=ON \
-DWITH_OTLP_GRPC=ON \
-DWITH_OTLP_FILE=ON \
-DWITH_PROMETHEUS=ON \
-DWITH_EXAMPLES=ON \
Expand All @@ -120,6 +121,7 @@ elif [[ "$1" == "cmake.maintainer.sync.test" ]]; then
-DOTELCPP_MAINTAINER_MODE=ON \
-DWITH_NO_DEPRECATED_CODE=ON \
-DWITH_OTLP_HTTP_COMPRESSION=ON \
-DWITH_OTLP_RETRY_PREVIEW=ON \
-DWITH_THREAD_INSTRUMENTATION_PREVIEW=ON \
"${SRC_DIR}"
eval "$MAKE_COMMAND"
Expand All @@ -130,6 +132,7 @@ elif [[ "$1" == "cmake.maintainer.async.test" ]]; then
rm -rf *
cmake "${CMAKE_OPTIONS[@]}" \
-DWITH_OTLP_HTTP=ON \
-DWITH_OTLP_GRPC=ON \
-DWITH_OTLP_FILE=ON \
-DWITH_PROMETHEUS=ON \
-DWITH_EXAMPLES=ON \
Expand All @@ -142,6 +145,7 @@ elif [[ "$1" == "cmake.maintainer.async.test" ]]; then
-DOTELCPP_MAINTAINER_MODE=ON \
-DWITH_NO_DEPRECATED_CODE=ON \
-DWITH_OTLP_HTTP_COMPRESSION=ON \
-DWITH_OTLP_RETRY_PREVIEW=ON \
-DWITH_THREAD_INSTRUMENTATION_PREVIEW=ON \
"${SRC_DIR}"
eval "$MAKE_COMMAND"
Expand All @@ -165,6 +169,7 @@ elif [[ "$1" == "cmake.maintainer.cpp11.async.test" ]]; then
-DOTELCPP_MAINTAINER_MODE=ON \
-DWITH_NO_DEPRECATED_CODE=ON \
-DWITH_OTLP_HTTP_COMPRESSION=ON \
-DWITH_OTLP_RETRY_PREVIEW=ON \
-DWITH_THREAD_INSTRUMENTATION_PREVIEW=ON \
"${SRC_DIR}"
make -k -j $(nproc)
Expand All @@ -175,6 +180,7 @@ elif [[ "$1" == "cmake.maintainer.abiv2.test" ]]; then
rm -rf *
cmake "${CMAKE_OPTIONS[@]}" \
-DWITH_OTLP_HTTP=ON \
-DWITH_OTLP_GRPC=ON \
-DWITH_OTLP_FILE=ON \
-DWITH_PROMETHEUS=ON \
-DWITH_EXAMPLES=ON \
Expand All @@ -189,6 +195,7 @@ elif [[ "$1" == "cmake.maintainer.abiv2.test" ]]; then
-DWITH_ABI_VERSION_1=OFF \
-DWITH_ABI_VERSION_2=ON \
-DWITH_OTLP_HTTP_COMPRESSION=ON \
-DWITH_OTLP_RETRY_PREVIEW=ON \
-DWITH_THREAD_INSTRUMENTATION_PREVIEW=ON \
"${SRC_DIR}"
eval "$MAKE_COMMAND"
Expand Down Expand Up @@ -340,6 +347,7 @@ elif [[ "$1" == "cmake.exporter.otprotocol.test" ]]; then
-DWITH_OTLP_HTTP=ON \
-DWITH_OTLP_FILE=ON \
-DWITH_OTLP_GRPC_SSL_MTLS_PREVIEW=ON \
-DWITH_OTLP_RETRY_PREVIEW=ON \
"${SRC_DIR}"
grpc_cpp_plugin=`which grpc_cpp_plugin`
proto_make_file="CMakeFiles/opentelemetry_proto.dir/build.make"
Expand Down
2 changes: 1 addition & 1 deletion ci/run_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set -e

BUILD_IMAGE=opentelemetry-cpp-build
docker image inspect "$BUILD_IMAGE" &> /dev/null || {
docker build -t "$BUILD_IMAGE" ci
docker build -t "$BUILD_IMAGE" -f .devcontainer/Dockerfile.dev .
}

if [[ $# -ge 1 ]]; then
Expand Down
2 changes: 1 addition & 1 deletion exporters/otlp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ if(BUILD_TESTING)
add_executable(otlp_grpc_exporter_test test/otlp_grpc_exporter_test.cc)
target_link_libraries(
otlp_grpc_exporter_test ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}
${GMOCK_LIB} opentelemetry_exporter_otlp_grpc)
${GMOCK_LIB} opentelemetry_exporter_otlp_grpc gRPC::grpc++)
gtest_add_tests(
TARGET otlp_grpc_exporter_test
TEST_PREFIX exporter.otlp.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,22 @@ std::string GetOtlpDefaultTracesCompression();
std::string GetOtlpDefaultMetricsCompression();
std::string GetOtlpDefaultLogsCompression();

std::uint32_t GetOtlpDefaultTracesRetryMaxAttempts();
std::uint32_t GetOtlpDefaultMetricsRetryMaxAttempts();
std::uint32_t GetOtlpDefaultLogsRetryMaxAttempts();

std::chrono::duration<float> GetOtlpDefaultTracesRetryInitialBackoff();
std::chrono::duration<float> GetOtlpDefaultMetricsRetryInitialBackoff();
std::chrono::duration<float> GetOtlpDefaultLogsRetryInitialBackoff();

std::chrono::duration<float> GetOtlpDefaultTracesRetryMaxBackoff();
std::chrono::duration<float> GetOtlpDefaultMetricsRetryMaxBackoff();
std::chrono::duration<float> GetOtlpDefaultLogsRetryMaxBackoff();

float GetOtlpDefaultTracesRetryBackoffMultiplier();
float GetOtlpDefaultMetricsRetryBackoffMultiplier();
float GetOtlpDefaultLogsRetryBackoffMultiplier();

} // namespace otlp
} // namespace exporter
OPENTELEMETRY_END_NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,18 @@ struct OtlpGrpcClientOptions
// Concurrent requests
std::size_t max_concurrent_requests;
#endif

/** The maximum number of call attempts, including the original attempt. */
std::uint32_t retry_policy_max_attempts{};

/** The initial backoff delay between retry attempts, random between (0, initial_backoff). */
std::chrono::duration<float> retry_policy_initial_backoff{};

/** The maximum backoff places an upper limit on exponential backoff growth. */
std::chrono::duration<float> retry_policy_max_backoff{};

/** The backoff will be multiplied by this value after each retry attempt. */
float retry_policy_backoff_multiplier{};
};

} // namespace otlp
Expand Down
Loading

0 comments on commit 7bba715

Please sign in to comment.