The OpenTelemetry C/C++ special interest group (SIG) meets regularly. See the OpenTelemetry community repo for information on this and other language SIGs.
See the public meeting notes for a summary description of past meetings. To request edit access, join the meeting or get in touch on Slack.
See the community membership document on how to become a Member, Approver and Maintainer.
OpenTelemetry C++ uses the Google naming convention.
Code is formatted automatically and enforced by CI.
Note: these instructions apply to examples configured with Bazel, see example-specific documentation for other build automation tools.
Install the latest bazel version by following the steps listed here.
Select an example of interest from the examples
folder.
Inside each example directory is a BUILD file containing instructions for
Bazel. Find the binary name of your example by inspecting the contents of this
BUILD file.
Build the example from the root of the opentelemetry-cpp directory using Bazel.
Replace <binary name> with the identifier found in the previous step:
bazel build //examples/<example directory name>:<binary name>
Run the resulting executable to see telemetry from the application as it calls the instrumented library:
bazel-bin/examples/<example directory name>/<binary name>
For instance, building and running the simple example can be done as follows:
bazel build //examples/simple:example_simple
bazel-bin/examples/simple/example_simple
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.
Before getting started, ensure you have the following installed:
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).
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.
.devcontainer/README.md for devcontainer configuration options.Once inside the DevContainer, you can use the following commands to run tests and CI workflows.
To run tests with Bazelisk using specific compilation options, use:
bazelisk-linux-amd64 test --copt=-DENABLE_LOGS_PREVIEW
--test_output=errors --cache_test_results=no --copt=-DENABLE_TEST //exporters/otlp/...
--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.You can also run the CI script provided to perform testing with the following command as an example:
bash ci/do_ci.sh cmake.exporter.otprotocol.test
This command initiates the CI pipeline, executing tests specifically for the cmake.exporter.otprotocol module.
If you encounter issues:
--copt) as needed to test additional flags
or enable/disable specific features.The .devcontainer/Dockerfile.dev
dockerfile can be built directly with the following command.
docker build -t opentelemetry-cpp-dev -f ./.devcontainer/Dockerfile.dev .
You can customize the image using build arguments to match permissions with the host user.
docker build -t opentelemetry-cpp-dev \
--build-arg USER_UID="$(id -u)" \
--build-arg USER_GID="$(id -g)" \
-f ./.devcontainer/Dockerfile.dev .
Run an interactive bash session binding your host opentelemetry-cpp directory to the container's workspace:
docker run -it -v "$PWD:/workspaces/opentelemetry-cpp" opentelemetry-cpp-dev bash
Everyone is welcome to contribute code to opentelemetry-cpp via GitHub pull
requests (PRs).
To create a new PR, fork the project in GitHub and clone the upstream repo:
git clone --recursive https://github.com/open-telemetry/opentelemetry-cpp.git
Add your fork as a remote:
git remote add fork https://github.com/YOUR_GITHUB_USERNAME/opentelemetry-cpp.git
If you haven't, make sure you are loading the submodules required to build OpenTelemetry
git submodule init
git submodule update
The source code is automatically formatted using clang-format.
The output can vary between versions, so make sure to install clang-format
version 10.0, and have clang-format-10 in your execution path,
so that the helper script tools/format.sh can find it.
Check out a new branch, make modifications and push the branch to your fork:
git checkout -b feature
# edit files
tools/format.sh
git commit
git push fork feature
If you made changes to the Markdown documents (*.md files), install the latest
markdownlint-cli and run:
markdownlint .
If you modified shell scripts (*.sh files), install shellcheck and run:
shellcheck --severity=error <path to shell script>.sh
Open a pull request against the main opentelemetry-cpp repo.
To run tests locally, please read the CI instructions.
[WIP] in the title, tag it as
work-in-progress, or mark it as
draft.A PR is considered to be ready to merge when:
Any Maintainer can merge the PR once it is ready to merge. Maintainer can make conscious judgement to merge pull requests which have not strictly met above mentioned requirements.
If a PR has been stuck (e.g. there are lots of debates and people couldn't agree on each other), the owner should try to get people aligned by:
If none of the above worked and the PR has been stuck for more than 2 weeks, the owner should bring it to the OpenTelemetry C++ SIG meeting. See README.md for the meeting link.
As with other OpenTelemetry clients, opentelemetry-cpp follows the opentelemetry-specification.
It's especially valuable to read through the library guidelines.
Hi! If you’re looking at this document, these resources will provide you the knowledge to get started as a newcomer to the OpenTelemetry project. They will help you understand the OpenTelemetry Project, its components, and specifically the C++ repository.
The OpenTelemetry Specification describes the requirements and expectations of for all OpenTelemetry implementations.
Read through the OpenTelemetry C++ documentation
The API and SDK documentation provides a lot of information on what the classes and their functions are used for.
Please contribute! You’re welcome to add more information if you come across any helpful resources.