mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-08-26 16:28:00 +00:00
exposes metrics to stats
This commit is contained in:
@@ -871,6 +871,32 @@ struct uwsgi_stats *uwsgi_master_generate_stats() {
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (uwsgi.has_metrics) {
|
||||
if (uwsgi_stats_key(us, "metrics"))
|
||||
goto end;
|
||||
|
||||
if (uwsgi_stats_object_open(us))
|
||||
goto end;
|
||||
|
||||
uwsgi_rlock(uwsgi.metrics_lock);
|
||||
struct uwsgi_metric *um = uwsgi.metrics;
|
||||
while(um) {
|
||||
int64_t um_val = um->initial_value+*um->value;
|
||||
if (uwsgi_stats_keyslong(us, um->name, (long long) um_val)) {
|
||||
uwsgi_rwunlock(uwsgi.metrics_lock);
|
||||
goto end;
|
||||
}
|
||||
um = um->next;
|
||||
}
|
||||
uwsgi_rwunlock(uwsgi.metrics_lock);
|
||||
|
||||
if (uwsgi_stats_object_close(us))
|
||||
goto end;
|
||||
|
||||
if (uwsgi_stats_comma(us))
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (uwsgi_stats_key(us, "sockets"))
|
||||
goto end;
|
||||
|
||||
|
||||
+2
-16
@@ -406,23 +406,9 @@ int64_t uwsgi_metric_get(char *name, char *oid) {
|
||||
if (!um) return 0;
|
||||
|
||||
// now (in rlocked context) we get the value from
|
||||
// the external pointer or from the map
|
||||
//
|
||||
// the map
|
||||
uwsgi_rlock(uwsgi.metrics_lock);
|
||||
switch(um->collect_way) {
|
||||
case UWSGI_METRIC_PTR:
|
||||
ret = um->initial_value+*um->ptr;
|
||||
break;
|
||||
/*
|
||||
case UWSGI_METRIC_MANUAL:
|
||||
case UWSGI_METRIC_FUNC:
|
||||
case UWSGI_METRIC_FILE:
|
||||
*/
|
||||
default:
|
||||
ret = um->initial_value+*um->value;
|
||||
break;
|
||||
}
|
||||
|
||||
ret = um->initial_value+*um->value;
|
||||
// unlock
|
||||
uwsgi_rwunlock(uwsgi.metrics_lock);
|
||||
return ret;
|
||||
|
||||
+1
-1
@@ -504,7 +504,7 @@ static struct uwsgi_option uwsgi_base_options[] = {
|
||||
{"reload-on-exception-repr", required_argument, 0, "reload a worker when a specific exception type+value (language-specific) is raised", uwsgi_opt_add_string_list, &uwsgi.reload_on_exception_repr, 0},
|
||||
{"exception-handler", required_argument, 0, "add an exception handler", uwsgi_opt_add_string_list, &uwsgi.exception_handlers_instance, UWSGI_OPT_MASTER},
|
||||
|
||||
{"enable-metrics", required_argument, 0, "enable metrics subsystem", uwsgi_opt_true, &uwsgi.has_metrics, 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},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user