Any way to invoke code from VCL after a request has been serviced?

Dridi Boukelmoune dridi at varni.sh
Tue May 16 09:53:38 CEST 2017


On Tue, May 16, 2017 at 5:23 AM, Ryan Burn <rnickb731 at gmail.com> wrote:
> Definitely closer. But I’m not sure how that approach would work
> without having the log analyzer portion built into the VMOD. A
> restriction of the OpenTracing API is that the functions to start,
> attach tags, and finish a span all need to act on the same object — it
> looks roughly like this:
>
> span = tracer.StartSpan(/* start time */, /* parent-span if exists /*);
> span.SetTag(/* key */, /* value */);
> span.Finish(/* finish time */);
>
> You couldn’t, for example, have the span created in a VMOD and then
> have a separate process analyzing the logs attach the tags and specify
> the span’s duration.

How about a VMOD doing the only StartSpan, std.log for logging keys
and whatnot, and the VUT doing all the rest when it processes the
transaction's logs?

The Finish operation appears to take a timestamp anyway, so it doesn't
need to happen exactly when the transaction finishes, does it?

You could also let your VMOD do the logging (SetTag) to not bother
users with the span id for every log statement by putting the id in the
relevant PRIV_ scope. The syntax you are looking for is not available
in VCL.

> Not sure if it’s possible, but if I could use the free function set in
> a PRIV_TOP structure to query the status code of the response sent,
> that would, I think, work well since I could avoid the complexity of
> setting up a VSM reader in a VMOD and pulling out the data from the
> log hierarchy.

Accessing the VSM in a VMOD is possible but I'd recommend not to.

Dridi



More information about the varnish-misc mailing list