TSG-1806 tfe.conf/future.conf 均增加 statsd_format 配置项,用于调整 fieldstat 输出格式

This commit is contained in:
luwenpeng
2020-06-18 14:08:05 +08:00
parent cf42953af5
commit 7c23dca564
4 changed files with 22 additions and 1 deletions

View File

@@ -19,6 +19,7 @@ struct future_promise_instance
long long f_num; long long f_num;
int no_stats; int no_stats;
int statsd_cycle; int statsd_cycle;
int statsd_format;
MESA_htable_handle name_table; MESA_htable_handle name_table;
char statsd_server_ip[256]; char statsd_server_ip[256];
int statsd_server_port; int statsd_server_port;
@@ -74,6 +75,8 @@ void future_promise_library_init(const char* profile)
g_FP_instance.statsd_server_ip, sizeof(g_FP_instance.statsd_server_ip), ""); g_FP_instance.statsd_server_ip, sizeof(g_FP_instance.statsd_server_ip), "");
MESA_load_profile_int_def(profile, "STAT", "statsd_port", &(g_FP_instance.statsd_server_port), 0); MESA_load_profile_int_def(profile, "STAT", "statsd_port", &(g_FP_instance.statsd_server_port), 0);
MESA_load_profile_int_def(profile, "STAT", "statsd_cycle", &(g_FP_instance.statsd_cycle), 2); MESA_load_profile_int_def(profile, "STAT", "statsd_cycle", &(g_FP_instance.statsd_cycle), 2);
// FS_OUTPUT_STATSD=1, FS_OUTPUT_INFLUX_LINE=2
MESA_load_profile_int_def(profile, "STAT", "statsd_format", &(g_FP_instance.statsd_format), 1);
MESA_load_profile_string_def(profile, "STAT", "histogram_bins", MESA_load_profile_string_def(profile, "STAT", "histogram_bins",
g_FP_instance.histogram_bins, sizeof(g_FP_instance.histogram_bins), FP_HISTOGRAM_BINS); g_FP_instance.histogram_bins, sizeof(g_FP_instance.histogram_bins), FP_HISTOGRAM_BINS);
MESA_load_profile_int_def(profile, "STAT", "print_diff", MESA_load_profile_int_def(profile, "STAT", "print_diff",
@@ -89,6 +92,10 @@ void future_promise_library_init(const char* profile)
return; return;
} }
if (g_FP_instance.statsd_format != 1 && g_FP_instance.statsd_format != 2)
{
g_FP_instance.statsd_format = 1;
}
MESA_htable_handle htable = MESA_htable_born(); MESA_htable_handle htable = MESA_htable_born();
value=0; value=0;
@@ -119,6 +126,7 @@ void future_promise_library_init(const char* profile)
{ {
FS_set_para(fs, STATS_SERVER_IP, g_FP_instance.statsd_server_ip, strlen(g_FP_instance.statsd_server_ip)+1); FS_set_para(fs, STATS_SERVER_IP, g_FP_instance.statsd_server_ip, strlen(g_FP_instance.statsd_server_ip)+1);
FS_set_para(fs, STATS_SERVER_PORT, &(g_FP_instance.statsd_server_port), sizeof(g_FP_instance.statsd_server_port)); FS_set_para(fs, STATS_SERVER_PORT, &(g_FP_instance.statsd_server_port), sizeof(g_FP_instance.statsd_server_port));
FS_set_para(fs, STATS_FORMAT, &(g_FP_instance.statsd_format), sizeof(g_FP_instance.statsd_format));
} }
FS_set_para(fs, HISTOGRAM_GLOBAL_BINS, g_FP_instance.histogram_bins, strlen(g_FP_instance.histogram_bins)+1); FS_set_para(fs, HISTOGRAM_GLOBAL_BINS, g_FP_instance.histogram_bins, strlen(g_FP_instance.histogram_bins)+1);
g_FP_instance.fsid_f_num=FS_register(fs, FS_STYLE_FIELD, g_FP_instance.favorite, "futures"); g_FP_instance.fsid_f_num=FS_register(fs, FS_STYLE_FIELD, g_FP_instance.favorite, "futures");

