tpl: Fix metrics hint tracking
authorCameron Moore <moorereason@gmail.com>
Fri, 8 Jan 2021 16:26:35 +0000 (10:26 -0600)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Fri, 8 Jan 2021 19:01:11 +0000 (20:01 +0100)
When tracking for cache hints, track the same template name as the call
to MeasureSince in Execute.  When referencing a partial "foo", the value
of `n` does not match `templ.Name()` (`partials/foo` versus
`partials/foo.html`).  This was causing hints to go untracked since
there was no existing metric to append the hint to.

Fixes #8125

tpl/partials/partials.go

index 016e0423c036bae6631e514f9d2c73250cebb2fe..e8a8adc36d9a4fe36e730880f117c9ee43fed4bd 100644 (file)
@@ -155,7 +155,7 @@ func (ns *Namespace) Include(name string, contextList ...interface{}) (interface
        }
 
        if ns.deps.Metrics != nil {
-               ns.deps.Metrics.TrackValue(n, result)
+               ns.deps.Metrics.TrackValue(templ.Name(), result)
        }
 
        return result, nil