Skip to content

Commit

Permalink
TS-3524 Add a new log tag, %<cluc>, which is the cache lookup URL (key)
Browse files Browse the repository at this point in the history
  • Loading branch information
zwoop committed Jun 11, 2015
1 parent 983e080 commit 719d55b
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 12 deletions.
5 changes: 5 additions & 0 deletions proxy/logging/Log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,11 @@ Log::init_fields()
global_field_list.add(field, false);
ink_hash_table_insert(field_symbol_hash, "cqhl", field);

field = new LogField("cache_lookup_url_canonical", "cluc", LogField::STRING, &LogAccess::marshal_cache_lookup_url_canon,
(LogField::UnmarshalFunc) & LogAccess::unmarshal_str);
global_field_list.add(field, false);
ink_hash_table_insert(field_symbol_hash, "cluc", field);

field = new LogField("client_req_body_len", "cqbl", LogField::sINT, &LogAccess::marshal_client_req_body_len,
&LogAccess::unmarshal_int_to_str);
global_field_list.add(field, false);
Expand Down
7 changes: 7 additions & 0 deletions proxy/logging/LogAccess.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,14 @@ LogAccess::marshal_client_host_ip(char *buf)

/*-------------------------------------------------------------------------
-------------------------------------------------------------------------*/
int
LogAccess::marshal_cache_lookup_url_canon(char *buf)
{
DEFAULT_STR_FIELD;
}

/*-------------------------------------------------------------------------
-------------------------------------------------------------------------*/
int
LogAccess::marshal_client_host_port(char *buf)
{
Expand Down
13 changes: 7 additions & 6 deletions proxy/logging/LogAccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,13 @@ class LogAccess

// other fields
//
inkcoreapi virtual int marshal_transfer_time_ms(char *); // INT
inkcoreapi virtual int marshal_transfer_time_s(char *); // INT
inkcoreapi virtual int marshal_file_size(char *); // INT
inkcoreapi virtual int marshal_plugin_identity_id(char *); // INT
inkcoreapi virtual int marshal_plugin_identity_tag(char *); // STR
int marshal_entry_type(char *); // INT
inkcoreapi virtual int marshal_transfer_time_ms(char *); // INT
inkcoreapi virtual int marshal_transfer_time_s(char *); // INT
inkcoreapi virtual int marshal_file_size(char *); // INT
inkcoreapi virtual int marshal_plugin_identity_id(char *); // INT
inkcoreapi virtual int marshal_plugin_identity_tag(char *); // STR
inkcoreapi virtual int marshal_cache_lookup_url_canon(char *); // STR
int marshal_entry_type(char *); // INT


// named fields from within a http header
Expand Down
40 changes: 39 additions & 1 deletion proxy/logging/LogAccessHttp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ LogAccessHttp::LogAccessHttp(HttpSM *sm)
m_client_req_url_canon_len(0), m_client_req_unmapped_url_canon_str(NULL), m_client_req_unmapped_url_canon_len(-1),
m_client_req_unmapped_url_path_str(NULL), m_client_req_unmapped_url_path_len(-1), m_client_req_unmapped_url_host_str(NULL),
m_client_req_unmapped_url_host_len(-1), m_client_req_url_path_str(NULL), m_client_req_url_path_len(0),
m_proxy_resp_content_type_str(NULL), m_proxy_resp_content_type_len(0)
m_proxy_resp_content_type_str(NULL), m_proxy_resp_content_type_len(0), m_cache_lookup_url_canon_str(NULL),
m_cache_lookup_url_canon_len(0)
{
ink_assert(m_http_sm != NULL);
}
Expand Down Expand Up @@ -236,6 +237,22 @@ LogAccessHttp::marshal_client_host_ip(char *buf)
return marshal_ip(buf, &m_http_sm->t_state.client_info.addr.sa);
}

/*-------------------------------------------------------------------------
-------------------------------------------------------------------------*/
int
LogAccessHttp::marshal_cache_lookup_url_canon(char *buf)
{
int len = INK_MIN_ALIGN;

validate_lookup_url();
len = round_strlen(m_cache_lookup_url_canon_len + 1); // +1 for eos
if (buf) {
marshal_mem(buf, m_cache_lookup_url_canon_str, m_cache_lookup_url_canon_len, len);
}

return len;
}

/*-------------------------------------------------------------------------
-------------------------------------------------------------------------*/

Expand Down Expand Up @@ -333,6 +350,27 @@ LogAccessHttp::validate_unmapped_url_path(void)
}


/*-------------------------------------------------------------------------
Private utility function to validate m_cache_lookup_url_canon_str &
m_cache_lookup__url_canon_len fields.
-------------------------------------------------------------------------*/
void
LogAccessHttp::validate_lookup_url(void)
{
if (m_cache_lookup_url_canon_len < 0) {
if (m_http_sm->t_state.cache_info.lookup_url_storage.valid()) {
int lookup_url_len;
char *lookup_url = m_http_sm->t_state.cache_info.lookup_url_storage.string_get_ref(&lookup_url_len);

if (lookup_url && lookup_url[0] != 0) {
m_cache_lookup_url_canon_str = LogUtils::escapify_url(&m_arena, lookup_url, lookup_url_len, &m_cache_lookup_url_canon_len);
}
} else {
m_cache_lookup_url_canon_len = 0;
}
}
}

/*-------------------------------------------------------------------------
This is the method, url, and version all rolled into one. Use the
respective marshalling routines to do the job.
Expand Down
15 changes: 10 additions & 5 deletions proxy/logging/LogAccessHttp.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,12 @@ class LogAccessHttp : public LogAccess
//
// other fields
//
virtual int marshal_transfer_time_ms(char *); // INT
virtual int marshal_transfer_time_s(char *); // INT
virtual int marshal_file_size(char *); // INT
virtual int marshal_plugin_identity_id(char *); // INT
virtual int marshal_plugin_identity_tag(char *); // STR
virtual int marshal_transfer_time_ms(char *); // INT
virtual int marshal_transfer_time_s(char *); // INT
virtual int marshal_file_size(char *); // INT
virtual int marshal_plugin_identity_id(char *); // INT
virtual int marshal_plugin_identity_tag(char *); // STR
virtual int marshal_cache_lookup_url_canon(char *); // STR

//
// named fields from within a http header
Expand Down Expand Up @@ -173,10 +174,14 @@ class LogAccessHttp : public LogAccess
int m_client_req_url_path_len;
char *m_proxy_resp_content_type_str;
int m_proxy_resp_content_type_len;
char *m_cache_lookup_url_canon_str;
int m_cache_lookup_url_canon_len;

void validate_unmapped_url(void);
void validate_unmapped_url_path(void);

void validate_lookup_url(void);

// -- member functions that are not allowed --
LogAccessHttp(const LogAccessHttp &rhs);
LogAccessHttp &operator=(LogAccessHttp &rhs);
Expand Down

0 comments on commit 719d55b

Please sign in to comment.