mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user