fn: add container state to eviction stats (#1296)

This commit is contained in:
Tolga Ceylan
2018-11-02 13:32:13 -07:00
committed by GitHub
parent 494fb1827b
commit ac17825a36
3 changed files with 45 additions and 3 deletions

View File

@@ -25,6 +25,7 @@ type requestState struct {
type ContainerState interface {
UpdateState(ctx context.Context, newState ContainerStateType, slots *slotQueue)
GetState() string
}
type RequestState interface {
UpdateState(ctx context.Context, newState RequestStateType, slots *slotQueue)
@@ -57,6 +58,16 @@ const (
ContainerStateMax
)
var containerStateKeys = [ContainerStateMax]string{
"none",
"wait",
"start",
"idle",
"paused",
"busy",
"done",
}
var containerGaugeKeys = [ContainerStateMax]string{
"",
"container_wait_total",
@@ -108,6 +119,16 @@ func isIdleState(state ContainerStateType) bool {
return state == ContainerStateIdle || state == ContainerStatePaused
}
func (c *containerState) GetState() string {
var res ContainerStateType
c.lock.Lock()
res = c.state
c.lock.Unlock()
return containerStateKeys[res]
}
func (c *containerState) UpdateState(ctx context.Context, newState ContainerStateType, slots *slotQueue) {
var now time.Time