You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by gs...@apache.org on 2020/11/18 19:21:04 UTC

[qpid-dispatch] branch dev-protocol-adaptors-2 updated (40dc885 -> eeb828e)

This is an automated email from the ASF dual-hosted git repository.

gsim pushed a change to branch dev-protocol-adaptors-2
in repository https://gitbox.apache.org/repos/asf/qpid-dispatch.git.


    from 40dc885  DISPATCH-1846: Improve tcp adaptor basic connectivity test
     new 1022d9b  DISPATCH-1843: disambiguate http stats records
     new eeb828e  DISPATCH-1847: use remote host in stats for ingress

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/adaptors/http1/http1_request_info.c | 16 +---------------
 src/adaptors/http2/http2_adaptor.c      | 18 +++++++++++++++++-
 src/adaptors/http_common.c              | 27 ++++++++++++++++++++++++---
 src/adaptors/http_common.h              |  1 +
 4 files changed, 43 insertions(+), 19 deletions(-)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[qpid-dispatch] 01/02: DISPATCH-1843: disambiguate http stats records

Posted by gs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

gsim pushed a commit to branch dev-protocol-adaptors-2
in repository https://gitbox.apache.org/repos/asf/qpid-dispatch.git

commit 1022d9bc7faec17828dd4ed781710d388e9d3f39
Author: Gordon Sim <gs...@redhat.com>
AuthorDate: Wed Nov 18 13:37:08 2020 +0000

    DISPATCH-1843: disambiguate http stats records
---
 src/adaptors/http_common.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/adaptors/http_common.c b/src/adaptors/http_common.c
index 09fb165..60648ad 100644
--- a/src/adaptors/http_common.c
+++ b/src/adaptors/http_common.c
@@ -627,17 +627,23 @@ static qdr_http_request_info_t* _new_qdr_http_request_info_t()
     return record;
 }
 
