Skip to content

Commit

Permalink
Merge branch 'topic/christian/prometheus-cpp'
Browse files Browse the repository at this point in the history
* topic/christian/prometheus-cpp:
  Add safety checks for accessing registry pointers
  Fix build on Windows
  Remove obsolete tests
  Use bundling approach for building prometheus-cpp
  Drop legacy telemetry API
  • Loading branch information
ckreibich committed Jul 11, 2024
2 parents c47de11 + 6050f42 commit fada26a
Show file tree
Hide file tree
Showing 56 changed files with 410 additions and 4,948 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
[submodule "caf"]
path = caf
url = https://github.com/zeek/actor-framework.git
[submodule "auxil/prometheus-cpp"]
path = auxil/prometheus-cpp
url = https://github.com/zeek/prometheus-cpp.git
12 changes: 12 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
2.8.0-dev.93 | 2024-07-11 12:11:26 -0700

* Add safety checks for accessing registry pointers (Dominik Charousset, Corelight)

* Fix build on Windows (Dominik Charousset, Corelight)

* Remove obsolete tests (Dominik Charousset, Corelight)

* Use bundling approach for building prometheus-cpp (Dominik Charousset and Christian Kreibich, Corelight)

* Drop legacy telemetry API (Dominik Charousset, Corelight)

2.8.0-dev.84 | 2024-06-24 15:38:31 +0200

* Remove unused master_resolver from the code base (Dominik Charousset, Corelight)
Expand Down
32 changes: 32 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

cmake_minimum_required(VERSION 3.15 FATAL_ERROR)
project(broker C CXX)

include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
include(cmake/CommonCMakeConfig.cmake)
include(cmake/ZeekBundle.cmake)

set(BROKER_TEST_TIMEOUT 60)

Expand Down Expand Up @@ -208,6 +210,36 @@ function(add_bundled_caf)
add_subdirectory(caf EXCLUDE_FROM_ALL)
endfunction()

# Bundle prometheus-cpp. This approach is currently experimental.
if (CMAKE_MSVC_RUNTIME_LIBRARY)
set(msvc_zeekbundle_args
CMAKE_MSVC_RUNTIME_LIBRARY=${CMAKE_MSVC_RUNTIME_LIBRARY}
CMAKE_MSVC_RUNTIME_LIBRARY_FLAG=${CMAKE_MSVC_RUNTIME_LIBRARY_FLAG})
endif ()
ZeekBundle_Add(
NAME prometheus-cpp
FETCH
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/auxil/prometheus-cpp
CONFIGURE
${msvc_zeekbundle_args}
ENABLE_COMPRESSION=OFF
ENABLE_PUSH=OFF)
unset(msvc_zeekbundle_args)

# Bundle all prometheus-cpp libraries that we need as single interface library.
add_library(broker-prometheus-cpp INTERFACE)
target_link_libraries(
broker-prometheus-cpp
INTERFACE
$<BUILD_INTERFACE:prometheus-cpp::core>
$<BUILD_INTERFACE:prometheus-cpp::pull>)
# Prometheus-cpp sets C++ 11 via CMake property, but we need C++ 17.
target_compile_features(broker-prometheus-cpp INTERFACE cxx_std_17)
# Must be exported to keep CMake happy, even though we only need it internally.
install(TARGETS broker-prometheus-cpp
EXPORT BrokerTargets
DESTINATION ${CMAKE_INSTALL_LIBDIR})

# NOTE: building and linking against an external CAF version is NOT supported!
# This variable is FOR DEVELOPMENT ONLY. The only officially supported CAF
# version is the bundled version!
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.8.0-dev.84
2.8.0-dev.93
1 change: 1 addition & 0 deletions auxil/prometheus-cpp
Submodule prometheus-cpp added at 2fec72
2 changes: 1 addition & 1 deletion ci/windows/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ RUN choco install -y --no-progress msysgit

