mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
@@ -88,10 +88,6 @@ type Agent interface {
|
||||
// Close is not safe to be called from multiple threads.
|
||||
io.Closer
|
||||
|
||||
// Stats should be burned at the stake. adding so as to not ruffle feathers.
|
||||
// TODO this should be derived from our metrics
|
||||
Stats() Stats
|
||||
|
||||
// Return the http.Handler used to handle Prometheus metric requests
|
||||
PromHandler() http.Handler
|
||||
AddCallListener(fnext.CallListener)
|
||||
@@ -119,8 +115,6 @@ type agent struct {
|
||||
freezeIdleMsecs time.Duration
|
||||
ejectIdleMsecs time.Duration
|
||||
|
||||
stats // TODO kill me
|
||||
|
||||
// Prometheus HTTP handler
|
||||
promHandler http.Handler
|
||||
}
|
||||
@@ -242,7 +236,7 @@ func (a *agent) endStateTrackers(ctx context.Context, call *call) {
|
||||
}
|
||||
|
||||
func (a *agent) submit(ctx context.Context, call *call) error {
|
||||
a.stats.Enqueue(ctx, call.AppName, call.Path)
|
||||
StatsEnqueue(ctx)
|
||||
|
||||
a.startStateTrackers(ctx, call)
|
||||
defer a.endStateTrackers(ctx, call)
|
||||
@@ -262,7 +256,7 @@ func (a *agent) submit(ctx context.Context, call *call) error {
|
||||
}
|
||||
|
||||
// decrement queued count, increment running count
|
||||
a.stats.DequeueAndStart(ctx, call.AppName, call.Path)
|
||||
StatsDequeueAndStart(ctx)
|
||||
|
||||
// pass this error (nil or otherwise) to end directly, to store status, etc
|
||||
err = slot.exec(ctx, call)
|
||||
@@ -289,11 +283,11 @@ func transformTimeout(e error, isRetriable bool) error {
|
||||
// cases. Only timeouts can be a simple dequeue while other cases are actual errors.
|
||||
func (a *agent) handleStatsDequeue(ctx context.Context, call *call, err error) {
|
||||
if err == context.DeadlineExceeded {
|
||||
a.stats.Dequeue(ctx, call.AppName, call.Path)
|
||||
IncrementTooBusy(ctx)
|
||||
StatsDequeue(ctx)
|
||||
StatsIncrementTooBusy(ctx)
|
||||
} else {
|
||||
a.stats.DequeueAndFail(ctx, call.AppName, call.Path)
|
||||
IncrementErrors(ctx)
|
||||
StatsDequeueAndFail(ctx)
|
||||
StatsIncrementErrors(ctx)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -301,15 +295,15 @@ func (a *agent) handleStatsDequeue(ctx context.Context, call *call, err error) {
|
||||
func (a *agent) handleStatsEnd(ctx context.Context, call *call, err error) {
|
||||
if err == nil {
|
||||
// decrement running count, increment completed count
|
||||
a.stats.Complete(ctx, call.AppName, call.Path)
|
||||
StatsComplete(ctx)
|
||||
} else {
|
||||
// decrement running count, increment failed count
|
||||
a.stats.Failed(ctx, call.AppName, call.Path)
|
||||
StatsFailed(ctx)
|
||||
// increment the timeout or errors count, as appropriate
|
||||
if err == context.DeadlineExceeded {
|
||||
IncrementTimedout(ctx)
|
||||
StatsIncrementTimedout(ctx)
|
||||
} else {
|
||||
IncrementErrors(ctx)
|
||||
StatsIncrementErrors(ctx)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user