mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-09-06 05:31:44 +00:00
added restorable metrics
This commit is contained in:
+11
-2
@@ -385,13 +385,13 @@ static void *uwsgi_metrics_loop(void *arg) {
|
||||
// gather the new value based on the type of collection strategy
|
||||
switch(metric->collect_way) {
|
||||
case UWSGI_METRIC_PTR:
|
||||
*metric->value = *metric->ptr;
|
||||
*metric->value = metric->initial_value + *metric->ptr;
|
||||
break;
|
||||
// aliases are NOOP
|
||||
case UWSGI_METRIC_ALIAS:
|
||||
break;
|
||||
case UWSGI_METRIC_SUM:
|
||||
*metric->value = uwsgi_metric_sum(metric);
|
||||
*metric->value = metric->initial_value + uwsgi_metric_sum(metric);
|
||||
break;
|
||||
case UWSGI_METRIC_FILE:
|
||||
uwsgi_log("reading from file\n");
|
||||
@@ -736,5 +736,14 @@ void uwsgi_setup_metrics() {
|
||||
|
||||
if (uwsgi.metrics_dir) {
|
||||
uwsgi_log("memory allocated for metrics storage: %llu bytes (%llu MB)\n", uwsgi.metrics_cnt * uwsgi.page_size, (uwsgi.metrics_cnt * uwsgi.page_size)/1024/1024);
|
||||
if (uwsgi.metrics_dir_restore) {
|
||||
metric = uwsgi.metrics;
|
||||
while(metric) {
|
||||
if (metric->map) {
|
||||
metric->initial_value = strtoll(metric->map, NULL, 10);
|
||||
}
|
||||
metric = metric->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-1
@@ -511,8 +511,11 @@ static struct uwsgi_option uwsgi_base_options[] = {
|
||||
{"exception-handler", required_argument, 0, "add an exception handler", uwsgi_opt_add_string_list, &uwsgi.exception_handlers_instance, UWSGI_OPT_MASTER},
|
||||
|
||||
{"enable-metrics", no_argument, 0, "enable metrics subsystem", uwsgi_opt_true, &uwsgi.has_metrics, UWSGI_OPT_MASTER},
|
||||
{"metrics-dir", required_argument, 0, "exports metrics as text files in the specified directory", uwsgi_opt_set_str, &uwsgi.metrics_dir, UWSGI_OPT_METRICS|UWSGI_OPT_MASTER},
|
||||
{"metric", required_argument, 0, "add a custom metric", uwsgi_opt_add_string_list, &uwsgi.additional_metrics, UWSGI_OPT_METRICS|UWSGI_OPT_MASTER},
|
||||
{"metrics-dir", required_argument, 0, "exports metrics as text files in the specified directory", uwsgi_opt_set_str, &uwsgi.metrics_dir, UWSGI_OPT_METRICS|UWSGI_OPT_MASTER},
|
||||
{"metrics-dir-restore", no_argument, 0, "restore last value taken from the metrics dir", uwsgi_opt_true, &uwsgi.metrics_dir_restore, UWSGI_OPT_METRICS|UWSGI_OPT_MASTER},
|
||||
{"metric-dir", required_argument, 0, "exports metrics as text files in the specified directory", uwsgi_opt_set_str, &uwsgi.metrics_dir, UWSGI_OPT_METRICS|UWSGI_OPT_MASTER},
|
||||
{"metric-dir-restore", no_argument, 0, "restore last value taken from the metrics dir", uwsgi_opt_true, &uwsgi.metrics_dir_restore, UWSGI_OPT_METRICS|UWSGI_OPT_MASTER},
|
||||
|
||||
{"udp", required_argument, 0, "run the udp server on the specified address", uwsgi_opt_set_str, &uwsgi.udp_socket, UWSGI_OPT_MASTER},
|
||||
{"stats", required_argument, 0, "enable the stats server on the specified address", uwsgi_opt_set_str, &uwsgi.stats, UWSGI_OPT_MASTER},
|
||||
|
||||
Reference in New Issue
Block a user