优化fieldstat3句柄创建

This commit is contained in:
fengweihao
2023-04-25 16:17:35 +08:00
parent 0bb38a6969
commit b9a8a45540
8 changed files with 48 additions and 51 deletions

View File

@@ -170,7 +170,6 @@ struct tsg_proxy_rt
struct event_base* gc_evbase;
struct event* gcev;
struct tfe_fieldstat_metric_t *fieldstat;
struct tsg_lua_script lua_script;
Ratelimiter_handle_t ratelimiter;
int enable_rate;
@@ -192,21 +191,6 @@ static void proxy_http_gc_cb(evutil_socket_t fd, short what, void * arg)
return;
}
struct tfe_fieldstat_metric_t *proxy_fieldstat_init(const char* profile_path, const char *section, int max_thread)
{
int cycle=0;
unsigned short telegraf_port=0;
char telegraf_ip[TFE_STRING_MAX]={0};
char app_name[TFE_STRING_MAX]={0};
MESA_load_profile_short_nodef(profile_path, section, "telegraf_port", (short *)&(telegraf_port));
MESA_load_profile_string_nodef(profile_path, section, "telegraf_ip", telegraf_ip, sizeof(telegraf_ip));
MESA_load_profile_string_def(profile_path, section, "app_name", app_name, sizeof(app_name), "metric");
MESA_load_profile_int_def(profile_path, section, "cycle", &cycle, 1000);
return tfe_fieldstat_metric_create(telegraf_ip, telegraf_port, app_name, cycle, max_thread, g_proxy_rt->local_logger);
}
static void proxy_http_stat_init(struct tsg_proxy_rt * pangu_runtime)
{
int i=0;
@@ -1188,8 +1172,6 @@ int proxy_http_init(struct tfe_proxy * proxy)
proxy_http_stat_init(g_proxy_rt);
g_proxy_rt->ratelimiter=ratelimit_handle_create(profile_path, "ratelimit");
g_proxy_rt->fieldstat=proxy_fieldstat_init(profile_path, "proxy_hits", g_proxy_rt->thread_num);
if(http_lua_handle_create(&g_proxy_rt->lua_script, g_proxy_rt->thread_num, "tfe") <0)
{
goto error_out;
@@ -3284,7 +3266,7 @@ void proxy_send_metric_log(const struct tfe_stream * stream, struct proxy_http_c
proxy_action_map[PX_ACTION_REJECT]="deny";
proxy_action_map[PX_ACTION_WHITELIST]="allow";
const char *manipulate_action_map[]= {"redirect","block","replace","hijack","insert","edit_element","run_script"};
struct tfe_fieldstat_metric_t *fieldstat = g_proxy_rt->fieldstat;
struct tfe_fieldstat_metric_t *fieldstat = (struct tfe_fieldstat_metric_t *)tfe_bussiness_resouce_get(DYNAMIC_FIELDSTAT);
for(i=0; i< ctx->n_enforce; i++)
{