Skip to content

Commit

Permalink
Flag unused VSL tags in the definition table.
Browse files Browse the repository at this point in the history
Add a flags field to the VSL tag definition table, and use this to
flag unused records.
  • Loading branch information
mbgrydeland committed Oct 31, 2013
1 parent ee1b415 commit 6725221
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 57 deletions.
2 changes: 1 addition & 1 deletion bin/varnishd/mgt/mgt_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ mgt_DumpRstVsl(void)
"\n.. The following is autogenerated output from "
"varnishd -x dumprstvsl\n\n");

#define SLTM(tag, sdesc, ldesc) mgt_sltm(#tag, sdesc, ldesc);
#define SLTM(tag, flags, sdesc, ldesc) mgt_sltm(#tag, sdesc, ldesc);
#include "tbl/vsl_tags.h"
#undef SLTM
}
Expand Down
2 changes: 1 addition & 1 deletion bin/varnishd/mgt/mgt_param_bits.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ bit_tweak(struct cli *cli, uint8_t *p, unsigned l, const char *arg,
*/

static const char * const VSL_tags[256] = {
# define SLTM(foo,sdesc,ldesc) [SLT_##foo] = #foo,
# define SLTM(foo,flags,sdesc,ldesc) [SLT_##foo] = #foo,
# include "tbl/vsl_tags.h"
# undef SLTM
NULL
Expand Down
105 changes: 59 additions & 46 deletions include/tbl/vsl_tags.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,28 @@
*
* Arguments:
* Tag-Name
* Flags
* Short Description (1 line, max ? chars)
* Long Description (in RST "definition list" format)
*/

#define NODEF_NOTICE "Note: This log record is masked by default\n\n"

SLTM(Debug, "Debug messages",
SLTM(Debug, SLT_F_BINARY, "Debug messages",
"Debug messages can normally be ignored, but are sometimes"
" helpful during trouble-shooting. Most debug messages must"
" be explicitly enabled with parameters.\n\n"
)
SLTM(Error, "Error messages",

SLTM(Error, 0, "Error messages",
"Error messages are stuff you probably want to know.\n\n"
)
SLTM(CLI, "CLI communication",

SLTM(CLI, 0, "CLI communication",
"CLI communication between master and child process.\n\n"
)

SLTM(ReqEnd, "Client request end",
SLTM(ReqEnd, 0, "Client request end",
"Marks the end of client request.\n\n"
"The format is::\n\n"
"\t%f %f %f %f %f\n"
Expand All @@ -70,7 +73,7 @@ SLTM(ReqEnd, "Client request end",

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

SLTM(SessOpen, "Client connection opened",
SLTM(SessOpen, 0, "Client connection opened",
"The first record for a client connection, with the socket-endpoints"
" of the connection.\n\n"
"The format is::\n\n"
Expand All @@ -95,7 +98,7 @@ SLTM(SessOpen, "Client connection opened",
#undef SESS_CLOSE
*/

SLTM(SessClose, "Client connection closed",
SLTM(SessClose, 0, "Client connection closed",
"SessionClose is the last record for any client connection.\n\n"
"The format is::\n\n"
"\t%s %f %u %u %u %u %u %u\n"
Expand All @@ -113,7 +116,7 @@ SLTM(SessClose, "Client connection closed",

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

SLTM(BackendOpen, "Backend connection opened",
SLTM(BackendOpen, 0, "Backend connection opened",
"Logged when a new backend connection is opened.\n\n"
"The format is::\n\n"
"\t%d %s %s %s\n"
Expand All @@ -125,9 +128,9 @@ SLTM(BackendOpen, "Backend connection opened",
"\n"
)

SLTM(BackendXID, "The unique ID of the backend transaction (unused)", "")
SLTM(BackendXID, SLT_F_UNUSED, "The unique ID of the backend transaction", "")

SLTM(BackendReuse, "Backend connection put up for reuse",
SLTM(BackendReuse, 0, "Backend connection put up for reuse",
"Logged when a backend connection is put up for reuse by a later"
" connection.\n\n"
"The format is::\n\n"
Expand All @@ -138,7 +141,7 @@ SLTM(BackendReuse, "Backend connection put up for reuse",
"\n"
)

SLTM(BackendClose, "Backend connection closed",
SLTM(BackendClose, 0, "Backend connection closed",
"Logged when a backend connection is closed.\n\n"
"The format is::\n\n"
"\t%d %s [ %s ]\n"
Expand All @@ -149,11 +152,11 @@ SLTM(BackendClose, "Backend connection closed",
"\n"
)

SLTM(HttpGarbage, "Unparseable HTTP request",
SLTM(HttpGarbage, SLT_F_BINARY, "Unparseable HTTP request",
"Logs the content of unparseable HTTP requests.\n\n"
)

SLTM(Backend, "Backend selected",
SLTM(Backend, 0, "Backend selected",
"Logged when a connection is selected for handling a backend"
" request.\n\n"
"The format is::\n\n"
Expand All @@ -165,11 +168,11 @@ SLTM(Backend, "Backend selected",
"\n"
)

SLTM(Length, "Size of object body",
SLTM(Length, 0, "Size of object body",
"Logs the size of a fetch object body.\n\n"
)

SLTM(BereqEnd, "Backend request end",
SLTM(BereqEnd, 0, "Backend request end",
"Marks the end of a backend request.\n\n"
"The format is::\n\n"
"\t%f %f %f %f %f %f\n"
Expand All @@ -183,46 +186,48 @@ SLTM(BereqEnd, "Backend request end",
"\n"
)

SLTM(FetchError, "Error while fetching object",
SLTM(FetchError, 0, "Error while fetching object",
"Logs the error message of a failed fetch operation.\n\n"
)

#define SLTH(tag, ind, req, resp, sdesc, ldesc) \
SLTM(Req##tag, (req ? "Client request " sdesc : "(unused)"), ldesc)
SLTM(Req##tag, req ? 0 : SLT_F_UNUSED, "Client request " sdesc, ldesc)
#include "tbl/vsl_tags_http.h"
#undef SLTH

#define SLTH(tag, ind, req, resp, sdesc, ldesc) \
SLTM(Resp##tag, (resp ? "Client response " sdesc : "(unused)"), ldesc)
SLTM(Resp##tag, resp ? 0 : SLT_F_UNUSED, "Client response " sdesc, \
ldesc)
#include "tbl/vsl_tags_http.h"
#undef SLTH

#define SLTH(tag, ind, req, resp, sdesc, ldesc) \
SLTM(Bereq##tag, (req ? "Backend request " sdesc : "(unused)"), ldesc)
SLTM(Bereq##tag, req ? 0 : SLT_F_UNUSED, "Backend request " sdesc, \
ldesc)
#include "tbl/vsl_tags_http.h"
#undef SLTH

#define SLTH(tag, ind, req, resp, sdesc, ldesc) \
SLTM(Beresp##tag, (resp ? "Backend response " sdesc : "(unused)"), \
SLTM(Beresp##tag, resp ? 0 : SLT_F_UNUSED, "Backend response " sdesc, \
ldesc)
#include "tbl/vsl_tags_http.h"
#undef SLTH

#define SLTH(tag, ind, req, resp, sdesc, ldesc) \
SLTM(Obj##tag, (resp ? "Object " sdesc : "(unused)"), ldesc)
SLTM(Obj##tag, resp ? 0 : SLT_F_UNUSED, "Object " sdesc, ldesc)
#include "tbl/vsl_tags_http.h"
#undef SLTH

SLTM(BogoHeader, "Bogus HTTP received",
SLTM(BogoHeader, 0, "Bogus HTTP received",
"Contains the first 20 characters of received HTTP headers we could"
" not make sense of. Applies to both req.http and beres.http.\n\n"
)
SLTM(LostHeader, "Failed attempt to set HTTP header",
SLTM(LostHeader, 0, "Failed attempt to set HTTP header",
"Logs the header name of a failed HTTP header operation due to"
" resource exhaustion.\n\n"
)

SLTM(TTL, "TTL set on object",
SLTM(TTL, 0, "TTL set on object",
"A TTL record is emitted whenever the ttl, grace or keep"
" values for an object is set.\n\n"
"The format is::\n\n"
Expand All @@ -249,7 +254,8 @@ SLTM(TTL, "TTL set on object",
"\t1001 VCL 12 120 3600 1312966113 8\n"
"\n"
)
SLTM(Fetch_Body, "Body fetched from backend",

SLTM(Fetch_Body, 0, "Body fetched from backend",
"Finished fetching body from backend.\n\n"
"The format is::\n\n"
"\t%d(%s) cls %d\n"
Expand All @@ -259,13 +265,16 @@ SLTM(Fetch_Body, "Body fetched from backend",
"\t+------------ Body status\n"
"\n"
)
SLTM(VCL_acl, "VSL ACL check results",

SLTM(VCL_acl, 0, "VSL ACL check results",
"Logs VCL ACL evaluation results.\n\n"
)
SLTM(VCL_call, "VCL method called",

SLTM(VCL_call, 0, "VCL method called",
"Logs the VCL method name when a VCL method is called.\n\n"
)
SLTM(VCL_trace, "VCL trace data",

SLTM(VCL_trace, 0, "VCL trace data",
"Logs VCL execution trace data.\n\n"
"The format is::\n\n"
"\t%u %u.%u\n"
Expand All @@ -276,10 +285,12 @@ SLTM(VCL_trace, "VCL trace data",
"\n"
NODEF_NOTICE
)
SLTM(VCL_return, "VCL method return value",

SLTM(VCL_return, 0, "VCL method return value",
"Logs the VCL method terminating statement.\n\n"
)
SLTM(ReqStart, "Client request start",

SLTM(ReqStart, 0, "Client request start",
"Start of request processing. Logs the client IP address and port"
" number.\n\n"
"The format is::\n\n"
Expand All @@ -290,20 +301,20 @@ SLTM(ReqStart, "Client request start",
"\n"
)

SLTM(Hit, "Hit object in cache",
SLTM(Hit, 0, "Hit object in cache",
"Object looked up in cache. Shows the VXID of the object.\n\n"
)

SLTM(HitPass, "Hit for pass object in cache.\n\n",
SLTM(HitPass, 0, "Hit for pass object in cache.\n\n",
"Hit-for-pass object looked up in cache. Shows the VXID of the"
" hit-for-pass object.\n\n"
)

SLTM(ExpBan, "Object evicted due to ban",
SLTM(ExpBan, 0, "Object evicted due to ban",
"Logs the VXID when an object is banned.\n\n"
)

SLTM(ExpKill, "Object expiry event",
SLTM(ExpKill, 0, "Object expiry event",
"Logs events related to object expiry. The events are:\n\n"
"EXP_Rearm\n"
"\tLogged when the expiry time of an object changes.\n\n"
Expand Down Expand Up @@ -344,28 +355,28 @@ SLTM(ExpKill, "Object expiry event",
"\n"
)

SLTM(WorkThread, "Logs thread start/stop events",
SLTM(WorkThread, 0, "Logs thread start/stop events",
"Logs worker thread creation and termination events.\n\n"
"The format is::\n\n"
"\t%p %s\n"
"\t| |\n"
"\t| +- [start|end]\n"
"\t+---- Worker struct pointer"
"\t+---- Worker struct pointer\n"
"\n"
NODEF_NOTICE
)

SLTM(ESI_xmlerror, "ESI parser error or warning message",
SLTM(ESI_xmlerror, 0, "ESI parser error or warning message",
"An error or warning was generated during parsing of an ESI object."
" The log record describes the problem encountered."
)

SLTM(Hash, "Value added to hash",
SLTM(Hash, 0, "Value added to hash",
"This value was added to the object lookup hash.\n\n"
NODEF_NOTICE
)

SLTM(Backend_health, "Backend health check",
SLTM(Backend_health, 0, "Backend health check",
"The result of a backend health probe.\n\n"
"The format is::\n\n"
"\t%s %s %s %u %u %u %f %f %s\n"
Expand All @@ -382,15 +393,17 @@ SLTM(Backend_health, "Backend health check",
"\n"
)

SLTM(VCL_Debug, "(unused)", "")
SLTM(VCL_Log, "Log statement from VCL",
SLTM(VCL_Debug, SLT_F_UNUSED, "", "")

SLTM(VCL_Log, 0, "Log statement from VCL",
"User generated log messages insert from VCL through std.log()"
)
SLTM(VCL_Error, "VCL execution error message",

SLTM(VCL_Error, 0, "VCL execution error message",
"Logs error messages generated during VCL execution.\n\n"
)

SLTM(Gzip, "G(un)zip performed on object",
SLTM(Gzip, 0, "G(un)zip performed on object",
"A Gzip record is emitted for each instance of gzip or gunzip"
" work performed. Worst case, an ESI transaction stored in"
" gzip'ed objects but delivered gunziped, will run into many of"
Expand All @@ -413,7 +426,7 @@ SLTM(Gzip, "G(un)zip performed on object",
"\n"
)

SLTM(Link, "Links to a child VXID",
SLTM(Link, 0, "Links to a child VXID",
"Links this VXID to any child VXID it initiates.\n\n"
"The format is::\n\n"
"\t%s %d\n"
Expand All @@ -423,7 +436,7 @@ SLTM(Link, "Links to a child VXID",
"\n"
)

SLTM(Begin, "Marks the start of a VXID",
SLTM(Begin, 0, "Marks the start of a VXID",
"The first record of a VXID transaction.\n\n"
"The format is::\n\n"
"\t%s %d\n"
Expand All @@ -433,11 +446,11 @@ SLTM(Begin, "Marks the start of a VXID",
"\n"
)

SLTM(End, "Marks the end of a VXID",
SLTM(End, 0, "Marks the end of a VXID",
"The last record of a VXID transaction.\n\n"
)

SLTM(VSL, "VSL API warnings and error message",
SLTM(VSL, 0, "VSL API warnings and error message",
"Warnings and error messages genererated by the VSL API while"
" reading the shared memory log.\n\n"
)
Expand Down
2 changes: 1 addition & 1 deletion include/tbl/vsl_tags_http.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@ SLTH(Header, HTTP_HDR_FIRST, 1, 1, "header",
"\t+----- Header name\n"
"\n"
)
SLTH(Lost, HTTP_HDR_LOST, 1, 1, "(unused)",
SLTH(Lost, HTTP_HDR_LOST, 0, 0, "lost header",
""
)
6 changes: 5 additions & 1 deletion include/vapi/vsl_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,15 @@ struct VSL_head {
#define SLT__MAX 256
enum VSL_tag_e {
SLT__Bogus = 0,
#define SLTM(foo,sdesc,ldesc) SLT_##foo,
#define SLTM(foo,flags,sdesc,ldesc) SLT_##foo,
#include "tbl/vsl_tags.h"
#undef SLTM
SLT__Reserved = 254,
SLT__Batch = 255
};

/* VSL tag flags */
#define SLT_F_UNUSED (1 << 0)
#define SLT_F_BINARY (1 << 1)

#endif /* VAPI_VSL_FMT_H_INCLUDED */
2 changes: 1 addition & 1 deletion lib/libvarnishapi/vsl.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
/*--------------------------------------------------------------------*/

const char *VSL_tags[SLT__MAX] = {
# define SLTM(foo,sdesc,ldesc) [SLT_##foo] = #foo,
# define SLTM(foo,flags,sdesc,ldesc) [SLT_##foo] = #foo,
# include "tbl/vsl_tags.h"
# undef SLTM
};
Expand Down
Loading

0 comments on commit 6725221

Please sign in to comment.