You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2020/05/05 04:26:53 UTC

[trafficserver] branch 9.0.x updated (7908481 -> 1c1d29a)

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

zwoop pushed a change to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git.


    from 7908481  Remove tls_versions from host sni policy check
     new 3b4982b  Adding logging fields for collapsed forwarding metrics (#6708)
     new 1c1d29a  Add Access log fields for ProxyProtocol Context

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:
 doc/admin-guide/logging/formatting.en.rst |  17 +++++
 proxy/logging/Log.cc                      |  30 ++++++++
 proxy/logging/LogAccess.cc                | 110 ++++++++++++++++++++++++++++++
 proxy/logging/LogAccess.h                 |   6 ++
 4 files changed, 163 insertions(+)


[trafficserver] 02/02: Add Access log fields for ProxyProtocol Context

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

zwoop pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit 1c1d29abaf71a52641ccc411de7341b08550188a
Author: Sudheer Vinukonda <su...@apache.org>
AuthorDate: Tue Apr 28 08:56:20 2020 -0700

    Add Access log fields for ProxyProtocol Context
    
    (cherry picked from commit 583e5ed5f3db1e33075b8e5b880d6f6bf1e730f3)
---
 doc/admin-guide/logging/formatting.en.rst |  7 ++++
 proxy/logging/Log.cc                      | 15 +++++++++
 proxy/logging/LogAccess.cc                | 55 +++++++++++++++++++++++++++++++
 proxy/logging/LogAccess.h                 |  3 ++
 4 files changed, 80 insertions(+)

diff --git a/doc/admin-guide/logging/formatting.en.rst b/doc/admin-guide/logging/formatting.en.rst
index c81f435..242afe2 100644
--- a/doc/admin-guide/logging/formatting.en.rst
+++ b/doc/admin-guide/logging/formatting.en.rst
@@ -505,6 +505,13 @@ shi   Origin Server  IP address resolved via DNS by |TS| for the origin server.
 shn   Origin Server  Host name of the origin server.
 nhi   Origin Server  Destination IP address of next hop
 nhp   Origin Server  Destination port of next hop
+ppv   Proxy Protocol Proxy Protocol Version used (if any) between the Loadbalancer
+      Version        and |TS|
+pps   Proxy Protocol Source IP received via Proxy Protocol context from the LB to
+      Source IP      the |TS|
+ppd   Proxy Protocol Destination IP received via Proxy Protocol context from the LB
+      Dest IP        to the |TS|
+
 ===== ============== ==========================================================
 
 .. note::
diff --git a/proxy/logging/Log.cc b/proxy/logging/Log.cc
index 8be6bd7..4d46f6d 100644
--- a/proxy/logging/Log.cc
+++ b/proxy/logging/Log.cc
@@ -917,6 +917,21 @@ Log::init_fields()
   global_field_list.add(field, false);
   field_symbol_hash.emplace("ctpd", field);
 
+  field = new LogField("proxy_protocol_version", "ppv", LogField::dINT, &LogAccess::marshal_proxy_protocol_version,
+                       reinterpret_cast<LogField::UnmarshalFunc>(&LogAccess::unmarshal_str));
+  global_field_list.add(field, false);
+  field_symbol_hash.emplace("ppv", field);
+
+  field = new LogField("proxy_protocol_src_ip", "pps", LogField::IP, &LogAccess::marshal_proxy_protocol_src_ip,
+                       &LogAccess::unmarshal_ip_to_str);
+  global_field_list.add(field, false);
+  field_symbol_hash.emplace("ppsip", field);
+
+  field = new LogField("proxy_protocol_dst_ip", "ppd", LogField::IP, &LogAccess::marshal_proxy_protocol_dst_ip,
+                       &LogAccess::unmarshal_ip_to_str);
+  global_field_list.add(field, false);
+  field_symbol_hash.emplace("ppdip", field);
+
   field = new LogField("version_build_number", "vbn", LogField::STRING, &LogAccess::marshal_version_build_number,
                        (LogField::UnmarshalFunc)&LogAccess::unmarshal_str);
   global_field_list.add(field, false);
diff --git a/proxy/logging/LogAccess.cc b/proxy/logging/LogAccess.cc
index 08f5b0a..6d8d9e1 100644
--- a/proxy/logging/LogAccess.cc
+++ b/proxy/logging/LogAccess.cc
@@ -1315,6 +1315,61 @@ LogAccess::marshal_version_build_number(char *buf)
   -------------------------------------------------------------------------*/
 
 int
+LogAccess::marshal_proxy_protocol_version(char *buf)
+{
+  const char *version_str = nullptr;
+  int len                 = INK_MIN_ALIGN;
+
+  if (m_http_sm) {
+    NetVConnection::ProxyProtocolVersion ver = m_http_sm->t_state.pp_info.proxy_protocol_version;
+    switch (ver) {
+    case NetVConnection::ProxyProtocolVersion::V1:
+      version_str = "V1";
+      break;
+    case NetVConnection::ProxyProtocolVersion::V2:
+      version_str = "V2";
+      break;
+    case NetVConnection::ProxyProtocolVersion::UNDEFINED:
+    default:
+      version_str = "-";
+      break;
+    }
+    len = LogAccess::strlen(version_str);
+  }
+
+  if (buf) {
+    marshal_str(buf, version_str, len);
+  }
+  return len;
+}
+
+/*-------------------------------------------------------------------------
+  -------------------------------------------------------------------------*/
+int
+LogAccess::marshal_proxy_protocol_src_ip(char *buf)
+{
+  sockaddr const *ip = nullptr;
+  if (m_http_sm && m_http_sm->t_state.pp_info.proxy_protocol_version != NetVConnection::ProxyProtocolVersion::UNDEFINED) {
+    ip = &m_http_sm->t_state.pp_info.src_addr.sa;
+  }
+  return marshal_ip(buf, ip);
+}
+
+/*-------------------------------------------------------------------------
+  -------------------------------------------------------------------------*/
+int
+LogAccess::marshal_proxy_protocol_dst_ip(char *buf)
+{
+  sockaddr const *ip = nullptr;
+  if (m_http_sm && m_http_sm->t_state.pp_info.proxy_protocol_version != NetVConnection::ProxyProtocolVersion::UNDEFINED) {
+    ip = &m_http_sm->t_state.pp_info.dst_addr.sa;
+  }
+  return marshal_ip(buf, ip);
+}
+
+/*-------------------------------------------------------------------------
+  -------------------------------------------------------------------------*/
+int
 LogAccess::marshal_client_host_port(char *buf)
 {
   if (buf) {
diff --git a/proxy/logging/LogAccess.h b/proxy/logging/LogAccess.h
index b29e6f4..e5c14cb 100644
--- a/proxy/logging/LogAccess.h
+++ b/proxy/logging/LogAccess.h
@@ -255,6 +255,9 @@ public:
   inkcoreapi int marshal_cache_read_retries(char *);                          // INT
   inkcoreapi int marshal_cache_write_retries(char *);                         // INT
   inkcoreapi int marshal_cache_collapsed_connection_success(char *);          // INT
+  inkcoreapi int marshal_proxy_protocol_version(char *);                      // STR
+  inkcoreapi int marshal_proxy_protocol_src_ip(char *);                       // STR
+  inkcoreapi int marshal_proxy_protocol_dst_ip(char *);                       // STR
 
   // named fields from within a http header
   //


[trafficserver] 01/02: Adding logging fields for collapsed forwarding metrics (#6708)

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

zwoop pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit 3b4982b650984f8e1fd66c3b039e6cffbbf636f4
Author: Evan Zelkowitz <ez...@apache.org>
AuthorDate: Mon Apr 27 19:54:43 2020 -0700

    Adding logging fields for collapsed forwarding metrics (#6708)
    
    * Adding logging fields for collapsed forwarding metrics
    
    This adds 3 new log fields for transaction output (since collapsed forwarding is transaction based)
    * crra - The number of read retry attempts for this transaction. If no CF has been done (it has not attempted a write) then this is just the read lock contention.  If a write has been attempted then this value gets reset to 0 as it attempts more reads post-write-fail.
    * cwra - The number of write retry attempts. This will be either the number based on write lock contention, or it can be the max-write-retries+1. If it is max+1 that means that we have hit the max attempts because the lock was being held by another writer and so this transaction fell back to read retries and attempted to be collapsed
    * cccs - Collapsed connection success. * -1: Attempted CF but failed and went to origin
    *  0: Did not need to collapse, either already had to go to origin or was a hit
    *  1: Attempted CF and got a hit on retry read attempts
    
    * Remove creation of cache_sm object since logaccess cannot use its destructor.  Using the access functions directly
    
    * Changed log values:
    * -1: Attempted CF but failed and went to origin
    *  0: Did not need to collapse, either already had to go to origin or was a hit
    *  1: Attempted CF and got a hit on retry read attempts
    
    * Update documentation for cccs value
    
    (cherry picked from commit 0ec63fc9df3810b68ab80864bf3f559c56c02aac)
---
 doc/admin-guide/logging/formatting.en.rst | 10 ++++++
 proxy/logging/Log.cc                      | 15 +++++++++
 proxy/logging/LogAccess.cc                | 55 +++++++++++++++++++++++++++++++
 proxy/logging/LogAccess.h                 |  3 ++
 4 files changed, 83 insertions(+)

diff --git a/doc/admin-guide/logging/formatting.en.rst b/doc/admin-guide/logging/formatting.en.rst
index 8fa5edd..c81f435 100644
--- a/doc/admin-guide/logging/formatting.en.rst
+++ b/doc/admin-guide/logging/formatting.en.rst
@@ -151,6 +151,9 @@ Cache Details
 .. _chm:
 .. _cwr:
 .. _cwtr:
+.. _crra:
+.. _cwra:
+.. _cccs:
 
 These log fields reveal details of the |TS| proxy interaction with its own
 cache while attempting to service incoming client requests.
@@ -173,6 +176,13 @@ cwr   Proxy Cache    Cache Write Result. Specifies the result of attempting to
                      (``WL_MISS``), write interrupted (``INTR``), error while
                      writing (``ERR``), or cache write successful (``FIN``).
 cwt   Proxy Cache    Cache Write Transform Result.
+crra  Proxy Cache    Cache read retry attempts to read the object from cache.
+cwra  Proxy Cache    Cache write retry attempts to write a fresh or updated
+                     object to cache.
+cccs  Proxy Cache    Cache collapsed connection success;
+                     -1: collapsing was attempted but failed, request went upstream
+                     0: collapsing was unnecessary
+                     1: attempted to collapse and got a cache hit on subsequent read attempts
 ===== ============== ==========================================================
 
 .. _admin-logging-fields-txn:
diff --git a/proxy/logging/Log.cc b/proxy/logging/Log.cc
index 42f8dc3..8be6bd7 100644
--- a/proxy/logging/Log.cc
+++ b/proxy/logging/Log.cc
@@ -892,6 +892,21 @@ Log::init_fields()
   global_field_list.add(field, false);
   field_symbol_hash.emplace("ctid", field);
 
+  field = new LogField("cache_read_retry_attempts", "crra", LogField::dINT, &LogAccess::marshal_cache_read_retries,
+                       &LogAccess::unmarshal_int_to_str);
+  global_field_list.add(field, false);
+  field_symbol_hash.emplace("crra", field);
+
+  field = new LogField("cache_write_retry_attempts", "cwra", LogField::dINT, &LogAccess::marshal_cache_write_retries,
+                       &LogAccess::unmarshal_int_to_str);
+  global_field_list.add(field, false);
+  field_symbol_hash.emplace("cwra", field);
+
+  field = new LogField("cache_collapsed_connection_success", "cccs", LogField::dINT,
+                       &LogAccess::marshal_cache_collapsed_connection_success, &LogAccess::unmarshal_int_to_str);
+  global_field_list.add(field, false);
+  field_symbol_hash.emplace("cccs", field);
+
   field = new LogField("client_transaction_priority_weight", "ctpw", LogField::sINT,
                        &LogAccess::marshal_client_http_transaction_priority_weight, &LogAccess::unmarshal_int_to_str);
   global_field_list.add(field, false);
diff --git a/proxy/logging/LogAccess.cc b/proxy/logging/LogAccess.cc
index 32b2e19..08f5b0a 100644
--- a/proxy/logging/LogAccess.cc
+++ b/proxy/logging/LogAccess.cc
@@ -2635,6 +2635,61 @@ LogAccess::marshal_client_http_transaction_priority_dependence(char *buf)
   -------------------------------------------------------------------------*/
 
 int
+LogAccess::marshal_cache_read_retries(char *buf)
+{
+  if (buf) {
+    int64_t id = 0;
+    if (m_http_sm) {
+      id = m_http_sm->get_cache_sm().get_open_read_tries();
+    }
+    marshal_int(buf, id);
+  }
+  return INK_MIN_ALIGN;
+}
+
+/*-------------------------------------------------------------------------
+  -------------------------------------------------------------------------*/
+
+int
+LogAccess::marshal_cache_write_retries(char *buf)
+{
+  if (buf) {
+    int64_t id = 0;
+    if (m_http_sm) {
+      id = m_http_sm->get_cache_sm().get_open_write_tries();
+    }
+    marshal_int(buf, id);
+  }
+  return INK_MIN_ALIGN;
+}
+
+int
+LogAccess::marshal_cache_collapsed_connection_success(char *buf)
+{
+  if (buf) {
+    int64_t id = 0; // default - no collapse attempt
+    if (m_http_sm) {
+      SquidLogCode code = m_http_sm->t_state.squid_codes.log_code;
+
+      // We increment open_write_tries beyond the max when we want to jump back to the read state for collapsing
+      if ((m_http_sm->get_cache_sm().get_open_write_tries() > (m_http_sm->t_state.txn_conf->max_cache_open_write_retries)) &&
+          ((code == SQUID_LOG_TCP_HIT) || (code == SQUID_LOG_TCP_MEM_HIT) || (code == SQUID_LOG_TCP_DISK_HIT))) {
+        // Attempted collapsed connection and got a hit, success
+        id = 1;
+      } else if (m_http_sm->get_cache_sm().get_open_write_tries() > (m_http_sm->t_state.txn_conf->max_cache_open_write_retries)) {
+        // Attempted collapsed connection with no hit, failure, we can also get +2 retries in a failure state
+        id = -1;
+      }
+    }
+
+    marshal_int(buf, id);
+  }
+  return INK_MIN_ALIGN;
+}
+/*-------------------------------------------------------------------------
+  -------------------------------------------------------------------------*/
+
+int
 LogAccess::marshal_http_header_field(LogField::Container container, char *field, char *buf)
 {
   char *str        = nullptr;
diff --git a/proxy/logging/LogAccess.h b/proxy/logging/LogAccess.h
index e9090d3..b29e6f4 100644
--- a/proxy/logging/LogAccess.h
+++ b/proxy/logging/LogAccess.h
@@ -252,6 +252,9 @@ public:
   inkcoreapi int marshal_cache_lookup_url_canon(char *);                      // STR
   inkcoreapi int marshal_client_sni_server_name(char *);                      // STR
   inkcoreapi int marshal_version_build_number(char *);                        // STR
+  inkcoreapi int marshal_cache_read_retries(char *);                          // INT
+  inkcoreapi int marshal_cache_write_retries(char *);                         // INT
+  inkcoreapi int marshal_cache_collapsed_connection_success(char *);          // INT
 
   // named fields from within a http header
   //