kamon-executors

Github星跟踪图

Executor Service Metrics Tracker

Build Status
Gitter
Maven Central

Getting Started

Executor Service Metrics is currently available for Scala 2.10, 2.11 and 2.12.

Supported releases and dependencies are shown below., kamon, status, jdk, scala, :------:, :------:, :----:, ------------------, 1.0.0, stable, 1.8+, 2.10, 2.11, 2.12

To get started with SBT, simply add the following to your build.sbt
file:

libraryDependencies += "io.kamon" %% "kamon-executors" % "1.0.0"

Documentation

Thread Pools

A Thread Pool is represented by a instance of the class ExecutorService. Using a ExecutorService, you can submit a series of tasks that will be completed in the future.

Executors class provides some factory methods in order to create types of thread pools as following:

  • Single Thread Executor: A thread pool with only one thread.
  • Cached Thread Pool: A thread pool that create as many threads it needs to execute the task in parallel.
  • Fixed Thread Pool: A thread pool with a fixed number of threads.
  • Scheduled Thread Pool: A thread pool made to schedule future task.
  • Single Thread Scheduled Pool: A thread pool with only one thread to schedule future task.
  • Work Stealing Pool: Creates a work-stealing thread pool using all available processors as its target parallelism level.

Thread Pool Metrics

The metrics provided for each Thread Pool will change depending on the type of pool at hand. To know for sure what kind of pool you are looking at, we will always include a tag named executor-type whose value will always be
present and be either fork-join-pool for thread-pool-executor, matching the type of thread pool that you actually
created.

Fork Join Pool

When your pool type is fork-join-pool you will get:

  • parallelism: a min max counter with the desired parallelism value. This value will remain steady over time.
  • pool-size: a gauge tracking the number of worker threads that have started but not yet terminated. This value will
    differ that of parallelism if threads are created to maintain parallelism when others are cooperatively blocked.
  • active-threads: a gauge tracking an estimate of the number of threads that are currently stealing or executing
    tasks.
  • running-threads: a gauge tracking an estimate of the number of worker threads that are not blocked waiting to join
    tasks or for other managed synchronization.
  • queued-task-count: a gauge tracking the total number of tasks currently held in queues by worker threads (but not
    including tasks submitted to the pool that have not begun executing). This value is only an approximation, obtained by
    iterating across all threads in the pool.

Thread Pool Executor

When your pool type is thread-pool-executor you will get:

  • core-pool-size: a gauge tracking the core pool size of the executor.
  • max-pool-size: a gauge tracking the maximum number of threads allowed by the executor.
  • pool-size: a gauge tracking the current number of threads in the pool.
  • active-threads: a gauge tracking the number of threads that are actively executing tasks.
  • processed-tasks: a gauge tracking the number of processed tasks for the executor. Please not that even while the
    ThreadPoolExecutor provides us with the total number of tasks ever processed by the executor, this metrics is effectively
    tracking the number of tasks as a differential from the last recorded value.

Thread Pools are very important to execute synchronous and asynchronous processes in our applications and for that reason Kamon provides a simple way to monitoring them.

Scala example

val forkJoinPool = Executors.newWorkStealingPool()
val fixedThreadPool = Executors.newFixedThreadPool(10)

Executors.register("java-fork-join-pool", forkJoinPool)
Executors.register("fixed-thread-pool", fixedThreadPool)

for (_ <- 0 to 100) {
  forkJoinPool.submit(HeavyWeightTask())
  fixedThreadPool.submit(HeavyWeightTask())
}

forkJoinPool.shutdown()
fixedThreadPool.shutdown()

Java example

final ExecutorService forkJoinPool = Executors.newWorkStealingPool();
final ExecutorService fixedThreadPool = Executors.newFixedThreadPool(10);

Executors.register("fork-join-pool", forkJoinPool);
Executors.register("fixed-thread-pool", fixedThreadPool);

for(int i = 0; i < 100; i++) {
    forkJoinPool.submit(new HeavyWeightTask());
    fixedThreadPool.submit(new HeavyWeightTask());
}

forkJoinPool.shutdown();
fixedThreadPool.shutdown();

The output for example above using the kamon-log-reporter module should be like the following:

+------------------------------------------------------------------------------------------------+, Thread-Pool-Executor, Name: fixed-thread-pool, Core Pool Size: 10, Max  Pool Size: 10, Pool Size        Active Threads          Processed Task, Min              10                  0                      0, Avg              10.0                1.0                    0.0, Max              10                  10                     0, +------------------------------------------------------------------------------------------------+
+------------------------------------------------------------------------------------------------+, Fork-Join-Pool, Name: fork-join-pool, Paralellism: 4, Pool Size       Active Threads     Running Threads     Queue Task Count, Min           2                 0                   0                   0, Avg           3.0               0.0                 1.0                 0.0, Max           4                 0                   4                   0, +------------------------------------------------------------------------------------------------+

主要指标

概览
名称与所有者kamon-io/kamon-executors
主编程语言Scala
编程语言Scala (语言数: 2)
平台
许可证Other
所有者活动
创建于2017-06-15 20:42:21
推送于2020-03-18 14:29:04
最后一次提交2020-03-18 15:28:56
发布数15
最新版本名称v2.0.3 (发布于 2020-03-03 23:11:18)
第一版名称v1.0.0-RC4 (发布于 )
用户参与
星数10
关注者数3
派生数8
提交数84
已启用问题?
问题数2
打开的问题数0
拉请求数12
打开的拉请求数0
关闭的拉请求数3
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?