summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/private/stream_internal.h1
-rw-r--r--src/entry/CMakeLists.txt2
-rw-r--r--src/extensions/sapp_metrics.cpp62
-rw-r--r--src/sapp_dev/sapp_init.c10
4 files changed, 54 insertions, 21 deletions
diff --git a/include/private/stream_internal.h b/include/private/stream_internal.h
index 246cbbe..dd8bf9a 100644
--- a/include/private/stream_internal.h
+++ b/include/private/stream_internal.h
@@ -472,6 +472,7 @@ int gdev_block_init(void);
int sapp_identify_broad_multicast_pkt(const void *this_layer_data, const raw_pkt_t *raw_pkt);
int sapp_identify_tunnel_inner_pkt(const raw_pkt_t *raw_pkt);
int sapp_metric_init(void);
+int sapp_metric_start(void);
void sapp_fs2_fuzzy_latency_update_per_entry(int thead_seq, int entry_id, long long time_cost);
int save_polling_inject_context(int mem_used_type, struct streaminfo_private *pstream_pr, const raw_pkt_t *raw_pkt);
void free_polling_inject_context(int mem_used_type, struct streaminfo_private *pstream_pr);
diff --git a/src/entry/CMakeLists.txt b/src/entry/CMakeLists.txt
index 4c5faf8..4003a52 100644
--- a/src/entry/CMakeLists.txt
+++ b/src/entry/CMakeLists.txt
@@ -26,7 +26,7 @@ endif()
add_executable(sapp sapp_main.c)
target_compile_options(sapp PUBLIC ${MEM_POOL_DEFINITIONS})
-target_link_libraries(sapp nsl pthread dl m pcap)
+target_link_libraries(sapp pthread dl pcap)
target_link_libraries(sapp MESA_handle_logger MESA_prof_load)
target_link_libraries(sapp sapp_assistant sapp_metrics)
target_link_libraries(sapp breakpad_mini)
diff --git a/src/extensions/sapp_metrics.cpp b/src/extensions/sapp_metrics.cpp
index 349124d..61d0540 100644
--- a/src/extensions/sapp_metrics.cpp
+++ b/src/extensions/sapp_metrics.cpp
@@ -297,7 +297,30 @@ static int sapp_fs2_init(sapp_global_t *global_paramters)
p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_OFFLOAD_STREAM] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Offload_STM");
p_fs2_rt->fs_id_count_array[SAPP_STAT_UDP_OFFLOAD_PKTS] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Offload_Pkt");
p_fs2_rt->fs_id_length_array[SAPP_STAT_UDP_OFFLOAD_BYTES] = FS_register(fs2_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, "Udp_Offload_Bit");
+
+ return 0;
+}
+
+static void sapp_fs2_destroy(sapp_global_t *global_paramters)
+{
+ sapp_config_profiling_metric_t *p_fs2_para = &global_paramters->config.profiling.fs2;
+ sapp_gval_individual_fixed_fs2_t *p_fs2_rt = &global_paramters->individual_fixed.fs2_runtime;
+ if (strlen(p_fs2_para->prometheus_service_uri) > 0 && p_fs2_para->prometheus_service_port > 0)
+ {
+ FS_library_destroy();
+ }
+
+ if (p_fs2_rt->fs_metric_handle)
+ {
+ FS_stop(&p_fs2_rt->fs_metric_handle);
+ }
+}
+
+static int sapp_fs2_start(sapp_global_t *global_paramters)
+{
+ sapp_gval_individual_fixed_fs2_t *p_fs2_rt = &global_paramters->individual_fixed.fs2_runtime;
+ void *fs2_handle = p_fs2_rt->fs_metric_handle;
if (unlikely(g_timestamp_record_sw))
{
for (int i = 0; i < g_packet_io_thread_num; i++)
@@ -342,26 +365,9 @@ static int sapp_fs2_init(sapp_global_t *global_paramters)
FS_set_para(fs2_handle, NOT_SEND_METRIC_TO_SERVER, &p_fs2_rt->fs_work_percent_id_array[i], sizeof(int));
}
FS_start(fs2_handle);
-
return 0;
}
-static void sapp_fs2_destroy(sapp_global_t *global_paramters)
-{
- sapp_config_profiling_metric_t *p_fs2_para = &global_paramters->config.profiling.fs2;
- sapp_gval_individual_fixed_fs2_t *p_fs2_rt = &global_paramters->individual_fixed.fs2_runtime;
- if (strlen(p_fs2_para->prometheus_service_uri) > 0 && p_fs2_para->prometheus_service_port > 0)
- {
- FS_library_destroy();
- }
-
- if (p_fs2_rt->fs_metric_handle)
- {
- FS_stop(&p_fs2_rt->fs_metric_handle);
- }
-}
-
-
void sapp_fs3_metric_set(int metric_idx, int metric_idy, long long value)
{
sapp_gval_individual_fixed_fs3_t *fs3_rt = &sapp_global_val->individual_fixed.fs3_runtime;
@@ -574,6 +580,14 @@ static int sapp_fs3_init(sapp_global_t *global_paramters)
NULL, 0);
fs3_rt->metrics_ids[1][SAPP_STAT_UDP_OFFLOAD_BYTES] = fieldstat_register(fs3_handle, FIELD_TYPE_COUNTER, "Udp_Offload_Bit",
NULL, 0);
+
+ return 0;
+}
+
+static int sapp_fs3_start(sapp_global_t *global_paramters)
+{
+ sapp_gval_individual_fixed_fs3_t *fs3_rt = &global_paramters->individual_fixed.fs3_runtime;
+ struct fieldstat_instance *fs3_handle = fs3_rt->fs_metric_handle;
// TODO: histogram for process lanency
fieldstat_instance_start(fs3_handle);
return 0;
@@ -606,6 +620,20 @@ int sapp_metric_init(void)
return ret;
}
+int sapp_metric_start(void)
+{
+ int ret = 0;
+ if( sapp_global_val->config.profiling.fs2.enabled == 1)
+ {
+ sapp_fs2_start(sapp_global_val);
+ }
+ if( sapp_global_val->config.profiling.fs3.enabled == 1)
+ {
+ sapp_fs3_start(sapp_global_val);
+ }
+ return ret;
+}
+
void sapp_metric_destroy(void)
{
diff --git a/src/sapp_dev/sapp_init.c b/src/sapp_dev/sapp_init.c
index 7b1d113..016f7c7 100644
--- a/src/sapp_dev/sapp_init.c
+++ b/src/sapp_dev/sapp_init.c
@@ -286,14 +286,18 @@ int MESA_platform_init(int argc, char *argv[])
sapp_dup_pkt_init();
- sapp_set_current_state(SAPP_STATE_PLUG_INITING);
- plugctrl_proc();
-
/* 2021-07-05, sapp_assistant_init()�ƶ���plugctrl_proc()֮��, Ҫ���Ѽ��ز������entry���б� */
if(sapp_metric_init() < 0){
return -1;
}
+ sapp_set_current_state(SAPP_STATE_PLUG_INITING);
+ plugctrl_proc();
+
+ if(sapp_metric_start() < 0){
+ return -1;
+ }
+
sapp_platform_finish_up(); /* ֧�ֶ�̬project tagע��, ���������в����ʼ����ɺ����, ��һЩƽ̨��ʼ���׶ε���β���� */
sapp_set_current_state(SAPP_STATE_PLUG_INITED);