|
Akka/Scala example source code file (MetricKeyDSL.scala)
The MetricKeyDSL.scala Akka example source code
/**
* Copyright (C) 2009-2014 Typesafe Inc. <http://www.typesafe.com>
*/
package akka.testkit.metrics
trait MetricKeyDSL {
case class MetricKey private[MetricKeyDSL] (path: String) {
import MetricKey._
def /(key: String): MetricKey = MetricKey(path + "." + sanitizeMetricKeyPart(key))
override def toString = path
}
object MetricKey {
def fromString(root: String) = MetricKey(sanitizeMetricKeyPart(root))
// todo not sure what else needs replacing, while keeping key as readable as can be
private def sanitizeMetricKeyPart(keyPart: String) =
keyPart
.replaceAll("""\.\.\.""", "\u2026") // ... => …
.replaceAll("""\.""", "-")
.replaceAll("""[\]\[\(\)\<\>]""", "|")
.replaceAll(" ", "-")
.replaceAll("/", "-")
}
}
object MetricKeyDSL extends MetricKeyDSL
Other Akka source code examplesHere is a short list of links related to this Akka MetricKeyDSL.scala source code file: |
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
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.