| career | drupal | java | mac | mysql | perl | scala | uml | unix  

Akka/Scala example source code file (HdrHistogram.scala)

This example Akka source code file (HdrHistogram.scala) is included in my "Source Code Warehouse" project. The intent of this project is to help you more easily find Akka and Scala source code examples by using tags.

All credit for the original source code belongs to; I'm just trying to make examples easier to find. (For my Scala work, see my Scala examples and tutorials.)

Akka tags/keywords

akka, arrayindexoutofboundsexception, given, hdrhistogram, illegalargumentexception, int, long, metric, metrics, string, test, testing, testkit

The HdrHistogram.scala Akka example source code

 * Copyright (C) 2009-2014 Typesafe Inc. <>
package akka.testkit.metrics

import com.codahale.metrics.Metric
import org.{ HdrHistogram ⇒ hdr }

 * Adapts Gil Tene's HdrHistogram to Metric's Metric interface.
 * @param highestTrackableValue The highest value to be tracked by the histogram. Must be a positive
 *                              integer that is >= 2.
 * @param numberOfSignificantValueDigits The number of significant decimal digits to which the histogram will
 *                                       maintain value resolution and separation. Must be a non-negative
 *                                       integer between 0 and 5.
private[akka] class HdrHistogram(
  highestTrackableValue: Long,
  numberOfSignificantValueDigits: Int,
  val unit: String = "")
  extends Metric {

  private val hist = new hdr.Histogram(highestTrackableValue, numberOfSignificantValueDigits)

  def update(value: Long) {
    catch {
      case ex: ArrayIndexOutOfBoundsException ⇒ throw wrapHistogramOutOfBoundsException(value, ex)

  def updateWithCount(value: Long, count: Long) {
      hist.recordValueWithCount(value, count)
    catch {
      case ex: ArrayIndexOutOfBoundsException ⇒ throw wrapHistogramOutOfBoundsException(value, ex)

  private def wrapHistogramOutOfBoundsException(value: Long, ex: ArrayIndexOutOfBoundsException): IllegalArgumentException =
    new IllegalArgumentException(s"Given value $value can not be stored in this histogram " +
      s"(min: ${hist.getLowestTrackableValue}, max: ${hist.getHighestTrackableValue}})", ex)

  def getData = hist.copy().getHistogramData


Other Akka source code examples

Here is a short list of links related to this Akka HdrHistogram.scala source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller


new blog posts


Copyright 1998-2021 Alvin Alexander,
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.