summaryrefslogtreecommitdiff
path: root/plugin/business/pangu-http/src/pangu_web_cache.cpp
diff options
context:
space:
mode:
authorzhengchao <[email protected]>2018-11-23 09:40:42 +0800
committerzhengchao <[email protected]>2018-11-23 21:17:53 +0800
commit88849c9890797bfdcb57b976eea090e615516c22 (patch)
tree6239799a68590cae341ce6c5840600b77e246899 /plugin/business/pangu-http/src/pangu_web_cache.cpp
parent369bdebbadc3c15f2c242b68e21653dcdcb78c7c (diff)
#44 tfe和cache的FieldStat2输出到statsd server.
Diffstat (limited to 'plugin/business/pangu-http/src/pangu_web_cache.cpp')
-rw-r--r--plugin/business/pangu-http/src/pangu_web_cache.cpp25
1 files changed, 20 insertions, 5 deletions
diff --git a/plugin/business/pangu-http/src/pangu_web_cache.cpp b/plugin/business/pangu-http/src/pangu_web_cache.cpp
index 523fbf4..7bffab2 100644
--- a/plugin/business/pangu-http/src/pangu_web_cache.cpp
+++ b/plugin/business/pangu-http/src/pangu_web_cache.cpp
@@ -186,11 +186,11 @@ static void set_stat_spec(struct cache_stat_sepc* spec, const char* name, enum f
spec->calc_type=calc_type;
return;
}
-void cache_stat_init(struct cache_handle* cache)
+void cache_stat_init(struct cache_handle* cache,
+const char* statsd_server_ip, int statsd_server_port, const char*histogram_bins)
{
const char* fieldstat_output="./cache.fieldstat";
- const char* app_name="tango_cache";
- const char* obj_size_bins_KB="0.5,0.8,0.9,0.95";
+ const char* app_name="tfe_cache";
int value=0, i=0;
screen_stat_handle_t fs_handle=NULL;
@@ -201,7 +201,12 @@ void cache_stat_init(struct cache_handle* cache)
value=0;
FS_set_para(fs_handle, CREATE_THREAD, &value, sizeof(value));
FS_set_para(fs_handle, APP_NAME, app_name, strlen(app_name)+1);
- FS_set_para(fs_handle, HISTOGRAM_GLOBAL_BINS, obj_size_bins_KB, strlen(obj_size_bins_KB)+1);
+ FS_set_para(fs_handle, HISTOGRAM_GLOBAL_BINS, histogram_bins, strlen(histogram_bins)+1);
+ if(strlen(statsd_server_ip)>0 && statsd_server_port!=0)
+ {
+ 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));
+ }
cache->fs_handle=fs_handle;
@@ -693,7 +698,17 @@ struct cache_handle* create_web_cache_handle(const char* profile_path, const cha
0, cache);
cache->ref_feather=feather;
}
- cache_stat_init(cache);
+ char statsd_server_ip[TFE_SYMBOL_MAX];
+ char histogram_bins[TFE_SYMBOL_MAX];
+ int statsd_server_port=0;
+
+ MESA_load_profile_string_def(profile_path, section, "statsd_server", statsd_server_ip,
+ sizeof(statsd_server_ip), "");
+ MESA_load_profile_int_def(profile_path, section, "statsd_port", &(statsd_server_port), 0);
+ MESA_load_profile_string_def(profile_path, section, "histogram_bins",
+ histogram_bins, sizeof(histogram_bins), "0.5,0.8,0.9,0.95");
+
+ cache_stat_init(cache, statsd_server_ip, statsd_server_port, histogram_bins);
return cache;
error_out:
free(cache);