Switch to github.com/golang/dep for vendoring
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
This commit is contained in:
parent
d6ab91be27
commit
8e5b17cf13
15431 changed files with 3971413 additions and 8881 deletions
49
vendor/golang.org/x/net/trace/trace.go
generated
vendored
49
vendor/golang.org/x/net/trace/trace.go
generated
vendored
|
@ -91,9 +91,10 @@ var DebugUseAfterFinish = false
|
|||
// It returns two bools; the first indicates whether the page may be viewed at all,
|
||||
// and the second indicates whether sensitive events will be shown.
|
||||
//
|
||||
// AuthRequest may be replaced by a program to customise its authorisation requirements.
|
||||
// AuthRequest may be replaced by a program to customize its authorization requirements.
|
||||
//
|
||||
// The default AuthRequest function returns (true, true) iff the request comes from localhost/127.0.0.1/[::1].
|
||||
// The default AuthRequest function returns (true, true) if and only if the request
|
||||
// comes from localhost/127.0.0.1/[::1].
|
||||
var AuthRequest = func(req *http.Request) (any, sensitive bool) {
|
||||
// RemoteAddr is commonly in the form "IP" or "IP:port".
|
||||
// If it is in the form "IP:port", split off the port.
|
||||
|
@ -237,7 +238,7 @@ func Render(w io.Writer, req *http.Request, sensitive bool) {
|
|||
|
||||
completedMu.RLock()
|
||||
defer completedMu.RUnlock()
|
||||
if err := pageTmpl.ExecuteTemplate(w, "Page", data); err != nil {
|
||||
if err := pageTmpl().ExecuteTemplate(w, "Page", data); err != nil {
|
||||
log.Printf("net/trace: Failed executing template: %v", err)
|
||||
}
|
||||
}
|
||||
|
@ -332,7 +333,8 @@ func New(family, title string) Trace {
|
|||
tr.ref()
|
||||
tr.Family, tr.Title = family, title
|
||||
tr.Start = time.Now()
|
||||
tr.events = make([]event, 0, maxEventsPerTrace)
|
||||
tr.maxEvents = maxEventsPerTrace
|
||||
tr.events = tr.eventsBuf[:0]
|
||||
|
||||
activeMu.RLock()
|
||||
s := activeTraces[tr.Family]
|
||||
|
@ -649,8 +651,8 @@ type event struct {
|
|||
Elapsed time.Duration // since previous event in trace
|
||||
NewDay bool // whether this event is on a different day to the previous event
|
||||
Recyclable bool // whether this event was passed via LazyLog
|
||||
What interface{} // string or fmt.Stringer
|
||||
Sensitive bool // whether this event contains sensitive information
|
||||
What interface{} // string or fmt.Stringer
|
||||
}
|
||||
|
||||
// WhenString returns a string representation of the elapsed time of the event.
|
||||
|
@ -691,14 +693,17 @@ type trace struct {
|
|||
IsError bool
|
||||
|
||||
// Append-only sequence of events (modulo discards).
|
||||
mu sync.RWMutex
|
||||
events []event
|
||||
mu sync.RWMutex
|
||||
events []event
|
||||
maxEvents int
|
||||
|
||||
refs int32 // how many buckets this is in
|
||||
recycler func(interface{})
|
||||
disc discarded // scratch space to avoid allocation
|
||||
|
||||
finishStack []byte // where finish was called, if DebugUseAfterFinish is set
|
||||
|
||||
eventsBuf [4]event // preallocated buffer in case we only log a few events
|
||||
}
|
||||
|
||||
func (tr *trace) reset() {
|
||||
|
@ -710,11 +715,15 @@ func (tr *trace) reset() {
|
|||
tr.traceID = 0
|
||||
tr.spanID = 0
|
||||
tr.IsError = false
|
||||
tr.maxEvents = 0
|
||||
tr.events = nil
|
||||
tr.refs = 0
|
||||
tr.recycler = nil
|
||||
tr.disc = 0
|
||||
tr.finishStack = nil
|
||||
for i := range tr.eventsBuf {
|
||||
tr.eventsBuf[i] = event{}
|
||||
}
|
||||
}
|
||||
|
||||
// delta returns the elapsed time since the last event or the trace start,
|
||||
|
@ -743,7 +752,7 @@ func (tr *trace) addEvent(x interface{}, recyclable, sensitive bool) {
|
|||
and very unlikely to be the fault of this code.
|
||||
|
||||
The most likely scenario is that some code elsewhere is using
|
||||
a requestz.Trace after its Finish method is called.
|
||||
a trace.Trace after its Finish method is called.
|
||||
You can temporarily set the DebugUseAfterFinish var
|
||||
to help discover where that is; do not leave that var set,
|
||||
since it makes this package much less efficient.
|
||||
|
@ -752,11 +761,11 @@ func (tr *trace) addEvent(x interface{}, recyclable, sensitive bool) {
|
|||
e := event{When: time.Now(), What: x, Recyclable: recyclable, Sensitive: sensitive}
|
||||
tr.mu.Lock()
|
||||
e.Elapsed, e.NewDay = tr.delta(e.When)
|
||||
if len(tr.events) < cap(tr.events) {
|
||||
if len(tr.events) < tr.maxEvents {
|
||||
tr.events = append(tr.events, e)
|
||||
} else {
|
||||
// Discard the middle events.
|
||||
di := int((cap(tr.events) - 1) / 2)
|
||||
di := int((tr.maxEvents - 1) / 2)
|
||||
if d, ok := tr.events[di].What.(*discarded); ok {
|
||||
(*d)++
|
||||
} else {
|
||||
|
@ -776,7 +785,7 @@ func (tr *trace) addEvent(x interface{}, recyclable, sensitive bool) {
|
|||
go tr.recycler(tr.events[di+1].What)
|
||||
}
|
||||
copy(tr.events[di+1:], tr.events[di+2:])
|
||||
tr.events[cap(tr.events)-1] = e
|
||||
tr.events[tr.maxEvents-1] = e
|
||||
}
|
||||
tr.mu.Unlock()
|
||||
}
|
||||
|
@ -802,7 +811,7 @@ func (tr *trace) SetTraceInfo(traceID, spanID uint64) {
|
|||
func (tr *trace) SetMaxEvents(m int) {
|
||||
// Always keep at least three events: first, discarded count, last.
|
||||
if len(tr.events) == 0 && m > 3 {
|
||||
tr.events = make([]event, 0, m)
|
||||
tr.maxEvents = m
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -893,10 +902,18 @@ func elapsed(d time.Duration) string {
|
|||
return string(b)
|
||||
}
|
||||
|
||||
var pageTmpl = template.Must(template.New("Page").Funcs(template.FuncMap{
|
||||
"elapsed": elapsed,
|
||||
"add": func(a, b int) int { return a + b },
|
||||
}).Parse(pageHTML))
|
||||
var pageTmplCache *template.Template
|
||||
var pageTmplOnce sync.Once
|
||||
|
||||
func pageTmpl() *template.Template {
|
||||
pageTmplOnce.Do(func() {
|
||||
pageTmplCache = template.Must(template.New("Page").Funcs(template.FuncMap{
|
||||
"elapsed": elapsed,
|
||||
"add": func(a, b int) int { return a + b },
|
||||
}).Parse(pageHTML))
|
||||
})
|
||||
return pageTmplCache
|
||||
}
|
||||
|
||||
const pageHTML = `
|
||||
{{template "Prolog" .}}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue