mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-05 05:18:52 +08:00
Add option to disable/enble prometheus when compiling
This commit is contained in:
parent
bbb1ed42a4
commit
bf0e5cbc9d
@ -33,7 +33,7 @@ message(STATUS "Build time = ${BUILD_TIME}")
|
||||
|
||||
MACRO(GET_GIT_BRANCH_NAME GIT_BRANCH_NAME)
|
||||
execute_process(COMMAND sh "-c" "git log --decorate | head -n 1 | sed 's/.*(\\(.*\\))/\\1/' | sed 's/.* \\(.*\\),.*/\\1/' | sed 's=[a-zA-Z]*\/==g'"
|
||||
OUTPUT_VARIABLE ${GIT_BRANCH_NAME})
|
||||
OUTPUT_VARIABLE ${GIT_BRANCH_NAME})
|
||||
ENDMACRO(GET_GIT_BRANCH_NAME)
|
||||
|
||||
GET_GIT_BRANCH_NAME(GIT_BRANCH_NAME)
|
||||
@ -117,17 +117,17 @@ include(DefineOptions)
|
||||
include(BuildUtils)
|
||||
include(ThirdPartyPackages)
|
||||
|
||||
if(MILVUS_USE_CCACHE)
|
||||
find_program(CCACHE_FOUND ccache)
|
||||
if(CCACHE_FOUND)
|
||||
message(STATUS "Using ccache: ${CCACHE_FOUND}")
|
||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE_FOUND})
|
||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE_FOUND})
|
||||
# let ccache preserve C++ comments, because some of them may be
|
||||
# meaningful to the compiler
|
||||
set(ENV{CCACHE_COMMENTS} "1")
|
||||
endif(CCACHE_FOUND)
|
||||
endif()
|
||||
if (MILVUS_USE_CCACHE)
|
||||
find_program(CCACHE_FOUND ccache)
|
||||
if (CCACHE_FOUND)
|
||||
message(STATUS "Using ccache: ${CCACHE_FOUND}")
|
||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE_FOUND})
|
||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE_FOUND})
|
||||
# let ccache preserve C++ comments, because some of them may be
|
||||
# meaningful to the compiler
|
||||
set(ENV{CCACHE_COMMENTS} "1")
|
||||
endif (CCACHE_FOUND)
|
||||
endif ()
|
||||
|
||||
set(MILVUS_CPU_VERSION false)
|
||||
if (MILVUS_GPU_VERSION)
|
||||
@ -142,6 +142,10 @@ else ()
|
||||
add_compile_definitions("MILVUS_CPU_VERSION")
|
||||
endif ()
|
||||
|
||||
if (MILVUS_WITH_PROMETHEUS)
|
||||
add_compile_definitions("MILVUS_WITH_PROMETHEUS")
|
||||
endif ()
|
||||
|
||||
if (CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -fPIC -DELPP_THREAD_SAFE -fopenmp")
|
||||
if (MILVUS_GPU_VERSION)
|
||||
@ -176,9 +180,9 @@ endif ()
|
||||
|
||||
if (MILVUS_GPU_VERSION)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/conf/server_gpu_config.template ${CMAKE_CURRENT_SOURCE_DIR}/conf/server_config.yaml)
|
||||
else()
|
||||
else ()
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/conf/server_cpu_config.template ${CMAKE_CURRENT_SOURCE_DIR}/conf/server_config.yaml)
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/conf/log_config.template ${CMAKE_CURRENT_SOURCE_DIR}/conf/log_config.conf)
|
||||
|
||||
|
@ -37,6 +37,7 @@ endforeach ()
|
||||
aux_source_directory(${MILVUS_ENGINE_SRC}/cache cache_files)
|
||||
aux_source_directory(${MILVUS_ENGINE_SRC}/config config_files)
|
||||
aux_source_directory(${MILVUS_ENGINE_SRC}/metrics metrics_files)
|
||||
aux_source_directory(${MILVUS_ENGINE_SRC}/metrics/prometheus metrics_prometheus_files)
|
||||
aux_source_directory(${MILVUS_ENGINE_SRC}/db db_main_files)
|
||||
aux_source_directory(${MILVUS_ENGINE_SRC}/db/engine db_engine_files)
|
||||
aux_source_directory(${MILVUS_ENGINE_SRC}/db/insert db_insert_files)
|
||||
@ -91,6 +92,11 @@ set(engine_files
|
||||
${wrapper_files}
|
||||
)
|
||||
|
||||
if (MILVUS_WITH_PROMETHEUS)
|
||||
set(engine_files ${engine_files}
|
||||
${metrics_prometheus_files})
|
||||
endif ()
|
||||
|
||||
set(client_grpc_lib
|
||||
grpcpp_channelz
|
||||
grpc++
|
||||
@ -115,7 +121,6 @@ set(third_party_libs
|
||||
sqlite
|
||||
${client_grpc_lib}
|
||||
yaml-cpp
|
||||
${prometheus_lib}
|
||||
mysqlpp
|
||||
zlib
|
||||
${boost_lib}
|
||||
@ -138,13 +143,19 @@ if (MILVUS_GPU_VERSION)
|
||||
)
|
||||
endif ()
|
||||
|
||||
if (MILVUS_ENABLE_PROFILING STREQUAL "ON")
|
||||
if (MILVUS_ENABLE_PROFILING)
|
||||
set(third_party_libs ${third_party_libs}
|
||||
gperftools
|
||||
libunwind
|
||||
)
|
||||
endif ()
|
||||
|
||||
if (MILVUS_WITH_PROMETHEUS)
|
||||
set(third_party_libs ${third_party_libs}
|
||||
${prometheus_lib}
|
||||
)
|
||||
endif ()
|
||||
|
||||
set(engine_libs
|
||||
pthread
|
||||
libgomp.a
|
||||
@ -166,13 +177,22 @@ target_link_libraries(milvus_engine
|
||||
${engine_libs}
|
||||
)
|
||||
|
||||
add_library(metrics STATIC ${metrics_files})
|
||||
if (MILVUS_WITH_PROMETHEUS)
|
||||
add_library(metrics STATIC ${metrics_files} ${metrics_prometheus_files})
|
||||
else ()
|
||||
add_library(metrics STATIC ${metrics_files})
|
||||
endif ()
|
||||
|
||||
set(metrics_lib
|
||||
yaml-cpp
|
||||
${prometheus_lib}
|
||||
)
|
||||
|
||||
if (MILVUS_WITH_PROMETHEUS)
|
||||
set(metrics_lib ${metrics_lib}
|
||||
${prometheus_lib}
|
||||
)
|
||||
endif ()
|
||||
|
||||
target_link_libraries(metrics ${metrics_lib})
|
||||
|
||||
set(server_libs
|
||||
|
@ -16,8 +16,10 @@
|
||||
// under the License.
|
||||
|
||||
#include "metrics/Metrics.h"
|
||||
#include "PrometheusMetrics.h"
|
||||
#include "server/Config.h"
|
||||
#ifdef MILVUS_WITH_PROMETHEUS
|
||||
#include "metrics/prometheus/PrometheusMetrics.h"
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
@ -37,11 +39,15 @@ Metrics::CreateMetricsCollector() {
|
||||
|
||||
config.GetMetricConfigCollector(collector_type_str);
|
||||
|
||||
#ifdef MILVUS_WITH_PROMETHEUS
|
||||
if (collector_type_str == "prometheus") {
|
||||
return PrometheusMetrics::GetInstance();
|
||||
} else {
|
||||
return MetricsBase::GetInstance();
|
||||
}
|
||||
#else
|
||||
return MetricsBase::GetInstance();
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace server
|
||||
|
@ -15,10 +15,10 @@
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
#include "metrics/PrometheusMetrics.h"
|
||||
#include "SystemInfo.h"
|
||||
#include "PrometheusMetrics.h"
|
||||
#include "cache/GpuCacheMgr.h"
|
||||
#include "server/Config.h"
|
||||
#include "metrics/SystemInfo.h"
|
||||
#include "utils/Log.h"
|
||||
|
||||
#include <string>
|
@ -24,7 +24,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "MetricBase.h"
|
||||
#include "metrics/MetricBase.h"
|
||||
#include "utils/Error.h"
|
||||
|
||||
#define METRICS_NOW_TIME std::chrono::system_clock::now()
|
@ -110,12 +110,16 @@ set(unittest_libs
|
||||
pthread
|
||||
metrics
|
||||
gfortran
|
||||
prometheus-cpp-pull
|
||||
prometheus-cpp-push
|
||||
prometheus-cpp-core
|
||||
dl
|
||||
z
|
||||
)
|
||||
if (MILVUS_WITH_PROMETHEUS)
|
||||
set(unittest_libs ${unittest_libs}
|
||||
prometheus-cpp-push
|
||||
prometheus-cpp-pull
|
||||
prometheus-cpp-core
|
||||
)
|
||||
endif ()
|
||||
|
||||
if (MILVUS_GPU_VERSION)
|
||||
include_directories("${CUDA_INCLUDE_DIRS}")
|
||||
|
@ -17,7 +17,16 @@
|
||||
# under the License.
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} test_files)
|
||||
set(test_files
|
||||
test_metricbase.cpp
|
||||
test_metrics.cpp
|
||||
utils.cpp
|
||||
)
|
||||
|
||||
if (MILVUS_WITH_PROMETHEUS)
|
||||
set(test_files ${test_files}
|
||||
test_prometheus.cpp)
|
||||
endif ()
|
||||
|
||||
add_executable(test_metrics
|
||||
${common_files}
|
||||
|
@ -15,8 +15,8 @@
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
#include "metrics/PrometheusMetrics.h"
|
||||
#include "server/Config.h"
|
||||
#include "metrics/prometheus/PrometheusMetrics.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <iostream>
|
||||
|
Loading…
Reference in New Issue
Block a user