-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
Is your feature request related to a problem? Please describe.
What do you think about adding instrumentation to Executors which will measure, how long tasks are being stucked in a queue?
For example, right now in Spring applications, depending on configuration, it may happen that:
client metric tells 20s, while in reality it was 10s
server metric tells 5s, while in reality it was 10s
Reason for that it's very simple: Thread Pool Saturation
.
From my experience I would say, that libraries, frameworks measure usually number of tasks, but... is 10 high? or maybe 1_000_000? That's why pending time seems in my opinion like something very useful
Here some reproducible example for Spring Application
spring-projects/spring-framework#35302
Describe the solution you'd like
the whole idea is to have something like this
class MonitoredExecutor internal constructor(private val delegate: Executor) : Executor {
override fun execute(runnable: Runnable) {
delegate.execute(MonitoredRunnable(runnable))
}
}
class MonitoredRunnable internal constructor(private val delegate: Runnable) : Runnable {
private val startTime = System.nanoTime()
override fun run() {
val duration = Duration.ofNanos(System.nanoTime() - startTime)
SomeLogger.log(this, "WORKAROUND Http server pending request took: $duration")
delegate.run()
}
}
Describe alternatives you've considered
No response
Additional context
I'm opening this issue in Java repository, but I think it's applicable probably for any other programming language
Tip
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1
or me too
, to help us triage it. Learn more here.