未验证 提交 2e62a052 编写于 作者: J Jin Hai 提交者: GitHub

Merge pull request #332 from youny626/0.6.0

Add option  to enable / disable prometheus
...@@ -18,6 +18,7 @@ Please mark all change in change log and use the ticket from JIRA. ...@@ -18,6 +18,7 @@ Please mark all change in change log and use the ticket from JIRA.
- \#260 - C++ SDK README - \#260 - C++ SDK README
- \#314 - add Find FAISS in CMake - \#314 - add Find FAISS in CMake
- \#310 - Add Q&A for 'protocol https not supported or disable in libcurl' issue - \#310 - Add Q&A for 'protocol https not supported or disable in libcurl' issue
- \#322 - Add option to enable / disable prometheus
## Task ## Task
......
...@@ -33,7 +33,7 @@ message(STATUS "Build time = ${BUILD_TIME}") ...@@ -33,7 +33,7 @@ message(STATUS "Build time = ${BUILD_TIME}")
MACRO(GET_GIT_BRANCH_NAME GIT_BRANCH_NAME) 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'" 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) ENDMACRO(GET_GIT_BRANCH_NAME)
GET_GIT_BRANCH_NAME(GIT_BRANCH_NAME) GET_GIT_BRANCH_NAME(GIT_BRANCH_NAME)
...@@ -117,17 +117,17 @@ include(DefineOptions) ...@@ -117,17 +117,17 @@ include(DefineOptions)
include(BuildUtils) include(BuildUtils)
include(ThirdPartyPackages) include(ThirdPartyPackages)
if(MILVUS_USE_CCACHE) if (MILVUS_USE_CCACHE)
find_program(CCACHE_FOUND ccache) find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND) if (CCACHE_FOUND)
message(STATUS "Using ccache: ${CCACHE_FOUND}") message(STATUS "Using ccache: ${CCACHE_FOUND}")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE_FOUND}) set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE_FOUND})
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE_FOUND}) set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE_FOUND})
# let ccache preserve C++ comments, because some of them may be # let ccache preserve C++ comments, because some of them may be
# meaningful to the compiler # meaningful to the compiler
set(ENV{CCACHE_COMMENTS} "1") set(ENV{CCACHE_COMMENTS} "1")
endif(CCACHE_FOUND) endif (CCACHE_FOUND)
endif() endif ()
set(MILVUS_CPU_VERSION false) set(MILVUS_CPU_VERSION false)
if (MILVUS_GPU_VERSION) if (MILVUS_GPU_VERSION)
...@@ -142,6 +142,10 @@ else () ...@@ -142,6 +142,10 @@ else ()
add_compile_definitions("MILVUS_CPU_VERSION") add_compile_definitions("MILVUS_CPU_VERSION")
endif () endif ()
if (MILVUS_WITH_PROMETHEUS)
add_compile_definitions("MILVUS_WITH_PROMETHEUS")
endif ()
if (CMAKE_BUILD_TYPE STREQUAL "Release") if (CMAKE_BUILD_TYPE STREQUAL "Release")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -fPIC -DELPP_THREAD_SAFE -fopenmp") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -fPIC -DELPP_THREAD_SAFE -fopenmp")
if (MILVUS_GPU_VERSION) if (MILVUS_GPU_VERSION)
...@@ -176,9 +180,9 @@ endif () ...@@ -176,9 +180,9 @@ endif ()
if (MILVUS_GPU_VERSION) if (MILVUS_GPU_VERSION)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/conf/server_gpu_config.template ${CMAKE_CURRENT_SOURCE_DIR}/conf/server_config.yaml) 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) 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) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/conf/log_config.template ${CMAKE_CURRENT_SOURCE_DIR}/conf/log_config.conf)
......
...@@ -14,10 +14,11 @@ CUSTOMIZATION="OFF" # default use ori faiss ...@@ -14,10 +14,11 @@ CUSTOMIZATION="OFF" # default use ori faiss
CUDA_COMPILER=/usr/local/cuda/bin/nvcc CUDA_COMPILER=/usr/local/cuda/bin/nvcc
GPU_VERSION="OFF" #defaults to CPU version GPU_VERSION="OFF" #defaults to CPU version
WITH_MKL="OFF" WITH_MKL="OFF"
FAISS_ROOT="" FAISS_ROOT="" #FAISS root path
FAISS_SOURCE="BUNDLED" FAISS_SOURCE="BUNDLED"
WITH_PROMETHEUS="ON"
while getopts "p:d:t:f:ulrcgjhxzm" arg while getopts "p:d:t:f:ulrcgjhxzme" arg
do do
case $arg in case $arg in
p) p)
...@@ -63,7 +64,10 @@ do ...@@ -63,7 +64,10 @@ do
;; ;;
m) m)
WITH_MKL="ON" WITH_MKL="ON"
;; ;;
e)
WITH_PROMETHEUS="OFF"
;;
h) # help h) # help
echo " echo "
...@@ -80,10 +84,11 @@ parameter: ...@@ -80,10 +84,11 @@ parameter:
-j: use jfrog cache build directory(default: OFF) -j: use jfrog cache build directory(default: OFF)
-g: build GPU version(default: OFF) -g: build GPU version(default: OFF)
-m: build with MKL(default: OFF) -m: build with MKL(default: OFF)
-e: build without prometheus
-h: help -h: help
usage: usage:
./build.sh -p \${INSTALL_PREFIX} -t \${BUILD_TYPE} -f \${FAISS_ROOT} [-u] [-l] [-r] [-c] [-z] [-j] [-g] [-m] [-h] ./build.sh -p \${INSTALL_PREFIX} -t \${BUILD_TYPE} -f \${FAISS_ROOT} [-u] [-l] [-r] [-c] [-z] [-j] [-g] [-m] [-e] [-h]
" "
exit 0 exit 0
;; ;;
...@@ -118,6 +123,7 @@ CMAKE_CMD="cmake \ ...@@ -118,6 +123,7 @@ CMAKE_CMD="cmake \
-DCUSTOMIZATION=${CUSTOMIZATION} \ -DCUSTOMIZATION=${CUSTOMIZATION} \
-DMILVUS_GPU_VERSION=${GPU_VERSION} \ -DMILVUS_GPU_VERSION=${GPU_VERSION} \
-DFAISS_WITH_MKL=${WITH_MKL} \ -DFAISS_WITH_MKL=${WITH_MKL} \
-DMILVUS_WITH_PROMETHEUS=${WITH_PROMETHEUS} \
../" ../"
echo ${CMAKE_CMD} echo ${CMAKE_CMD}
${CMAKE_CMD} ${CMAKE_CMD}
......
...@@ -37,6 +37,7 @@ endforeach () ...@@ -37,6 +37,7 @@ endforeach ()
aux_source_directory(${MILVUS_ENGINE_SRC}/cache cache_files) aux_source_directory(${MILVUS_ENGINE_SRC}/cache cache_files)
aux_source_directory(${MILVUS_ENGINE_SRC}/config config_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 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 db_main_files)
aux_source_directory(${MILVUS_ENGINE_SRC}/db/engine db_engine_files) aux_source_directory(${MILVUS_ENGINE_SRC}/db/engine db_engine_files)
aux_source_directory(${MILVUS_ENGINE_SRC}/db/insert db_insert_files) aux_source_directory(${MILVUS_ENGINE_SRC}/db/insert db_insert_files)
...@@ -91,6 +92,11 @@ set(engine_files ...@@ -91,6 +92,11 @@ set(engine_files
${wrapper_files} ${wrapper_files}
) )
if (MILVUS_WITH_PROMETHEUS)
set(engine_files ${engine_files}
${metrics_prometheus_files})
endif ()
set(client_grpc_lib set(client_grpc_lib
grpcpp_channelz grpcpp_channelz
grpc++ grpc++
...@@ -115,7 +121,6 @@ set(third_party_libs ...@@ -115,7 +121,6 @@ set(third_party_libs
sqlite sqlite
${client_grpc_lib} ${client_grpc_lib}
yaml-cpp yaml-cpp
${prometheus_lib}
mysqlpp mysqlpp
zlib zlib
${boost_lib} ${boost_lib}
...@@ -138,13 +143,19 @@ if (MILVUS_GPU_VERSION) ...@@ -138,13 +143,19 @@ if (MILVUS_GPU_VERSION)
) )
endif () endif ()
if (MILVUS_ENABLE_PROFILING STREQUAL "ON") if (MILVUS_ENABLE_PROFILING)
set(third_party_libs ${third_party_libs} set(third_party_libs ${third_party_libs}
gperftools gperftools
libunwind libunwind
) )
endif () endif ()
if (MILVUS_WITH_PROMETHEUS)
set(third_party_libs ${third_party_libs}
${prometheus_lib}
)
endif ()
set(engine_libs set(engine_libs
pthread pthread
libgomp.a libgomp.a
...@@ -166,13 +177,22 @@ target_link_libraries(milvus_engine ...@@ -166,13 +177,22 @@ target_link_libraries(milvus_engine
${engine_libs} ${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 set(metrics_lib
yaml-cpp yaml-cpp
${prometheus_lib}
) )
if (MILVUS_WITH_PROMETHEUS)
set(metrics_lib ${metrics_lib}
${prometheus_lib}
)
endif ()
target_link_libraries(metrics ${metrics_lib}) target_link_libraries(metrics ${metrics_lib})
set(server_libs set(server_libs
......
...@@ -16,8 +16,10 @@ ...@@ -16,8 +16,10 @@
// under the License. // under the License.
#include "metrics/Metrics.h" #include "metrics/Metrics.h"
#include "PrometheusMetrics.h"
#include "server/Config.h" #include "server/Config.h"
#ifdef MILVUS_WITH_PROMETHEUS
#include "metrics/prometheus/PrometheusMetrics.h"
#endif
#include <string> #include <string>
...@@ -37,11 +39,15 @@ Metrics::CreateMetricsCollector() { ...@@ -37,11 +39,15 @@ Metrics::CreateMetricsCollector() {
config.GetMetricConfigCollector(collector_type_str); config.GetMetricConfigCollector(collector_type_str);
#ifdef MILVUS_WITH_PROMETHEUS
if (collector_type_str == "prometheus") { if (collector_type_str == "prometheus") {
return PrometheusMetrics::GetInstance(); return PrometheusMetrics::GetInstance();
} else { } else {
return MetricsBase::GetInstance(); return MetricsBase::GetInstance();
} }
#else
return MetricsBase::GetInstance();
#endif
} }
} // namespace server } // namespace server
......
...@@ -15,9 +15,9 @@ ...@@ -15,9 +15,9 @@
// specific language governing permissions and limitations // specific language governing permissions and limitations
// under the License. // under the License.
#include "metrics/PrometheusMetrics.h" #include "metrics/prometheus/PrometheusMetrics.h"
#include "SystemInfo.h"
#include "cache/GpuCacheMgr.h" #include "cache/GpuCacheMgr.h"
#include "metrics/SystemInfo.h"
#include "server/Config.h" #include "server/Config.h"
#include "utils/Log.h" #include "utils/Log.h"
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "MetricBase.h" #include "metrics/MetricBase.h"
#include "utils/Error.h" #include "utils/Error.h"
#define METRICS_NOW_TIME std::chrono::system_clock::now() #define METRICS_NOW_TIME std::chrono::system_clock::now()
......
...@@ -110,12 +110,18 @@ set(unittest_libs ...@@ -110,12 +110,18 @@ set(unittest_libs
pthread pthread
metrics metrics
gfortran 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 ()
set(unittest_libs ${unittest_libs}
dl
z
)
if (MILVUS_GPU_VERSION) if (MILVUS_GPU_VERSION)
include_directories("${CUDA_INCLUDE_DIRS}") include_directories("${CUDA_INCLUDE_DIRS}")
...@@ -135,4 +141,4 @@ add_subdirectory(db) ...@@ -135,4 +141,4 @@ add_subdirectory(db)
add_subdirectory(wrapper) add_subdirectory(wrapper)
add_subdirectory(metrics) add_subdirectory(metrics)
add_subdirectory(scheduler) add_subdirectory(scheduler)
add_subdirectory(server) add_subdirectory(server)
\ No newline at end of file
...@@ -18,10 +18,15 @@ ...@@ -18,10 +18,15 @@
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
set(test_files set(test_files
${CMAKE_CURRENT_SOURCE_DIR}/test_metricbase.cpp test_metricbase.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_metrics.cpp test_metrics.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_prometheus.cpp utils.cpp
${CMAKE_CURRENT_SOURCE_DIR}/utils.cpp) )
if (MILVUS_WITH_PROMETHEUS)
set(test_files ${test_files}
test_prometheus.cpp)
endif ()
add_executable(test_metrics add_executable(test_metrics
${common_files} ${common_files}
......
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
// specific language governing permissions and limitations // specific language governing permissions and limitations
// under the License. // under the License.
#include "metrics/PrometheusMetrics.h"
#include "server/Config.h" #include "server/Config.h"
#include "metrics/prometheus/PrometheusMetrics.h"
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <iostream> #include <iostream>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册