nl.grons.metrics.scala

CheckedBuilder

Related Doc: package scala

trait CheckedBuilder extends BaseBuilder

The mixin trait for creating a class which creates health checks.

Linear Supertypes
BaseBuilder, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. CheckedBuilder
  2. BaseBuilder
  3. AnyRef
  4. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract val registry: HealthCheckRegistry

    The com.codahale.metrics.health.HealthCheckRegistry where created metrics are registered.

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  5. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  10. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  11. def healthCheck(name: String, unhealthyMessage: String = "Health check failed")(checker: ⇒ HealthCheckMagnet): HealthCheck

    Converts a code block to a com.codahale.metrics.health.HealthCheck and registers it.

    Converts a code block to a com.codahale.metrics.health.HealthCheck and registers it.

    Use it as follows:

    object Application {
      // The application wide health check registry.
      val healthCheckRegistry = new com.codahale.metrics.health.HealthCheckRegistry()
    }
    trait Checked extends CheckedBuilder {
      val healthCheckRegistry = Application.healthCheckRegistry
    }
    
    class Example(db: Database) extends Checked {
      private[this] val databaseCheck = healthCheck("database") { db.isConnected }
    }

    The code block must have a result of type Boolean, Try, Either or com.codahale.metrics.health.HealthCheck.Result.

    • A check result of true indicates healthy, false indicates unhealthy.
    • A check result of type Success indicates healthy, Failure indicates unhealthy. The embedded value (after applying .toString) or throwable is used as (un)healthy message.
    • A check result of type Right indicates healthy, Left[Any] or Left[Throwable] indicates unhealthy. The embedded value (after applying .toString) or throwable is used as (un)healthy message.
    • If the check result is of type com.codahale.metrics.health.HealthCheck.Result, the result is passed unchanged.
    • In case the code block throws an exception, the result is considered 'unhealthy'.

    It is also possible to override the health check base name. For example:

    class Example(db: Database) extends Checked {
      override lazy val metricBaseName = MetricName("Overridden.Base.Name")
      private[this] val databaseCheck = healthCheck("database") { db.isConnected }
    }
    name

    the name of the health check

    unhealthyMessage

    the unhealthy message for checkers that return false, defaults to "Health check failed"

    checker

    the code block that does the health check

  12. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  13. lazy val metricBaseName: MetricName

    The base name for all metrics created from this builder.

    The base name for all metrics created from this builder.

    Definition Classes
    BaseBuilder
  14. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  15. final def notify(): Unit

    Definition Classes
    AnyRef
  16. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  17. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  18. def toString(): String

    Definition Classes
    AnyRef → Any
  19. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  20. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  21. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from BaseBuilder

Inherited from AnyRef

Inherited from Any

Ungrouped