Welcome! Log In Create A New Profile

Advanced

[PATCH] Added $http2_stream_id

J Carter
May 11, 2023 10:40PM
# HG changeset patch
# User jordanc.carter@outlook.com
# Date 1683858766 -3600
# Fri May 12 03:32:46 2023 +0100
# Node ID de1a1b4141e827984cbd0d2feb97f870c32ff289
# Parent b71e69247483631bd8fc79a47cc32b762625b1fb
Added $http2_stream_id

Useful for tracing multiplexed requests from client logs or pcaps
captured between client and nginx, to nginx's own access logs.

Also useful for matching multiplexed request's access log entries to
debug level error logs - which is particularly difficult to do.

diff --git a/src/http/v2/ngx_http_v2_module.c
b/src/http/v2/ngx_http_v2_module.c ---
a/src/http/v2/ngx_http_v2_module.c +++
b/src/http/v2/ngx_http_v2_module.c @@ -15,6 +15,8 @@

static ngx_int_t ngx_http_v2_variable(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data);
+static ngx_int_t ngx_http_v2_variable_stream_id(ngx_http_request_t *r,
+ ngx_http_variable_value_t *v, uintptr_t data);

static ngx_int_t ngx_http_v2_module_init(ngx_cycle_t *cycle);

@@ -213,6 +215,9 @@
{ ngx_string("http2"), NULL,
ngx_http_v2_variable, 0, 0, 0 },

+ { ngx_string("http2_stream_id"), NULL,
+ ngx_http_v2_variable_stream_id, 0, 0, 0 },
+
ngx_http_null_variable
};

@@ -271,6 +276,32 @@


static ngx_int_t
+ngx_http_v2_variable_stream_id(ngx_http_request_t *r,
+ ngx_http_variable_value_t *v, uintptr_t data)
+{
+ u_char *p;
+
+ if (!r->stream) {
+ v->not_found = 1;
+ return NGX_OK;
+ }
+
+ p = ngx_pnalloc(r->pool, NGX_INT32_LEN);
+ if (p == NULL) {
+ return NGX_ERROR;
+ }
+
+ v->len = ngx_sprintf(p, "%i", r->stream->node->id) - p;
+ v->valid = 1;
+ v->no_cacheable = 0;
+ v->not_found = 0;
+ v->data = p;
+
+ return NGX_OK;
+}
+
+
+static ngx_int_t
ngx_http_v2_module_init(ngx_cycle_t *cycle)
{
return NGX_OK;
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH] Added $http2_stream_id

J Carter 405 May 11, 2023 10:40PM

Re: [PATCH] Added $http2_stream_id

Maxim Dounin 148 May 14, 2023 10:42AM

Re: [PATCH] Added $http2_stream_id

J Carter 126 May 14, 2023 01:50PM

Re: [PATCH] Added $http2_stream_id

J Carter 103 May 14, 2023 07:00PM

Re: [PATCH] Added $http2_stream_id

Maxim Dounin 133 May 21, 2023 05:42PM

Re: [PATCH] Added $http2_stream_id

J Carter 126 May 28, 2023 12:44AM



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

Online Users

Guests: 308
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready