Skip to content

Commit

Permalink
vsl: Implement varnishncsa -E in libvarnishapi
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dridi committed Jan 18, 2021
1 parent 0275c19 commit 53b83f2
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 9 deletions.
7 changes: 4 additions & 3 deletions bin/varnishhist/varnishhist.c
Original file line number Diff line number Diff line change
Expand Up @@ -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, ':');
Expand Down Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions bin/varnishhist/varnishhist_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
1 change: 1 addition & 0 deletions bin/varnishlog/varnishlog_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions bin/varnishncsa/varnishncsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
6 changes: 6 additions & 0 deletions bin/varnishtest/tests/e00003.vtc
Original file line number Diff line number Diff line change
Expand Up @@ -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}
1 change: 1 addition & 0 deletions bin/varnishtop/varnishtop_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions include/vapi/vapi_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand Down
2 changes: 2 additions & 0 deletions lib/libvarnishapi/vsl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions lib/libvarnishapi/vsl_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions lib/libvarnishapi/vsl_arg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down
2 changes: 2 additions & 0 deletions lib/libvarnishapi/vsl_dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 53b83f2

Please sign in to comment.