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

Ryan Burn rnickb731 at gmail.com
Fri May 12 02:48:49 CEST 2017


Is it possible to set up a VUT.dispatch_f function in a varnish
module? The OpenTracing API for managing a span requires operating on
a single object; and since I need to modify varnish backend requests
to inject tracing context into their headers, I would think it has to
run from a module.

Are the functions VUT_Init, VUT_Setup, VUT_Main, etc allowed to be
invoked from a module, or are they only meant to work in a stand-alone
process?

On Tue, May 9, 2017 at 3:40 AM, Guillaume Quintard
<guillaume at varnish-software.com> wrote:
> Have a look at varnishncsa and varnishlog, and more specifically to the
> function they set VUT.dispatch_f to, that should put you on the right
> tracks. If not, ping me on IRC, or here.
>
> --
> Guillaume Quintard
>
> On Tue, May 9, 2017 at 1:08 AM, Ryan Burn <rnickb731 at gmail.com> wrote:
>>
>> Thanks Reza and Guillaume. I didn't realize there was a way to set up
>> callbacks on the VSM. I think either of the approaches will work for
>> me.
>>
>> On Mon, May 8, 2017 at 12:13 PM, Guillaume Quintard
>> <guillaume at varnish-software.com> wrote:
>> >
>> > That's the way to do it in a vmod, indeed.
>> >
>> > However Ryan, I don't get why you are reluctant to use the logs. By
>> > using
>> > the c api, you can just define callbacks and get called everything a
>> > request/transaction ends, so you don't need to read regularly.
>> > --
>> > Guillaume Quintard
>> >
>> >
>> > On May 8, 2017 17:45, "Reza Naghibi" <reza at varnish-software.com> wrote:
>> >
>> > You can do this in a VMOD via PRIV_TASK:
>> >
>> >
>> > --
>> > Reza Naghibi
>> > Varnish Software
>> >
>> > On Fri, May 5, 2017 at 10:15 PM, Ryan Burn <rnickb731 at gmail.com> wrote:
>> >>
>> >> Hello,
>> >> From VCL, is it possible to execute code that runs after a request has
>> >> been processed?
>> >>
>> >> I'm looking into writing a module that enables Varnish for distributed
>> >> tracing using the OpenTracing project [opentracing.io]. This requires
>> >> invoking code at the beginning of a request to start a span and insert
>> >> tracing context into the request's headers and invoking code after a
>> >> request's been processed to finish the span and measure how long it
>> >> took to process.
>> >>
>> >> I recently did a similar project for nginx
>> >> [github.com/rnburn/nginx-opentracing]. Nginx provides an
>> >> NGX_HTTP_LOG_PHASE [www.nginxguts.com/2011/01/phases/] that allows you
>> >> to set up handlers run after requests are serviced. Can anything
>> >> equivalent be done using VCL?
>> >>
>> >> I image you could accomplish this by subscribing and regularly reading
>> >> from Varnish's shared memory log, but I'd much rather do it directly
>> >> if possible.
>> >>
>> >> Thanks, Ryan
>> >>
>> >> _______________________________________________
>> >> varnish-misc mailing list
>> >> varnish-misc at varnish-cache.org
>> >> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>> >
>> >
>> >
>> > _______________________________________________
>> > varnish-misc mailing list
>> > varnish-misc at varnish-cache.org
>> > https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>> >
>> >
>
>



More information about the varnish-misc mailing list