gchudnov / metrics-thread   0.9.1

MIT License GitHub

Capture thread states in metrics

Scala versions: 2.13 2.12

metrics-thread

Capture thread states in metrics.


Usage

Add the following dependency to your build.sbt:

libraryDependencies += "com.github.gchudnov" %% "metrics-thread" % "0.9.1"

Optionally, add github credentials and package repository resolver to build.sbt:

credentials += Credentials(Path.userHome / ".sbt" / ".credentials")
resolvers += Resolver.url("GitHub Package Registry", url("https://maven.pkg.github.com/gchudnov/metrics-thread"))

// cat ~/.sbt/.credentials
// realm=GitHub Package Registry
// host=maven.pkg.github.com
// user=USER
// password=TOKEN

To start capturing thread states, create an implicit instance of MetricRegistry and invoke ThreadScanner.start:

import com.codahale.metrics.MetricRegistry
import scala.concurrent.duration._

implicit val metricRegistry: MetricRegistry = new MetricRegistry()

ThreadScanner.start(1.second)

API

ThreadScanner.start(pollDuration: FiniteDuration, pattern: String = ".*")

where:

  • pollDuration - time inverval to poll for thread state change
  • pattern - reegular expression pattern used to match with thread names (by default all threads).

Contact

Grigorii Chudnov

License

Distributed under the The MIT License (MIT).