fn: uds init wait latency metric in prometheus (#1336)

* fn: uds init wait latency metric in prometheus

Adding tracker for UDS initialization during container start. This
complements our existing container state latency trackers and
docker-api latency trackers.
This commit is contained in:
Tolga Ceylan
2018-11-30 14:09:01 -08:00
committed by GitHub
parent fea4e931ce
commit 179b5e0e4c
2 changed files with 43 additions and 4 deletions

View File

@@ -895,16 +895,26 @@ func (a *agent) runHot(ctx context.Context, caller slotCaller, call *call, tok R
go func() {
defer cancel() // also close if we get an agent shutdown / idle timeout
// We record init wait for three basic states below: "initialized", "canceled", "timedout"
// Notice how we do not distinguish between agent-shutdown, eviction, ctx.Done, etc. This is
// because monitoring go-routine may pick these events earlier and cancel the ctx.
initStart := time.Now()
// INIT BARRIER HERE. Wait for the initialization go-routine signal
select {
case <-initialized:
statsContainerUDSInitLatency(ctx, initStart, time.Now(), "initialized")
case <-a.shutWg.Closer(): // agent shutdown
statsContainerUDSInitLatency(ctx, initStart, time.Now(), "canceled")
return
case <-ctx.Done():
statsContainerUDSInitLatency(ctx, initStart, time.Now(), "canceled")
return
case <-evictor.C: // eviction
statsContainerUDSInitLatency(ctx, initStart, time.Now(), "canceled")
return
case <-time.After(a.cfg.HotStartTimeout):
statsContainerUDSInitLatency(ctx, initStart, time.Now(), "timedout")
tryQueueErr(models.ErrContainerInitTimeout, errQueue)
return
}