summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfumingwei <[email protected]>2023-03-13 18:06:52 +0800
committerfumingwei <[email protected]>2023-03-13 18:06:52 +0800
commit00b85a300d7afb70d71373b9457530de08bc96eb (patch)
tree1998add4254c51ce14392279d5919c8e5d90c8e8
parent86c09082ae13bb4aebf7bdcd38edd62e16a0e809 (diff)
feature:修改出现的笔误
-rwxr-xr-xCMakeLists.txt7
-rw-r--r--inc/fieldstat.h19
-rw-r--r--src/fieldstat.cpp5
-rw-r--r--test/fieldstat_test.cpp2
4 files changed, 17 insertions, 16 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6a023d2..a48d527 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,9 +1,6 @@
cmake_minimum_required (VERSION 2.8)
-set(lib_name MESA_field_stat2)
-
-set(CMAKE_CXX_STANDARD 11)
-set(CMAKE_C_STANDARD 11)
+set(lib_name fieldstat)
project (${lib_name})
@@ -59,7 +56,7 @@ set_target_properties(${lib_name}_static PROPERTIES OUTPUT_NAME ${lib_name})
install(TARGETS ${lib_name}_shared LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib COMPONENT LIBRARIES)
install(TARGETS ${lib_name}_static LIBRARY ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib COMPONENT LIBRARIES)
-install(FILES inc/field_stat2.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/MESA COMPONENT HEADER)
+install(FILES inc/fieldstat.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/MESA COMPONENT HEADER)
include(Package)
diff --git a/inc/fieldstat.h b/inc/fieldstat.h
index af28345..388d1ca 100644
--- a/inc/fieldstat.h
+++ b/inc/fieldstat.h
@@ -4,6 +4,9 @@
extern "C"
{
#endif
+
+#define TABLE_COLUMN_MAX_SIZE 64
+
enum field_type
{
FIELD_TYPE_COUNTER,
@@ -16,13 +19,13 @@ struct fieldstat_instance;
struct metric_id_list
{
int count;
- int id[64]; // define marco
+ int id[TABLE_COLUMN_MAX_SIZE]; // define marco
};
/**
* Create fieldstat instance.
* @param name The instance name.
- * @return Instance id. NULL is failed, Not NULL is successd.
+ * @return Instance ptr. NULL is failed, Not NULL is successd.
*/
struct fieldstat_instance * fieldstat_instance_create(const char *name);
/**
@@ -67,7 +70,7 @@ int fieldstat_set_local_output(struct fieldstat_instance *instance, const char *
* @param instance The Fieldstat instance.
* @return -1 is failed. 0 is success.
*/
-int fieldstat_background_thead_disable(struct fieldstat_instance *instance);
+int fieldstat_background_thread_disable(struct fieldstat_instance *instance);
/**
* Set the output interval in seconds
* @param seconds In seconds.
@@ -82,7 +85,7 @@ int fieldstat_set_output_interval(struct fieldstat_instance *instance, int secon
* @param tag_key Tag key array
* @param tag_value Tag key array
* @param n_tag size of tag_key[] and tag_value[]
- * @return -1 is failed. 0 is success.
+ * @return metric id. -1 is failed. >=0 is success.
*/
int fieldstat_register(struct fieldstat_instance *instance, enum field_type type, const char *field_name, const char *tag_key[], const char *tag_value[], size_t n_tag);
/**
@@ -92,7 +95,7 @@ int fieldstat_register(struct fieldstat_instance *instance, enum field_type type
* @param column_name column name array.
* @param column_type column type array. Type in [counter, gauge]
* @param n_column size of column_type[] and column_name[]
- * @return -1 is failed. 0 is success.
+ * @return metric id. -1 is failed. >=0 is success.
*/
int fieldstat_register_table(struct fieldstat_instance *instance, const char *name, const char *column_name[], enum field_type column_type[], size_t n_column);
/**
@@ -103,7 +106,7 @@ int fieldstat_register_table(struct fieldstat_instance *instance, const char *na
* @param tag_key Tag key array
* @param tag_value Tag key array
* @param n_tag size of tag_key[] and tag_value[]
- * @return -1 is failed. 0 is success.
+ * @return metric id. -1 is failed. >=0 is success.
*/
struct metric_id_list fieldstat_register_table_metrics(struct fieldstat_instance * instance, int table_id, const char *line_name, const char *tag_key[], const char *tag_value[],size_t n_tag);
/**
@@ -149,7 +152,7 @@ void fieldstat_passive_output(struct fieldstat_instance *instance);
* @param tag_value the array of tag value
* @param n_tag the number of tags
* @param quantiles the quantiles of summary output
- * @return metric id: -1 is failed, > 0 is success
+ * @return metric id: -1 is failed, >= 0 is success
* the output.
*/
int fieldstat_register_histogram(struct fieldstat_instance *instance, const char *field_name, const char *tag_key[], const char *tag_value[], size_t n_tag,
@@ -163,7 +166,7 @@ int fieldstat_register_histogram(struct fieldstat_instance *instance, const char
* @param tag_value the array of tag value
* @param n_tag the number of tags
* @param quantiles the quantiles of summary output
- * @return metric id: -1 is failed, > 0 is success
+ * @return metric id: -1 is failed, >= 0 is success
* the output.
*/
int fieldstat_register_summary(struct fieldstat_instance *instance, const char *field_name, const char *tag_key[], const char *tag_value[], size_t n_tag,
diff --git a/src/fieldstat.cpp b/src/fieldstat.cpp
index d4687e1..d1bf882 100644
--- a/src/fieldstat.cpp
+++ b/src/fieldstat.cpp
@@ -225,7 +225,7 @@ int fieldstat_set_output_interval(struct fieldstat_instance *instance, int secon
return 0;
}
-int fieldstat_background_thead_disable(struct fieldstat_instance *instance)
+int fieldstat_background_thread_disable(struct fieldstat_instance *instance)
{
if(instance->running == 1)
{
@@ -442,13 +442,14 @@ void fieldstat_instance_start(struct fieldstat_instance *instance)
struct fieldstat_instance * fieldstat_instance_create(const char *name)
{
- struct fieldstat_instance *instance = (struct fieldstat_instance *)calloc(sizeof(struct fieldstat_instance),1);
+ struct fieldstat_instance *instance = NULL;
if(strlen(name) >= INSTANCE_NAME_LEN)
{
return NULL;
}
+ instance = (struct fieldstat_instance *)calloc(sizeof(struct fieldstat_instance),1);
strcpy(instance->name, name);
instance->running = 0;
instance->output_interval_s = 2;
diff --git a/test/fieldstat_test.cpp b/test/fieldstat_test.cpp
index fc72f9a..8a406ff 100644
--- a/test/fieldstat_test.cpp
+++ b/test/fieldstat_test.cpp
@@ -67,7 +67,7 @@ int main(int argc, char *argv[])
printf("Set output_interval failed!\n");
}
- // ret = fieldstat_background_thead_disable(test_instance);
+ // ret = fieldstat_background_thread_disable(test_instance);
// if(ret == -1)
// {
// printf("Set backgroud thread disable failed!\n");