MCPcopy
hub / github.com/grpc/grpc-go / append

Method append

internal/channelz/trace.go:107–126  ·  view source on GitHub ↗
(e *traceEvent)

Source from the content-addressed store, hash-verified

105}
106
107func (c *ChannelTrace) append(e *traceEvent) {
108 c.mu.Lock()
109 if len(c.Events) == getMaxTraceEntry() {
110 del := c.Events[0]
111 c.Events = c.Events[1:]
112 if del.RefID != 0 {
113 // start recursive cleanup in a goroutine to not block the call originated from grpc.
114 go func() {
115 // need to acquire c.cm.mu lock to call the unlocked attemptCleanup func.
116 c.cm.mu.Lock()
117 c.cm.decrTraceRefCount(del.RefID)
118 c.cm.mu.Unlock()
119 }()
120 }
121 }
122 e.Timestamp = time.Now()
123 c.Events = append(c.Events, e)
124 c.EventNum++
125 c.mu.Unlock()
126}
127
128func (c *ChannelTrace) clear() {
129 if c.clearCalled {

Callers 1

traceEventMethod · 0.80

Calls 5

getMaxTraceEntryFunction · 0.85
NowMethod · 0.80
decrTraceRefCountMethod · 0.65
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected