Welcome! Log In Create A New Profile

Advanced

[nginx] Upstream: implemented $upstream_bytes_sent.

December 13, 2018 09:26AM
details: https://hg.nginx.org/nginx/rev/e573d74299a0
branches:
changeset: 7429:e573d74299a0
user: Ruslan Ermilov <ru@nginx.com>
date: Thu Dec 13 17:23:07 2018 +0300
description:
Upstream: implemented $upstream_bytes_sent.

diffstat:

src/http/ngx_http_upstream.c | 15 +++++++++++++++
src/http/ngx_http_upstream.h | 1 +
2 files changed, 16 insertions(+), 0 deletions(-)

diffs (57 lines):

diff -r cbc5dee8d5d2 -r e573d74299a0 src/http/ngx_http_upstream.c
--- a/src/http/ngx_http_upstream.c Tue Dec 11 19:41:22 2018 +0300
+++ b/src/http/ngx_http_upstream.c Thu Dec 13 17:23:07 2018 +0300
@@ -409,6 +409,10 @@ static ngx_http_variable_t ngx_http_ups
ngx_http_upstream_response_length_variable, 1,
NGX_HTTP_VAR_NOCACHEABLE, 0 },

+ { ngx_string("upstream_bytes_sent"), NULL,
+ ngx_http_upstream_response_length_variable, 2,
+ NGX_HTTP_VAR_NOCACHEABLE, 0 },
+
#if (NGX_HTTP_CACHE)

{ ngx_string("upstream_cache_status"), NULL,
@@ -4136,6 +4140,10 @@ ngx_http_upstream_next(ngx_http_request_

if (u->peer.sockaddr) {

+ if (u->peer.connection) {
+ u->state->bytes_sent = u->peer.connection->sent;
+ }
+
if (ft_type == NGX_HTTP_UPSTREAM_FT_HTTP_403
|| ft_type == NGX_HTTP_UPSTREAM_FT_HTTP_404)
{
@@ -4319,6 +4327,10 @@ ngx_http_upstream_finalize_request(ngx_h
- u->pipe->preread_size;
u->state->response_length = u->pipe->read_length;
}
+
+ if (u->peer.connection) {
+ u->state->bytes_sent = u->peer.connection->sent;
+ }
}

u->finalize_request(r, rc);
@@ -5502,6 +5514,9 @@ ngx_http_upstream_response_length_variab
if (data == 1) {
p = ngx_sprintf(p, "%O", state[i].bytes_received);

+ } else if (data == 2) {
+ p = ngx_sprintf(p, "%O", state[i].bytes_sent);
+
} else {
p = ngx_sprintf(p, "%O", state[i].response_length);
}
diff -r cbc5dee8d5d2 -r e573d74299a0 src/http/ngx_http_upstream.h
--- a/src/http/ngx_http_upstream.h Tue Dec 11 19:41:22 2018 +0300
+++ b/src/http/ngx_http_upstream.h Thu Dec 13 17:23:07 2018 +0300
@@ -64,6 +64,7 @@ typedef struct {
ngx_msec_t queue_time;
off_t response_length;
off_t bytes_received;
+ off_t bytes_sent;

ngx_str_t *peer;
} ngx_http_upstream_state_t;
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] Upstream: implemented $upstream_bytes_sent.

ru@nginx.com 155 December 13, 2018 09:26AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 76
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready