From cf73ec2d87f7d0e273fec1a5e63b4265725458eb Mon Sep 17 00:00:00 2001 From: Aster Seker Date: Mon, 14 Sep 2026 13:26:03 +0300 Subject: [PATCH 1/4] refactor(otlp): separate compression type from helpers Move OtlpCompression into a focused public type header, retain the historical include path as a compatibility wrapper, and make the OTLP backend call detail compression helpers explicitly. Add include-contract coverage for both public headers. --- .../logit/loggers/OtlpHttpLogger.hpp | 7 ++++--- .../logit/loggers/otlp/OtlpCompression.hpp | 18 ++++------------- .../loggers/otlp/OtlpCompressionType.hpp | 20 +++++++++++++++++++ tests/CMakeLists.txt | 2 ++ tests/include_otlp_compression_nhr_test.cpp | 5 +++++ ...include_otlp_compression_type_nhr_test.cpp | 5 +++++ 6 files changed, 40 insertions(+), 17 deletions(-) create mode 100644 include/logit_cpp/logit/loggers/otlp/OtlpCompressionType.hpp create mode 100644 tests/include_otlp_compression_nhr_test.cpp create mode 100644 tests/include_otlp_compression_type_nhr_test.cpp diff --git a/include/logit_cpp/logit/loggers/OtlpHttpLogger.hpp b/include/logit_cpp/logit/loggers/OtlpHttpLogger.hpp index 37861bc..11ea2a5 100644 --- a/include/logit_cpp/logit/loggers/OtlpHttpLogger.hpp +++ b/include/logit_cpp/logit/loggers/OtlpHttpLogger.hpp @@ -10,10 +10,11 @@ #endif #include "ILogger.hpp" -#include "otlp/OtlpCompression.hpp" +#include "otlp/OtlpCompressionType.hpp" #include "otlp/OtlpJsonFormatConfig.hpp" #include "otlp/OtlpJsonSerializer.hpp" #include "otlp/OtlpPayloadSplitter.hpp" +#include #ifndef KURLYK_WEBSOCKET_SUPPORT # define KURLYK_WEBSOCKET_SUPPORT 0 @@ -350,7 +351,7 @@ namespace logit { kurlyk::Headers chunk_headers = headers; if (m_config.compression == OtlpCompression::Gzip) { - if (!compress_string_gzip(chunk, post_content, m_config.compression_level)) { + if (!detail::compress_string_gzip(chunk, post_content, m_config.compression_level)) { // Compression failed: fallback to uncompressed payload. // Count this as a failed export attempt so operators can observe compression issues. m_state->failed_exports.fetch_add(1); @@ -359,7 +360,7 @@ namespace logit { chunk_headers.emplace("Content-Encoding", "gzip"); } } else if (m_config.compression == OtlpCompression::Zstd) { - if (!compress_string_zstd(chunk, post_content, m_config.compression_level)) { + if (!detail::compress_string_zstd(chunk, post_content, m_config.compression_level)) { // Compression failed: fallback to uncompressed payload. // Count this as a failed export attempt so operators can observe compression issues. m_state->failed_exports.fetch_add(1); diff --git a/include/logit_cpp/logit/loggers/otlp/OtlpCompression.hpp b/include/logit_cpp/logit/loggers/otlp/OtlpCompression.hpp index d6f4d80..abdc8ff 100644 --- a/include/logit_cpp/logit/loggers/otlp/OtlpCompression.hpp +++ b/include/logit_cpp/logit/loggers/otlp/OtlpCompression.hpp @@ -3,21 +3,11 @@ #define LOGIT_CPP_HEADER_LOGIT_CPP_LOGIT_LOGGERS_OTLP_OTLPCOMPRESSION_HPP_INCLUDED /// \file OtlpCompression.hpp -/// \brief Backward-compatible forwarding header for shared compression helpers. +/// \brief Compatibility header for the OTLP compression type. /// -/// New code should include `` directly. -/// This header is kept for existing OTLP headers that include it. +/// The enum now lives in `OtlpCompressionType.hpp`. This path remains available +/// for existing users that included `OtlpCompression.hpp` directly. -#include "../../detail/CompressionUtils.hpp" - -namespace logit { - -enum class OtlpCompression { None, Gzip, Zstd }; - -// Forward declarations: the actual implementations live in detail:: -using detail::compress_string_gzip; -using detail::compress_string_zstd; - -} // namespace logit +#include "OtlpCompressionType.hpp" #endif // LOGIT_CPP_HEADER_LOGIT_CPP_LOGIT_LOGGERS_OTLP_OTLPCOMPRESSION_HPP_INCLUDED diff --git a/include/logit_cpp/logit/loggers/otlp/OtlpCompressionType.hpp b/include/logit_cpp/logit/loggers/otlp/OtlpCompressionType.hpp new file mode 100644 index 0000000..d6c8238 --- /dev/null +++ b/include/logit_cpp/logit/loggers/otlp/OtlpCompressionType.hpp @@ -0,0 +1,20 @@ +#pragma once +#ifndef LOGIT_CPP_HEADER_LOGIT_CPP_LOGIT_LOGGERS_OTLP_OTLPCOMPRESSIONTYPE_HPP_INCLUDED +#define LOGIT_CPP_HEADER_LOGIT_CPP_LOGIT_LOGGERS_OTLP_OTLPCOMPRESSIONTYPE_HPP_INCLUDED + +/// \file OtlpCompressionType.hpp +/// \brief Compression algorithm selected for OTLP/HTTP payloads. + +namespace logit { + +/// \enum OtlpCompression +/// \brief Compression algorithm used for an OTLP/HTTP request payload. +enum class OtlpCompression { + None, + Gzip, + Zstd +}; + +} // namespace logit + +#endif // LOGIT_CPP_HEADER_LOGIT_CPP_LOGIT_LOGGERS_OTLP_OTLPCOMPRESSIONTYPE_HPP_INCLUDED diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 045abf3..ea399d3 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -40,6 +40,8 @@ else() include_log_file_read_result_nhr_test.cpp include_loggers_nhr_test.cpp include_memory_logger_nhr_test.cpp + include_otlp_compression_nhr_test.cpp + include_otlp_compression_type_nhr_test.cpp include_only_ilogger_test.cpp include_quickstart_test.cpp include_utils_nhr_test.cpp diff --git a/tests/include_otlp_compression_nhr_test.cpp b/tests/include_otlp_compression_nhr_test.cpp new file mode 100644 index 0000000..ef5aac0 --- /dev/null +++ b/tests/include_otlp_compression_nhr_test.cpp @@ -0,0 +1,5 @@ +#include + +int main() { + return static_cast(logit::OtlpCompression::None) == 0 ? 0 : 1; +} diff --git a/tests/include_otlp_compression_type_nhr_test.cpp b/tests/include_otlp_compression_type_nhr_test.cpp new file mode 100644 index 0000000..149827b --- /dev/null +++ b/tests/include_otlp_compression_type_nhr_test.cpp @@ -0,0 +1,5 @@ +#include + +int main() { + return static_cast(logit::OtlpCompression::Zstd) == 2 ? 0 : 1; +} From 63cbcc8b7ff7a3f5d79a59190cca2261db15a09d Mon Sep 17 00:00:00 2001 From: Aster Seker Date: Mon, 14 Sep 2026 14:07:15 +0300 Subject: [PATCH 2/4] refactor(otlp): remove obsolete compression shim Keep OtlpCompressionType.hpp as the sole OTLP compression type header. Remove the unused compatibility path and its include-contract test so the public include surface reflects the internal-only status of the old header. --- .../logit/loggers/otlp/OtlpCompression.hpp | 13 ------------- tests/CMakeLists.txt | 1 - tests/include_otlp_compression_nhr_test.cpp | 5 ----- 3 files changed, 19 deletions(-) delete mode 100644 include/logit_cpp/logit/loggers/otlp/OtlpCompression.hpp delete mode 100644 tests/include_otlp_compression_nhr_test.cpp diff --git a/include/logit_cpp/logit/loggers/otlp/OtlpCompression.hpp b/include/logit_cpp/logit/loggers/otlp/OtlpCompression.hpp deleted file mode 100644 index abdc8ff..0000000 --- a/include/logit_cpp/logit/loggers/otlp/OtlpCompression.hpp +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once -#ifndef LOGIT_CPP_HEADER_LOGIT_CPP_LOGIT_LOGGERS_OTLP_OTLPCOMPRESSION_HPP_INCLUDED -#define LOGIT_CPP_HEADER_LOGIT_CPP_LOGIT_LOGGERS_OTLP_OTLPCOMPRESSION_HPP_INCLUDED - -/// \file OtlpCompression.hpp -/// \brief Compatibility header for the OTLP compression type. -/// -/// The enum now lives in `OtlpCompressionType.hpp`. This path remains available -/// for existing users that included `OtlpCompression.hpp` directly. - -#include "OtlpCompressionType.hpp" - -#endif // LOGIT_CPP_HEADER_LOGIT_CPP_LOGIT_LOGGERS_OTLP_OTLPCOMPRESSION_HPP_INCLUDED diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ea399d3..e9de14c 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -40,7 +40,6 @@ else() include_log_file_read_result_nhr_test.cpp include_loggers_nhr_test.cpp include_memory_logger_nhr_test.cpp - include_otlp_compression_nhr_test.cpp include_otlp_compression_type_nhr_test.cpp include_only_ilogger_test.cpp include_quickstart_test.cpp diff --git a/tests/include_otlp_compression_nhr_test.cpp b/tests/include_otlp_compression_nhr_test.cpp deleted file mode 100644 index ef5aac0..0000000 --- a/tests/include_otlp_compression_nhr_test.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include - -int main() { - return static_cast(logit::OtlpCompression::None) == 0 ? 0 : 1; -} From 302f2e74d8fb648b0197d4cf9743b6af7df3621a Mon Sep 17 00:00:00 2001 From: Aster Seker Date: Mon, 14 Sep 2026 15:36:20 +0300 Subject: [PATCH 3/4] test(otlp): remove internal type header contract Do not advertise OtlpCompressionType.hpp as a standalone public include. The OTLP compression type remains covered through the supported logger umbrella headers. --- tests/CMakeLists.txt | 1 - tests/include_otlp_compression_type_nhr_test.cpp | 5 ----- 2 files changed, 6 deletions(-) delete mode 100644 tests/include_otlp_compression_type_nhr_test.cpp diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index e9de14c..045abf3 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -40,7 +40,6 @@ else() include_log_file_read_result_nhr_test.cpp include_loggers_nhr_test.cpp include_memory_logger_nhr_test.cpp - include_otlp_compression_type_nhr_test.cpp include_only_ilogger_test.cpp include_quickstart_test.cpp include_utils_nhr_test.cpp diff --git a/tests/include_otlp_compression_type_nhr_test.cpp b/tests/include_otlp_compression_type_nhr_test.cpp deleted file mode 100644 index 149827b..0000000 --- a/tests/include_otlp_compression_type_nhr_test.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include - -int main() { - return static_cast(logit::OtlpCompression::Zstd) == 2 ? 0 : 1; -} From 3b47e20c0201b27c8be7d477f96e22db5f4e44a0 Mon Sep 17 00:00:00 2001 From: Aster Seker Date: Mon, 14 Sep 2026 18:41:13 +0300 Subject: [PATCH 4/4] ci(otlp): cover optional backend build Add a Linux C++17 job that configures LOGIT_WITH_OTLP with bundled kurlyk dependencies and runs the OTLP test suite. Keep the PR description aligned with the aggregate-first header contract. --- .github/workflows/ci.yml | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 17c9250..99ee176 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -139,6 +139,44 @@ jobs: build-mdbx/Testing/Temporary/LastTest.log if-no-files-found: ignore + linux-otlp: + runs-on: ubuntu-latest + timeout-minutes: 20 + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - run: git submodule update --init --recursive + - name: Install OTLP build dependencies + run: sudo apt-get update && sudo apt-get install -y libcurl4-openssl-dev libssl-dev + - name: Configure OTLP + run: >- + cmake -S . -B build-otlp + -DLOGIT_CPP_BUILD_TESTS=ON + -DLOGIT_WITH_OTLP=ON + -DLOGIT_USE_SUBMODULES=ON + -DKURLYK_USE_FALLBACK_ASIO=ON + -DKURLYK_USE_FALLBACK_SIMPLE_WS_SERVER=ON + -DKURLYK_AUTH_SUPPORT=OFF + -DKURLYK_OAUTH_SUPPORT=OFF + -DLOGIT_WITH_SYSLOG=OFF + -DLOGIT_WITH_WIN_EVENT_LOG=OFF + -DCMAKE_BUILD_TYPE=Release + -DCMAKE_CXX_STANDARD=17 + - name: Build OTLP tests + run: cmake --build build-otlp --parallel 2 + - name: Run OTLP tests + run: ctest --test-dir build-otlp --output-on-failure -R '^otlp_' + - name: Upload OTLP logs + if: failure() + uses: actions/upload-artifact@v4 + with: + name: logs-otlp + path: | + build-otlp/CMakeFiles/CMakeOutput.log + build-otlp/Testing/Temporary/LastTest.log + if-no-files-found: ignore + windows: runs-on: windows-latest strategy: