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

dagit pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 9a42009  Adds squid log sub-codes for detail
9a42009 is described below

commit 9a420095e07f6c459555d8277c1f253caee8ecb6
Author: Derek Dagit <der...@oath.com>
AuthorDate: Tue Apr 10 15:36:58 2018 +0000

    Adds squid log sub-codes for detail
    
    The new log format symbol "crsc" (Cache Result Sub-Code) can provide
    more specific detail that can be hidden behind current Cache Result
    Codes.
    
    This change adds a code for one such case: redirect retries exceeded.
---
 doc/admin-guide/logging/cache-results.en.rst | 21 ++++++++++++++++++++-
 doc/admin-guide/logging/formatting.en.rst    |  3 +++
 proxy/hdrs/HTTP.h                            |  6 ++++++
 proxy/http/HttpSM.cc                         |  2 ++
 proxy/http/HttpTransact.h                    |  1 +
 proxy/logging/Log.cc                         |  9 +++++++++
 proxy/logging/LogAccess.cc                   |  5 +++++
 proxy/logging/LogAccess.h                    |  1 +
 proxy/logging/LogAccessHttp.cc               | 13 +++++++++++++
 proxy/logging/LogAccessHttp.h                |  1 +
 10 files changed, 61 insertions(+), 1 deletion(-)

diff --git a/doc/admin-guide/logging/cache-results.en.rst 
b/doc/admin-guide/logging/cache-results.en.rst
index fcbb84a..4edb2d3 100644
--- a/doc/admin-guide/logging/cache-results.en.rst
+++ b/doc/admin-guide/logging/cache-results.en.rst
@@ -26,7 +26,8 @@ In addition to recording information about client and origin 
requests and
 responses, |TS| exposes detailed information about cache interactions for every
 request which passes through a node. This information is incredibly important
 to establishing an efficient caching configuration, though it is only present
-in your logging output if the :ref:`crc <crc>` logging field is used.
+in your logging output if the :ref:`crc <crc>` logging field is used. For even
+more detail, see :ref:`crsc <crsc>`.
 
 Interpreting Cache Results
 ==========================
@@ -239,3 +240,21 @@ ERR_UNKNOWN
 
 The client connected, but subsequently disconnected without sending
 a request.
+
+.. _admin-logging-crsc:
+
+Cache Result Sub-Codes
+======================
+
+The following are all possible cache result sub-codes you will currently
+encounter in |TS| logging output, and what each one means. These sub-codes can
+offer more specific details that are not exposed in cache result codes.
+
+.. _crsc-num-redirects-exceeded:
+
+NUM_REDIRECTIONS_EXCEEDED
+-------------------------
+
+The origin server responded with a redirect, but following this redirect would
+exceed the configured maximum number of redirects allowed:
+:ts:cv:`proxy.config.http.number_of_redirections`
diff --git a/doc/admin-guide/logging/formatting.en.rst 
b/doc/admin-guide/logging/formatting.en.rst
index bbb3150..56676cc 100644
--- a/doc/admin-guide/logging/formatting.en.rst
+++ b/doc/admin-guide/logging/formatting.en.rst
@@ -147,6 +147,7 @@ Cache Details
 
 .. _cluc:
 .. _crc:
+.. _crsc:
 .. _chm:
 .. _cwr:
 .. _cwtr:
@@ -162,6 +163,8 @@ cluc  Client Request Cache Lookup URL, also known as the 
:term:`cache key`,
                      URL.
 crc   Proxy Cache    Cache Result Code. The result of |TS| attempting to obtain
                      the object from cache; :ref:`admin-logging-cache-results`.
+crsc  Proxy Cache    Cache Result Sub-Code. More specific code to complement 
the
+                     Cache Result Code.
 chm   Proxy Cache    Cache Hit-Miss status. Specifies the level of cache from
                      which this request was served by |TS|. Currently supports
                      only RAM (``HIT_RAM``) vs disk (``HIT_DISK``).
diff --git a/proxy/hdrs/HTTP.h b/proxy/hdrs/HTTP.h
index 597739f..7d11dc9 100644
--- a/proxy/hdrs/HTTP.h
+++ b/proxy/hdrs/HTTP.h
@@ -160,6 +160,12 @@ enum SquidLogCode {
   SQUID_LOG_ERR_UNKNOWN               = 'Z'
 };
 
+// squild log subcodes
+enum SquidSubcode {
+  SQUID_SUBCODE_EMPTY                     = '0',
+  SQUID_SUBCODE_NUM_REDIRECTIONS_EXCEEDED = '1',
+};
+
 /* squid hieratchy codes */
 enum SquidHierarchyCode {
   SQUID_HIER_EMPTY                           = '0',
diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc
index 2dfbba7..90cd2c5 100644
--- a/proxy/http/HttpSM.cc
+++ b/proxy/http/HttpSM.cc
@@ -1610,6 +1610,8 @@ HttpSM::handle_api_return()
         (redirection_tries <= t_state.txn_conf->number_of_redirections)) {
       ++redirection_tries;
       do_redirect();
+    } else if (redirection_tries > t_state.txn_conf->number_of_redirections) {
+      t_state.squid_codes.subcode = SQUID_SUBCODE_NUM_REDIRECTIONS_EXCEEDED;
     }
     // we have further processing to do
     //  based on what t_state.next_action is
diff --git a/proxy/http/HttpTransact.h b/proxy/http/HttpTransact.h
index 7150896..187531c 100644
--- a/proxy/http/HttpTransact.h
+++ b/proxy/http/HttpTransact.h
@@ -685,6 +685,7 @@ public:
 
   typedef struct _SquidLogInfo {
     SquidLogCode log_code          = SQUID_LOG_ERR_UNKNOWN;
+    SquidSubcode subcode           = SQUID_SUBCODE_EMPTY;
     SquidHierarchyCode hier_code   = SQUID_HIER_EMPTY;
     SquidHitMissCode hit_miss_code = SQUID_MISS_NONE;
 
diff --git a/proxy/logging/Log.cc b/proxy/logging/Log.cc
index f9730c8..8522806 100644
--- a/proxy/logging/Log.cc
+++ b/proxy/logging/Log.cc
@@ -597,6 +597,9 @@ Log::init_fields()
     SQUID_LOG_ERR_WEBFETCH_DETECTED, "ERR_WEBFETCH_DETECTED", 
SQUID_LOG_ERR_FUTURE_1, "ERR_FUTURE_1", SQUID_LOG_ERR_UNKNOWN,
     "ERR_UNKNOWN");
 
+  Ptr<LogFieldAliasTable> cache_subcode_map = make_ptr(new LogFieldAliasTable);
+  cache_subcode_map->init(2, SQUID_SUBCODE_EMPTY, "NONE", 
SQUID_SUBCODE_NUM_REDIRECTIONS_EXCEEDED, "NUM_REDIRECTIONS_EXCEEDED");
+
   Ptr<LogFieldAliasTable> cache_hit_miss_map = make_ptr(new 
LogFieldAliasTable);
   cache_hit_miss_map->init(21, SQUID_HIT_RESERVED, "HIT", SQUID_HIT_LEVEL_1, 
"HIT_RAM", // Also SQUID_HIT_RAM
                            SQUID_HIT_LEVEL_2, "HIT_SSD",                       
         // Also SQUID_HIT_SSD
@@ -616,6 +619,12 @@ Log::init_fields()
   global_field_list.add(field, false);
   ink_hash_table_insert(field_symbol_hash, "crc", field);
 
+  // Reuse the unmarshalling code from crc
+  field = new LogField("cache_result_subcode", "crsc", LogField::sINT, 
&LogAccess::marshal_cache_result_subcode,
+                       &LogAccess::unmarshal_cache_code, 
make_alias_map(cache_subcode_map));
+  global_field_list.add(field, false);
+  ink_hash_table_insert(field_symbol_hash, "crsc", field);
+
   field = new LogField("cache_hit_miss", "chm", LogField::sINT, 
&LogAccess::marshal_cache_hit_miss,
                        &LogAccess::unmarshal_cache_hit_miss, 
make_alias_map(cache_hit_miss_map));
   global_field_list.add(field, false);
diff --git a/proxy/logging/LogAccess.cc b/proxy/logging/LogAccess.cc
index 99111f4..f903435 100644
--- a/proxy/logging/LogAccess.cc
+++ b/proxy/logging/LogAccess.cc
@@ -260,6 +260,11 @@ LOG_ACCESS_DEFAULT_FIELD(marshal_cache_result_code, 
DEFAULT_INT_FIELD)
 /*-------------------------------------------------------------------------
   -------------------------------------------------------------------------*/
 
+LOG_ACCESS_DEFAULT_FIELD(marshal_cache_result_subcode, DEFAULT_INT_FIELD)
+
+/*-------------------------------------------------------------------------
+  -------------------------------------------------------------------------*/
+
 LOG_ACCESS_DEFAULT_FIELD(marshal_cache_hit_miss, DEFAULT_INT_FIELD)
 
 /*-------------------------------------------------------------------------
diff --git a/proxy/logging/LogAccess.h b/proxy/logging/LogAccess.h
index 2e3d97a..85fb08a 100644
--- a/proxy/logging/LogAccess.h
+++ b/proxy/logging/LogAccess.h
@@ -207,6 +207,7 @@ public:
   inkcoreapi virtual int marshal_proxy_resp_header_len(char *);    // INT
   inkcoreapi virtual int marshal_proxy_finish_status_code(char *); // INT
   inkcoreapi virtual int marshal_cache_result_code(char *);        // INT
+  inkcoreapi virtual int marshal_cache_result_subcode(char *);     // INT
   inkcoreapi virtual int marshal_proxy_host_port(char *);          // INT
   inkcoreapi virtual int marshal_cache_hit_miss(char *);           // INT
 
diff --git a/proxy/logging/LogAccessHttp.cc b/proxy/logging/LogAccessHttp.cc
index 059d8af..b9732f8 100644
--- a/proxy/logging/LogAccessHttp.cc
+++ b/proxy/logging/LogAccessHttp.cc
@@ -971,6 +971,19 @@ LogAccessHttp::marshal_cache_result_code(char *buf)
   -------------------------------------------------------------------------*/
 
 int
+LogAccessHttp::marshal_cache_result_subcode(char *buf)
+{
+  if (buf) {
+    SquidSubcode code = m_http_sm->t_state.squid_codes.subcode;
+    marshal_int(buf, (int64_t)code);
+  }
+  return INK_MIN_ALIGN;
+}
+
+/*-------------------------------------------------------------------------
+  -------------------------------------------------------------------------*/
+
+int
 LogAccessHttp::marshal_cache_hit_miss(char *buf)
 {
   if (buf) {
diff --git a/proxy/logging/LogAccessHttp.h b/proxy/logging/LogAccessHttp.h
index e998bb1..c10f260 100644
--- a/proxy/logging/LogAccessHttp.h
+++ b/proxy/logging/LogAccessHttp.h
@@ -93,6 +93,7 @@ public:
   int marshal_proxy_resp_status_code(char *) override;   // INT
   int marshal_proxy_finish_status_code(char *) override; // INT
   int marshal_cache_result_code(char *) override;        // INT
+  int marshal_cache_result_subcode(char *) override;     // INT
   int marshal_cache_hit_miss(char *) override;           // INT
 
   //

-- 
To stop receiving notification emails like this one, please contact
da...@apache.org.

Reply via email to