优化fieldstat3句柄创建
This commit is contained in:
@@ -662,21 +662,6 @@ static void doh_process_req(const struct tfe_stream *stream, const struct tfe_ht
|
||||
}
|
||||
}
|
||||
|
||||
struct tfe_fieldstat_metric_t *doh_fieldstat_init(const char* profile, 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, section, "telegraf_port", (short *)&(telegraf_port));
|
||||
MESA_load_profile_string_nodef(profile, section, "telegraf_ip", telegraf_ip, sizeof(telegraf_ip));
|
||||
MESA_load_profile_string_def(profile, section, "app_name", app_name, sizeof(app_name), "metric");
|
||||
MESA_load_profile_int_def(profile, section, "cycle", &cycle, 1000);
|
||||
|
||||
return tfe_fieldstat_metric_create(telegraf_ip, telegraf_port, app_name, cycle, max_thread, g_doh_conf->local_logger);
|
||||
}
|
||||
|
||||
int doh_on_init(struct tfe_proxy *proxy)
|
||||
{
|
||||
const char *profile = "./conf/doh/doh.conf";
|
||||
@@ -695,7 +680,6 @@ int doh_on_init(struct tfe_proxy *proxy)
|
||||
|
||||
g_doh_conf->thread_num = tfe_proxy_get_work_thread_count();
|
||||
g_doh_conf->local_logger = MESA_create_runtime_log_handle("doh", RLOG_LV_DEBUG);
|
||||
g_doh_conf->fieldstat = doh_fieldstat_init(profile, "proxy_hits", g_doh_conf->thread_num);
|
||||
|
||||
g_doh_conf->gc_evbase = tfe_proxy_get_gc_evbase();
|
||||
g_doh_conf->fs_handle = tfe_proxy_get_fs_handle();
|
||||
@@ -876,7 +860,7 @@ int doh_on_data(const struct tfe_stream *stream, const struct tfe_http_session *
|
||||
void doh_send_metric_log(const struct tfe_stream * stream, struct doh_ctx *ctx, unsigned int thread_id)
|
||||
{
|
||||
size_t c2s_byte_num = 0, s2c_byte_num =0;
|
||||
struct tfe_fieldstat_metric_t *fieldstat = g_doh_conf->fieldstat;
|
||||
struct tfe_fieldstat_metric_t *fieldstat = (struct tfe_fieldstat_metric_t *)tfe_bussiness_resouce_get(DYNAMIC_FIELDSTAT);
|
||||
|
||||
fieldstat->tags[thread_id][TAG_RULE_ID].value_int = ctx->result->config_id;
|
||||
fieldstat->tags[thread_id][TAG_ACTION].value_int = 48;
|
||||
|
||||
@@ -69,7 +69,6 @@ struct doh_conf
|
||||
struct event *gcev;
|
||||
struct event_base *gc_evbase;
|
||||
screen_stat_handle_t fs_handle;
|
||||
struct tfe_fieldstat_metric_t *fieldstat;
|
||||
|
||||
struct maat *maat;
|
||||
struct maat_table tables[TYPE_MAX];
|
||||
|
||||
@@ -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++)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user