View File

@@ -4,3 +4,5 @@ statsd_server=192.168.10.72
statsd_port=8092 statsd_port=8092
histogram_bins=0.50,0.80,0.9,0.95 histogram_bins=0.50,0.80,0.9,0.95
statsd_cycle=2 statsd_cycle=2
# FS_OUTPUT_STATSD=1, FS_OUTPUT_INFLUX_LINE=2
statsd_format=1

View File

@@ -72,6 +72,8 @@ level=10
statsd_server=192.168.10.72 statsd_server=192.168.10.72
statsd_port=8126 statsd_port=8126
statsd_cycle=2 statsd_cycle=2
# FS_OUTPUT_STATSD=1, FS_OUTPUT_INFLUX_LINE=2
statsd_format=1
[http] [http]
loglevel=20 loglevel=20

View File

@@ -346,13 +346,21 @@ int tfe_stat_init(struct tfe_proxy * proxy, const char * profile)
screen_stat_handle_t fs_handle = NULL; screen_stat_handle_t fs_handle = NULL;
char statsd_server_ip[TFE_SYMBOL_MAX]={0}; char statsd_server_ip[TFE_SYMBOL_MAX]={0};
char histogram_bins[TFE_SYMBOL_MAX]={0}; char histogram_bins[TFE_SYMBOL_MAX]={0};
int statsd_format=0;
int statsd_server_port=0; int statsd_server_port=0;
MESA_load_profile_string_def(profile, "STAT", "statsd_server", statsd_server_ip, MESA_load_profile_string_def(profile, "STAT", "statsd_server", statsd_server_ip,
sizeof(statsd_server_ip), ""); sizeof(statsd_server_ip), "");
MESA_load_profile_int_def(profile, "STAT", "statsd_port", &(statsd_server_port), 0); MESA_load_profile_int_def(profile, "STAT", "statsd_port", &(statsd_server_port), 0);
// FS_OUTPUT_STATSD=1, FS_OUTPUT_INFLUX_LINE=2
MESA_load_profile_int_def(profile, "STAT", "statsd_format", &(statsd_format), 1);
MESA_load_profile_string_def(profile, "STAT", "histogram_bins", MESA_load_profile_string_def(profile, "STAT", "histogram_bins",
histogram_bins, sizeof(histogram_bins), "0.5,0.8,0.9,0.95"); histogram_bins, sizeof(histogram_bins), "0.5,0.8,0.9,0.95");
if (statsd_format != 1 && statsd_format != 2)
{
statsd_format = 1;
}
fs_handle = FS_create_handle(); fs_handle = FS_create_handle();
FS_set_para(fs_handle, OUTPUT_DEVICE, fieldstat_output, (int)strlen(fieldstat_output) + 1); FS_set_para(fs_handle, OUTPUT_DEVICE, fieldstat_output, (int)strlen(fieldstat_output) + 1);
FS_set_para(fs_handle, APP_NAME, app_name, (int)strlen(app_name) + 1); FS_set_para(fs_handle, APP_NAME, app_name, (int)strlen(app_name) + 1);
@@ -365,6 +373,7 @@ int tfe_stat_init(struct tfe_proxy * proxy, const char * profile)
{ {
FS_set_para(fs_handle, STATS_SERVER_IP, statsd_server_ip, strlen(statsd_server_ip)+1); FS_set_para(fs_handle, STATS_SERVER_IP, statsd_server_ip, strlen(statsd_server_ip)+1);
FS_set_para(fs_handle, STATS_SERVER_PORT, &(statsd_server_port), sizeof(statsd_server_port)); FS_set_para(fs_handle, STATS_SERVER_PORT, &(statsd_server_port), sizeof(statsd_server_port));
FS_set_para(fs_handle, STATS_FORMAT, &statsd_format, sizeof(statsd_format));
} }
FS_set_para(fs_handle, HISTOGRAM_GLOBAL_BINS, histogram_bins, strlen(histogram_bins)+1); FS_set_para(fs_handle, HISTOGRAM_GLOBAL_BINS, histogram_bins, strlen(histogram_bins)+1);