summaryrefslogtreecommitdiff
path: root/src/plugin
diff options
context:
space:
mode:
authorlijia <[email protected]>2021-07-09 17:48:39 +0800
committerlijia <[email protected]>2021-07-09 17:48:39 +0800
commit41724299de7b703145510ddeecc75b0bf099ec3c (patch)
tree987519fe06a750cefda44875a177399eb4f910aa /src/plugin
parent1df8b36e679069d7c1b2760d33ca14ec3b4a61fc (diff)
TSG-6871, 支持按每个插件的entry统计单包处理延时.
Diffstat (limited to 'src/plugin')
-rw-r--r--src/plugin/src/plugin.c27
-rw-r--r--src/plugin/src/plugin_manage.c7
2 files changed, 22 insertions, 12 deletions
diff --git a/src/plugin/src/plugin.c b/src/plugin/src/plugin.c
index 4f152fe..4adcfd1 100644
--- a/src/plugin/src/plugin.c
+++ b/src/plugin/src/plugin.c
@@ -1534,7 +1534,7 @@ char plugin_call_appentry(stSessionFunInfo* funelem_session,stSessionInfo* sessi
{
char rec=APP_STATE_DROPME;
struct timespec before_ts, after_ts;
- long long time_spent_us;
+ long long time_spent_ns;
char debug_raw_pkt_string[256];
if(g_business_plug_info==NULL)
@@ -1552,18 +1552,27 @@ char plugin_call_appentry(stSessionFunInfo* funelem_session,stSessionInfo* sessi
if(g_timestamp_record_sw){
//plug_record_start_time(g_business_plug_info->plugid, thread_seq);
clock_gettime(CLOCK_REALTIME, &after_ts);
- time_spent_us = (after_ts.tv_sec*1000000000 + after_ts.tv_nsec)/1000 - (before_ts.tv_sec*1000000000 + before_ts.tv_nsec)/1000;
- if(time_spent_us >= g_timestamp_record_threshold){
- if(NULL == a_packet ){
- sapp_runtime_log(RLOG_LV_FATAL, "plug_name:%s, entry:%s, pkt process latency:%lld us",
+ time_spent_ns = (after_ts.tv_sec*1000000000 + after_ts.tv_nsec) - (before_ts.tv_sec*1000000000 + before_ts.tv_nsec);
+ if(sapp_global_val->config.profiling.pkt_latency_accurate_enable != 0){
+ sapp_fs2_set_plug_entry_latency(funelem_session->entry_id, time_spent_ns);
+ }else{
+ sapp_fs2_fuzzy_latency_update_per_entry(thread_seq, funelem_session->entry_id, time_spent_ns);
+ }
+
+ if(time_spent_ns >= g_timestamp_record_threshold){
+ if(NULL == a_packet || (SESSION_STATE_CLOSE & session_info->session_state)){
+ sapp_runtime_log(RLOG_LV_FATAL, "plug_name:%s, entry:%s, session close process latency:%lld ns, %s",
g_plug_global_entry[funelem_session->entry_id].plug_name,
- g_plug_global_entry[funelem_session->entry_id].plug_entry_name, time_spent_us);
+ g_plug_global_entry[funelem_session->entry_id].plug_entry_name, time_spent_ns,
+ printaddr(&a_stream->addr, thread_seq));
+
}else{
const struct streaminfo_private *stream_pr = (struct streaminfo_private *)a_stream;
- sapp_runtime_log(RLOG_LV_FATAL, "plug_name:%s, entry:%s, pkt process latency:%lld us, %s",
+ sapp_rawpkt_ntop(stream_pr->raw_pkt, 1, debug_raw_pkt_string, sizeof(debug_raw_pkt_string));
+ sapp_runtime_log(RLOG_LV_FATAL, "plug_name:%s, entry:%s, pkt process latency:%lld ns, %s",
g_plug_global_entry[funelem_session->entry_id].plug_name,
- g_plug_global_entry[funelem_session->entry_id].plug_entry_name, time_spent_us,
- sapp_rawpkt_ntop(stream_pr->raw_pkt, 1, debug_raw_pkt_string, sizeof(debug_raw_pkt_string)));
+ g_plug_global_entry[funelem_session->entry_id].plug_entry_name,
+ time_spent_ns,debug_raw_pkt_string);
}
}
}
diff --git a/src/plugin/src/plugin_manage.c b/src/plugin/src/plugin_manage.c
index 0709f88..f0ef81a 100644
--- a/src/plugin/src/plugin_manage.c
+++ b/src/plugin/src/plugin_manage.c
@@ -1,6 +1,7 @@
#include "sapp_api.h"
#include "sapp_declaration.h"
#include "sapp_private_api.h"
+
/*
sapp挂载插件失败后,仅写错误日志,然后继续加载下一个插件,
即便所有插件都加载失败,仍然会处理流量,空跑�? 有时候必要的插件如果不加载,sapp运行已无意义,应该退出,这样其他监控程序可以告警�? 而仅写一条错误日志,不方便通过第三方监测程序发现问题�?
@@ -43,8 +44,8 @@ struct plug_manage_key_t{
static MESA_htable_handle g_plug_manage_htable;
-plug_global_entry_t g_plug_global_entry[MAX_PLUG_ENTRY_NUM];
-static int g_plug_global_entry_index;
+plug_global_entry_t g_plug_global_entry[SAPP_MAX_PLUG_ENTRY_NUM];
+int g_plug_global_entry_index;
/*
TODO1:
插件加载失败是否退�? 取决于g_plug_uniq_htable中的necessary是否设置;
@@ -74,7 +75,7 @@ int plug_mange_get_entry_id(const char *plug_name, const char *plug_entry_name)
{
int this_entry_id;
- if(g_plug_global_entry_index >= MAX_PLUG_ENTRY_NUM){
+ if(g_plug_global_entry_index >= SAPP_MAX_PLUG_ENTRY_NUM){
sapp_runtime_log(RLOG_LV_FATAL, "plug entry number overflow! no valid id for %s->%s\n", plug_name, plug_entry_name);
return -1;
}