[master] 53b83f275 vsl: Implement varnishncsa -E in libvarnishapi
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Mon Jan 18 16:06:08 UTC 2021
commit 53b83f275fa24585eae3905b6aff57ddc55411ff
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date: Mon Nov 23 14:32:46 2020 +0100
vsl: Implement varnishncsa -E in libvarnishapi
This doesn't change the behavior of varnishncsa that already ignores ESI
sub-requests unless the -E option is specified. This is however breaking
the default behavior of other VSL processing tools that gained the -E
option, aligning with varnishncsa's behavior. Except varnishhist, that
gained the E filter in its -P argument instead of the -E option.
This allows to also not collect ESI transactions in VXID mode to further
reduce churn and reduce the risk for overruns in varnishncsa.
diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c
index 63bf8e73e..539245305 100644
--- a/bin/varnishhist/varnishhist.c
+++ b/bin/varnishhist/varnishhist.c
@@ -510,8 +510,8 @@ main(int argc, char **argv)
break;
}
/* else check if valid definition */
- if (colon == optarg + 1 &&
- (*optarg == 'b' || *optarg == 'c')) {
+ if (colon == optarg + 1 && (*optarg == 'b' ||
+ *optarg == 'c' || *optarg == 'E')) {
cli_p.VSL_arg = *optarg;
ptag = colon + 1;
colon = strchr(colon + 1, ':');
@@ -605,7 +605,8 @@ main(int argc, char **argv)
VUT_Error(vut, 1, "-P: No such profile '%s'", profile);
assert(active_profile->VSL_arg == 'b' ||
- active_profile->VSL_arg == 'c');
+ active_profile->VSL_arg == 'c' ||
+ active_profile->VSL_arg == 'E');
assert(VUT_Arg(vut, active_profile->VSL_arg, NULL));
match_tag = active_profile->tag;
fnum = active_profile->field;
diff --git a/bin/varnishhist/varnishhist_options.h b/bin/varnishhist/varnishhist_options.h
index 28d2fc4c7..c575bc85f 100644
--- a/bin/varnishhist/varnishhist_options.h
+++ b/bin/varnishhist/varnishhist_options.h
@@ -52,12 +52,12 @@
VOPT("P:", "[-P <[cb:]tag:[prefix]:field_num[:min:max]>]", \
"Custom profile definition", \
"Graph the given custom definition defined as: an optional" \
- " (c)lient or (b)ackend filter (defaults to client), the" \
- " tag we'll look for, a prefix to look for (can be empty," \
- " but must be terminated by a colon) and the field number" \
- " of the value we are interested in. min and max are the" \
- " boundaries of the graph in powers of ten and default to" \
- " -6 and 3." \
+ " (c)lient, (b)ackend or (E)SI filter (defaults to client),"\
+ " the tag we'll look for, a prefix to look for (can be" \
+ " empty, but must be terminated by a colon) and the field" \
+ " number of the value we are interested in. min and max are"\
+ " the boundaries of the graph in powers of ten and default" \
+ " to -6 and 3." \
)
#define HIS_OPT_B \
diff --git a/bin/varnishlog/varnishlog_options.h b/bin/varnishlog/varnishlog_options.h
index 85394c204..046808663 100644
--- a/bin/varnishlog/varnishlog_options.h
+++ b/bin/varnishlog/varnishlog_options.h
@@ -62,6 +62,7 @@ VSL_OPT_c
VSL_OPT_C
VUT_OPT_d
VUT_GLOBAL_OPT_D
+VSL_OPT_E
VUT_OPT_g
VUT_OPT_h
VSL_OPT_i
diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c
index 1d8fb46dd..7cfa347a0 100644
--- a/bin/varnishncsa/varnishncsa.c
+++ b/bin/varnishncsa/varnishncsa.c
@@ -1166,6 +1166,9 @@ main(int argc, char * const *argv)
if (CTX.c_opt)
AN(VUT_Arg(vut, 'c', NULL));
+ if (CTX.E_opt)
+ AN(VUT_Arg(vut, 'E', NULL));
+
if (optind != argc)
VUT_Usage(vut, &vopt_spec, 1);
diff --git a/bin/varnishtest/tests/e00003.vtc b/bin/varnishtest/tests/e00003.vtc
index 11ba3de74..96bd91b32 100644
--- a/bin/varnishtest/tests/e00003.vtc
+++ b/bin/varnishtest/tests/e00003.vtc
@@ -145,3 +145,9 @@ shell {
EOF
diff -u expected.txt ncsa.txt
}
+
+shell -err {varnishlog -n ${v1_name} -d -c -i Begin | grep esi}
+shell -err {varnishlog -n ${v1_name} -d -c -i Begin -g request | grep esi}
+shell {varnishlog -n ${v1_name} -d -c -i Begin -g raw | grep esi}
+shell {varnishlog -n ${v1_name} -d -E -i Begin | grep esi}
+shell {varnishlog -n ${v1_name} -d -E -i Begin | grep rxreq}
diff --git a/bin/varnishtop/varnishtop_options.h b/bin/varnishtop/varnishtop_options.h
index 7070a4618..c77e48fbc 100644
--- a/bin/varnishtop/varnishtop_options.h
+++ b/bin/varnishtop/varnishtop_options.h
@@ -67,6 +67,7 @@ VSL_OPT_b
VSL_OPT_c
VSL_OPT_C
TOP_OPT_d
+VSL_OPT_E
TOP_OPT_f
VUT_OPT_g
VUT_OPT_h
diff --git a/include/vapi/vapi_options.h b/include/vapi/vapi_options.h
index ad5fe86a9..498ed08ed 100644
--- a/include/vapi/vapi_options.h
+++ b/include/vapi/vapi_options.h
@@ -52,6 +52,11 @@
"Do all regular expression and string matching caseless." \
)
+#define VSL_OPT_E \
+ VOPT("E", "[-E]", "Display ESI transactions", \
+ "Display ESI transactions and other client transactions." \
+ )
+
#define VSL_OPT_i \
VOPT("i:", "[-i <taglist>]", "Include tags", \
"Include log records of these tags in output. Taglist is" \
diff --git a/lib/libvarnishapi/vsl.c b/lib/libvarnishapi/vsl.c
index 761cc4402..681c69985 100644
--- a/lib/libvarnishapi/vsl.c
+++ b/lib/libvarnishapi/vsl.c
@@ -346,6 +346,8 @@ VSL_PrintTransactions(struct VSL_data *vsl, struct VSL_transaction * const pt[],
case VSL_t_req:
if (!vsl->c_opt)
continue;
+ if (t->reason == VSL_r_esi && !vsl->E_opt)
+ continue;
break;
case VSL_t_bereq:
if (!vsl->b_opt)
diff --git a/lib/libvarnishapi/vsl_api.h b/lib/libvarnishapi/vsl_api.h
index 600ee994f..b374be38c 100644
--- a/lib/libvarnishapi/vsl_api.h
+++ b/lib/libvarnishapi/vsl_api.h
@@ -85,6 +85,7 @@ struct VSL_data {
int b_opt;
int c_opt;
int C_opt;
+ int E_opt;
int L_opt;
int R_opt_l;
vtim_dur R_opt_p;
diff --git a/lib/libvarnishapi/vsl_arg.c b/lib/libvarnishapi/vsl_arg.c
index eb7985c9f..0ec414164 100644
--- a/lib/libvarnishapi/vsl_arg.c
+++ b/lib/libvarnishapi/vsl_arg.c
@@ -361,6 +361,10 @@ VSL_Arg(struct VSL_data *vsl, int opt, const char *arg)
/* Caseless regular expressions */
vsl->C_opt = 1;
return (1);
+ case 'E':
+ vsl->E_opt = 1;
+ vsl->c_opt = 1;
+ return (1);
case 'i': case 'x': return (vsl_ix_arg(vsl, opt, arg));
case 'I': case 'X': return (vsl_IX_arg(vsl, opt, arg));
case 'L':
diff --git a/lib/libvarnishapi/vsl_dispatch.c b/lib/libvarnishapi/vsl_dispatch.c
index acb295a83..e4cdbe1e5 100644
--- a/lib/libvarnishapi/vsl_dispatch.c
+++ b/lib/libvarnishapi/vsl_dispatch.c
@@ -1310,6 +1310,8 @@ vslq_candidate(struct VSLQ *vslq, const uint32_t *ptr)
return (0);
if (type == VSL_t_sess)
return (0);
+ if (reason == VSL_r_esi && !vsl->E_opt)
+ return (0);
return (1);
}
More information about the varnish-commit
mailing list