# Add git to the global PATH
SHELL [ "cmd", "/c" ]
RUN setx /M PATH "%PATH%;C:\\Program Files\\Git\\bin"
RUN setx /M PATH "%PATH%;C:\\Program Files\\Git\\bin"
2 changes: 1 addition & 1 deletion cmake
Submodule cmake updated 2 files
+11 −0 CheckCompilers.cmake
+138 −0 ZeekBundle.cmake
41 changes: 23 additions & 18 deletions libbroker/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,10 @@ set(BROKER_SRC
broker/internal/json_client.cc
broker/internal/json_type_mapper.cc
broker/internal/master_actor.cc
broker/internal/metric_collector.cc
broker/internal/metric_exporter.cc
broker/internal/metric_factory.cc
broker/internal/metric_scraper.cc
broker/internal/metric_view.cc
broker/internal/peering.cc
broker/internal/pending_connection.cc
broker/internal/println.cc
broker/internal/prometheus.cc
broker/internal/store_actor.cc
broker/internal/web_socket.cc
broker/internal/wire_format.cc
Expand All @@ -85,12 +80,6 @@ set(BROKER_SRC
broker/store_event.cc
broker/subnet.cc
broker/subscriber.cc
broker/telemetry/counter.cc
broker/telemetry/gauge.cc
broker/telemetry/histogram.cc
broker/telemetry/metric_family.cc
broker/telemetry/metric_registry.cc
broker/telemetry/metric_registry_impl.cc
broker/time.cc
broker/topic.cc
broker/variant.cc
Expand All @@ -112,7 +101,13 @@ if (ENABLE_SHARED)
MACOSX_RPATH true
OUTPUT_NAME broker)
target_link_libraries(broker PUBLIC ${LINK_LIBS})
target_link_libraries(broker PRIVATE CAF::core CAF::io CAF::net)
target_link_libraries(
broker
PRIVATE
CAF::core
CAF::io
CAF::net
broker-prometheus-cpp)
install(TARGETS broker
EXPORT BrokerTargets
DESTINATION ${CMAKE_INSTALL_LIBDIR})
Expand All @@ -129,7 +124,13 @@ if (ENABLE_STATIC)
set_target_properties(broker_static PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif()
target_link_libraries(broker_static PUBLIC ${LINK_LIBS})
target_link_libraries(broker_static PRIVATE CAF::core CAF::io CAF::net)
target_link_libraries(
broker_static
PRIVATE
CAF::core
CAF::io
CAF::net
broker-prometheus-cpp)
install(TARGETS broker_static
EXPORT BrokerTargets
DESTINATION ${CMAKE_INSTALL_LIBDIR})
Expand Down Expand Up @@ -175,8 +176,6 @@ set(BROKER_TEST_SRC
broker/internal/channel.test.cc
broker/internal/core_actor.test.cc
broker/internal/json.test.cc
broker/internal/metric_collector.test.cc
broker/internal/metric_exporter.test.cc
broker/internal/wire_format.test.cc
broker/master.test.cc
broker/peering.test.cc
Expand All @@ -188,7 +187,6 @@ set(BROKER_TEST_SRC
broker/store.test.cc
broker/store_event.test.cc
broker/subscriber.test.cc
broker/telemetry/histogram.test.cc
broker/topic.test.cc
broker/variant.test.cc
broker/zeek.test.cc
Expand All @@ -202,8 +200,15 @@ set(BROKER_TEST_SRC
# endif()

add_executable(broker-test ${BROKER_TEST_SRC})
target_link_libraries(broker-test PRIVATE
${main_lib_target} CAF::core CAF::io CAF::net CAF::test)
target_link_libraries(
broker-test
PRIVATE
${main_lib_target}
CAF::core
CAF::io
CAF::net
CAF::test
broker-prometheus-cpp)

foreach(file_path ${BROKER_TEST_SRC})
get_filename_component(test_dir ${file_path} DIRECTORY)
Expand Down
Loading

0 comments on commit fada26a

Please sign in to comment.