Skip to content

TeiaCare/TeiaCarePrometheus

Repository files navigation

TeiaCarePrometheus

Welcome to TeiaCarePrometheus!

TeiaCarePrometheus is a C++ client library that implements the Prometheus Data Model.

Docs Codacy Badge Codacy Badge

TeiaCarePrometheus

Getting Started

This project uses git submodules so it is required to clone it using the --recursive flag in order to retrive the required submodules.

git clone https://github.com/TeiaCare/TeiaCarePrometheus.git --recursive

This project relies on venvpp2 (included as the scripts submodule) to manage the development environment based on Conan v2 and CMake v4 with CMakePresets as first class citizens.

Create Development Environment

Run the venvpp2 setup script from the project root. It creates a .venv at the project root, pins CONAN_HOME to ./.conan2 and installs the Python requirements (Conan, CMake, Ninja, pre-commit, etc.).

# Linux/MacOS
scripts/scripts/env/setup.sh

# Windows
scripts\scripts\env\setup.bat

Start Development Environment

On subsequent sessions just re-activate the virtual environment created above.

# Linux/MacOS
source .venv/bin/activate

# Windows
.venv\Scripts\activate.bat

Setup Build Environment (Windows Only)

When building from command line on Windows it is necessary to activate the Visual Studio Developer Command Prompt.

Depending on the version of Visual Studio compiler and on its install location it is required to run vcvars64.bat script the set the development environment properly.

Note: using Visual Studio IDE or the CMake extension for VSCode this step is already managed in the background, so no action is required.

Examples:

# Visual Studio 2022 - Build Tools
"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvars64.bat"

# Visual Studio 2019 - Enterprise
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"

Configure Conan Remote

Configure the TeiaCare Artifactory remote to fetch 3rd party dependencies (only required for unit tests and examples).

conan remote add teiacare https://artifactory.app.teiacare.com/artifactory/api/conan/teiacare --index 0 --force
conan remote login teiacare <ARTIFACTORY_USERNAME> -p <ARTIFACTORY_PASSWORD>

Install Dependencies

Install Conan packages and generate CMakePresets.json together with the CMake toolchain file. Pick the profile that matches your platform (available profiles are under scripts/profiles/): linux-clang, linux-gcc, macos-arm64, macos-x64, windows-msvc.

# Linux (clang) - Debug
conan install prometheus_client -b=missing -pr:a=scripts/profiles/linux-clang -s build_type=Debug

# Linux (gcc) - Release
conan install prometheus_client -b=missing -pr:a=scripts/profiles/linux-gcc -s build_type=Release

# Windows (msvc) - Release
conan install prometheus_client -b=missing -pr:a=scripts/profiles/windows-msvc -s build_type=Release

Configure, Build and Install

Use the CMake presets generated by Conan to configure, build and install the library.

# CMake configure
cmake --preset conan-debug

# CMake build
cmake --build build/Debug

# CMake install
cmake --install build/Debug

Replace conan-debug / build/Debug with conan-release / build/Release when building the Release configuration.

Examples

# Run all the examples
python scripts/tools/run_examples.py install/examples

Examples are installed in $PWD/install/examples.

Unit Tests and Code Coverage

# Run Unit Tests
python scripts/tools/run_unit_tests.py <Debug|Release|RelWithDebInfo>

# Run Code Coverage
python scripts/tools/run_coverage.py <COMPILER_NAME> <COMPILER_VERSION> prometheus_client

Note that code coverage is not available on Windows.

Unit tests results are available in $PWD/results/unit_tests. Coverage results are available in $PWD/results/coverage.

Sanitizers

Address Sanitizer

# Run Unit Tests with Address Sanitizer
python scripts/tools/run_sanitizer.py --address_sanitizer install/unit_tests/teiacare_prometheus_client_unit_tests

Note that Address Sanitizer is supported only on Linux.

Thread Sanitizer

# Run Unit Tests with Thread Sanitizer
python scripts/tools/run_sanitizer.py --thread_sanitizer install/unit_tests/teiacare_prometheus_client_unit_tests

Note that Thread Sanitizer is supported only on Linux.

About

TeiaCarePrometheus is a C++ client library that implements the Prometheus Data Model

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors