From 0fed009bdff4d560f59ba334e0b9c69ac86328b3 Mon Sep 17 00:00:00 2001 From: Brett Date: Sun, 6 Apr 2025 17:23:31 -0400 Subject: [PATCH] otel --- CMakeLists.txt | 22 ++++++++++++++++++++++ default.nix | 21 +++++++++++++++++++++ include/blt/std/defines.h | 26 ++++++++++++++++++++++++++ include/blt/std/types.h | 1 + libraries/parallel-hashmap | 2 +- 5 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 default.nix create mode 100644 include/blt/std/defines.h diff --git a/CMakeLists.txt b/CMakeLists.txt index d41de9e..f8ac431 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,8 @@ option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) option(ENABLE_TSAN "Enable the thread data race sanitizer" OFF) +option(BLT_DEBUG_OTEL "Enable OpenTelemetry Service" OFF) + option(BUILD_STD "Build the BLT standard utilities." ON) option(BUILD_PROFILING "Build the BLT profiler extension" ON) option(BUILD_FS "Build the BLT FS utilities including the NBT + eNBT extension" ON) @@ -29,6 +31,22 @@ option(BLT_DISABLE_WARN "Disable blt::logging BLT_WARN macro" OFF) option(BLT_DISABLE_ERROR "Disable blt::logging BLT_ERROR macro" OFF) option(BLT_DISABLE_FATAL "Disable blt::logging BLT_FATAL macro" OFF) +if (BLT_DEBUG_OTEL) + set(WITH_BENCHMARK OFF) + set(BUILD_TESTING OFF) + set(WITH_ABSEIL OFF) + include(FetchContent) + FetchContent_Declare( + opentelemtry-cpp + GIT_REPOSITORY https://github.com/open-telemetry/opentelemetry-cpp + GIT_TAG 6175aa0b213eea053247e43b4f35b8d201fa356e # release-1.20.0 + ) + FetchContent_MakeAvailable(opentelemtry-cpp) + + message("${OPENTELEMETRY_CPP_LIBRARIES}") +# include_directories("${opentelemtry-cpp_INCLUDE_DIRS}") +endif () + if(${BLT_DISABLE_STATS}) add_compile_definitions(BLT_DISABLE_STATS) endif () @@ -200,3 +218,7 @@ if (${BUILD_TESTS}) endif () project(BLT) + +if (BLT_DEBUG_OTEL) + target_link_libraries(${BLT_TARGET} PUBLIC ${OPENTELEMETRY_CPP_LIBRARIES}) +endif () \ No newline at end of file diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..049fdba --- /dev/null +++ b/default.nix @@ -0,0 +1,21 @@ +{ pkgs ? (import { + config.allowUnfree = true; + config.segger-jlink.acceptLicense = true; +}), ... }: +pkgs.mkShell +{ + buildInputs = with pkgs; [ + cmake + gcc + clang + emscripten + ninja + renderdoc + valgrind + ]; + propagatedBuildInputs = with pkgs; [ + gtest + gtest.dev + ]; + LD_LIBRARY_PATH="/run/opengl-driver/lib:/run/opengl-driver-32/lib"; +} diff --git a/include/blt/std/defines.h b/include/blt/std/defines.h new file mode 100644 index 0000000..ce31c3f --- /dev/null +++ b/include/blt/std/defines.h @@ -0,0 +1,26 @@ +#pragma once +/* + * Copyright (C) 2024 Brett Terpstra + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef BLT_DEFINES_H +#define BLT_DEFINES_H + +#if defined(BLT_DEBUG_OTEL) && defined(__has_include) &&__has_include() + #define BLT_DEBUG_OTEL_ENABLED 1 +#endif + +#endif //BLT_DEFINES_H diff --git a/include/blt/std/types.h b/include/blt/std/types.h index b8e4a0a..45305e5 100644 --- a/include/blt/std/types.h +++ b/include/blt/std/types.h @@ -21,6 +21,7 @@ #include #include +#include #ifndef NO_BLT_NAMESPACE_ON_TYPES namespace blt diff --git a/libraries/parallel-hashmap b/libraries/parallel-hashmap index d88c5e1..8a889d3 160000 --- a/libraries/parallel-hashmap +++ b/libraries/parallel-hashmap @@ -1 +1 @@ -Subproject commit d88c5e15079047777b418132ece5879e7c9aaa2b +Subproject commit 8a889d3699b3c09ade435641fb034427f3fd12b6