Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion core/emperor.c
Original file line number Diff line number Diff line change
Expand Up @@ -2528,7 +2528,12 @@ static void emperor_send_stats(int fd) {
}

if (uwsgi.stats_http) {
if (uwsgi_send_http_stats(client_fd)) {
enum uwsgi_stats_format fmt;
if (uwsgi_stats_read_request(client_fd, &fmt)) {
close(client_fd);
return;
}
if (uwsgi_stats_send_http_header(client_fd, UWSGI_STATS_FORMAT_JSON)) {
close(client_fd);
return;
}
Expand Down
20 changes: 18 additions & 2 deletions core/stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,17 +365,33 @@ void uwsgi_send_stats(int fd, struct uwsgi_stats *(*func) (void)) {
return;
}

enum uwsgi_stats_format fmt = UWSGI_STATS_FORMAT_JSON;
if (uwsgi.stats_http) {
if (uwsgi_send_http_stats(client_fd)) {
if (uwsgi_stats_read_request(client_fd, &fmt)) {
close(client_fd);
return;
}
}

struct uwsgi_stats *us = func();
struct uwsgi_stats *us;
switch (fmt) {
case UWSGI_STATS_FORMAT_PROMETHEUS:
us = uwsgi_master_generate_stats_prometheus();
break;
default:
us = func();
break;
}

if (!us)
goto end;

if (uwsgi.stats_http) {
if (uwsgi_stats_send_http_header(client_fd, fmt)) {
goto end0;
}
}

size_t remains = us->pos;
off_t pos = 0;
while (remains > 0) {
Expand Down
Loading