-static char *_record_key(const char *host, const char* site, bool ingress)
+static char *_record_key(const char *host, const char *address, const char* site, bool ingress)
 {
     if (!host) return 0;
     size_t hostlen = strlen(host);
+    size_t addresslen = address ? strlen(address) + 1 : 0;
     size_t sitelen = site ? strlen(site) + 1 : 0;
-    char *key = malloc(hostlen + sitelen + 3);
+    char *key = malloc(hostlen + addresslen + sitelen + 3);
     size_t i = 0;
     key[i++] = ingress ? 'i' : 'o';
     key[i++] = '_';
     strcpy(key+i, host);
     i += hostlen;
+    if (address) {
+        key[i++] = '_';
+        strcpy(key+i, address);
+        i += (addresslen-1);
+    }
     if (site) {
         key[i++] = '@';
         strcpy(key+i, site);
@@ -654,7 +660,7 @@ void qd_http_record_request(qdr_core_t *core, const char * method, uint32_t stat
     record->address = address ? qd_strdup(address) : 0;
     record->host = host ? qd_strdup(host) : 0;
     record->site = remote_site ? qd_strdup(remote_site) : 0;
-    record->key = _record_key(record->host, local_site, record->ingress);
+    record->key = _record_key(record->host, record->address, local_site, record->ingress);
     record->requests = 1;
     record->bytes_in = bytes_in;
     record->bytes_out = bytes_out;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[qpid-dispatch] 02/02: DISPATCH-1847: use remote host in stats for ingress

Posted by gs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

gsim pushed a commit to branch dev-protocol-adaptors-2
in repository https://gitbox.apache.org/repos/asf/qpid-dispatch.git

commit eeb828e39391abf401e16b32e247715bec292658
Author: Gordon Sim <gs...@redhat.com>
AuthorDate: Wed Nov 18 19:17:55 2020 +0000

    DISPATCH-1847: use remote host in stats for ingress
---
 src/adaptors/http1/http1_request_info.c | 16 +---------------
 src/adaptors/http2/http2_adaptor.c      | 18 +++++++++++++++++-
 src/adaptors/http_common.c              | 15 +++++++++++++++
 src/adaptors/http_common.h              |  1 +
 4 files changed, 34 insertions(+), 16 deletions(-)

diff --git a/src/adaptors/http1/http1_request_info.c b/src/adaptors/http1/http1_request_info.c
index a2f4f38..2ea239f 100644
--- a/src/adaptors/http1/http1_request_info.c
+++ b/src/adaptors/http1/http1_request_info.c
@@ -24,20 +24,6 @@
 #include "dispatch_private.h"
 #include <inttypes.h>
 
-static char *_get_host_from_host_port(const char *host_port)
-{
-    char *end = strchr(host_port, ':');
-    if (end == NULL) {
-        return 0;
-    } else {
-        size_t len = end - host_port;
-        char *host = malloc(len + 1);
-        strncpy(host, host_port, len);
-        host[len] = '\0';
-        return host;
-    }
-}
-
 static void _http1_record_request_info(qdr_http1_adaptor_t *adaptor, qdr_http1_request_base_t *request, const char *host, bool ingress)
 {
      uint64_t in_octets, out_octets;
@@ -49,7 +35,7 @@ static void _http1_record_request_info(qdr_http1_adaptor_t *adaptor, qdr_http1_r
 
 void qdr_http1_record_client_request_info(qdr_http1_adaptor_t *adaptor, qdr_http1_request_base_t *request)
 {
-    char *host = _get_host_from_host_port(request->hconn->client.client_ip_addr);
+    char *host = qd_get_host_from_host_port(request->hconn->client.client_ip_addr);
     _http1_record_request_info(adaptor, request, host ? host : request->hconn->client.client_ip_addr, true);
     if (host) free(host);
 }
diff --git a/src/adaptors/http2/http2_adaptor.c b/src/adaptors/http2/http2_adaptor.c
index dd2638b..8e1b74a 100644
--- a/src/adaptors/http2/http2_adaptor.c
+++ b/src/adaptors/http2/http2_adaptor.c
@@ -790,10 +790,26 @@ static void send_settings_frame(qdr_http2_connection_t *conn)
 static void _http_record_request(qdr_http2_connection_t *conn, qdr_http2_stream_data_t *stream_data)
 {
     stream_data->stop = qd_timer_now();
+
+    bool free_remote_addr = false;
+    char *remote_addr;
+    if (conn->ingress) {
+        remote_addr = qd_get_host_from_host_port(conn->remote_address);
+        if (remote_addr) {
+            free_remote_addr = true;
+        } else {
+            remote_addr = conn->remote_address;
+        }
+    } else {
+        remote_addr = conn->config->host;
+    }
     qd_http_record_request(http2_adaptor->core, stream_data->method, stream_data->request_status,
-                           conn->config->address, conn->config->host, conn->config->site,
+                           conn->config->address, remote_addr, conn->config->site,
                            stream_data->remote_site, conn->ingress, stream_data->bytes_in, stream_data->bytes_out,
                            stream_data->stop && stream_data->start ? stream_data->stop - stream_data->start : 0);
+    if (free_remote_addr) {
+        free(remote_addr);
+    }
 }
 
 static int on_frame_recv_callback(nghttp2_session *session,
diff --git a/src/adaptors/http_common.c b/src/adaptors/http_common.c
index 60648ad..3d1d023 100644
--- a/src/adaptors/http_common.c
+++ b/src/adaptors/http_common.c
@@ -673,3 +673,18 @@ void qd_http_record_request(qdr_core_t *core, const char * method, uint32_t stat
     qd_log(qd_log_source(QD_HTTP_LOG_SOURCE), QD_LOG_DEBUG, "Adding http request info %s", record->key);
     _add_http_request_info(core, record);
 }
+
+char *qd_get_host_from_host_port(const char *host_port)
+{
+    char *end = strchr(host_port, ':');
+    if (end == NULL) {
+        return 0;
+    } else {
+        size_t len = end - host_port;
+        char *host = malloc(len + 1);
+        strncpy(host, host_port, len);
+        host[len] = '\0';
+        return host;
+    }
+}
+
diff --git a/src/adaptors/http_common.h b/src/adaptors/http_common.h
index 603e979..1fa5fd5 100644
--- a/src/adaptors/http_common.h
+++ b/src/adaptors/http_common.h
@@ -104,6 +104,7 @@ extern const char *qdr_http_request_info_columns[QDR_HTTP_REQUEST_INFO_COLUMN_CO
 void qd_http_record_request(qdr_core_t *core, const char * method, uint32_t status_code, const char *address, const char *host,
                             const char *local_site, const char *remote_site, bool ingress,
                             uint64_t bytes_in, uint64_t bytes_out, uint64_t latency);
+char *qd_get_host_from_host_port(const char *host_port);
 
 //
 // These functions are defined in their respective HTTP adaptors:


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org