diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2015-02-12 11:30:06 +0100 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2015-02-13 05:15:30 +0100 |
commit | 07fc83bb01c5873b47aff50d6d3abbb9f11842bd (patch) | |
tree | 814c6067a25066978b5cb8bac6541f39d0d4454d /kamon-core/src/main/scala/kamon/metric/UserMetrics.scala | |
parent | 82a110b23ca57286e4e3dd0315c20ed99b5e8f88 (diff) | |
download | Kamon-07fc83bb01c5873b47aff50d6d3abbb9f11842bd.tar.gz Kamon-07fc83bb01c5873b47aff50d6d3abbb9f11842bd.tar.bz2 Kamon-07fc83bb01c5873b47aff50d6d3abbb9f11842bd.zip |
! all: Kamon now works as a single instance in a companion object.
Diffstat (limited to 'kamon-core/src/main/scala/kamon/metric/UserMetrics.scala')
-rw-r--r-- | kamon-core/src/main/scala/kamon/metric/UserMetrics.scala | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/kamon-core/src/main/scala/kamon/metric/UserMetrics.scala b/kamon-core/src/main/scala/kamon/metric/UserMetrics.scala index e6ec5e99..e0818292 100644 --- a/kamon-core/src/main/scala/kamon/metric/UserMetrics.scala +++ b/kamon-core/src/main/scala/kamon/metric/UserMetrics.scala @@ -16,30 +16,13 @@ package kamon.metric -import akka.actor -import akka.actor.{ ActorSystem, ExtendedActorSystem, ExtensionIdProvider, ExtensionId } -import kamon.Kamon import kamon.metric.instrument.Gauge.CurrentValueCollector import kamon.metric.instrument.Histogram.DynamicRange import kamon.metric.instrument._ import scala.concurrent.duration.FiniteDuration -object UserMetrics extends ExtensionId[UserMetricsExtension] with ExtensionIdProvider { - override def get(system: ActorSystem): UserMetricsExtension = super.get(system) - def lookup(): ExtensionId[_ <: actor.Extension] = UserMetrics - def createExtension(system: ExtendedActorSystem): UserMetricsExtension = { - val metricsExtension = Metrics.get(system) - val instrumentFactory = metricsExtension.instrumentFactory(entity.category) - val userMetricsExtension = new UserMetricsExtensionImpl(instrumentFactory) - - metricsExtension.register(entity, userMetricsExtension).recorder - } - - val entity = Entity("user-metric", "user-metric") -} - -trait UserMetricsExtension extends Kamon.Extension { +trait UserMetricsExtension { def histogram(name: String): Histogram def histogram(name: String, dynamicRange: DynamicRange): Histogram def histogram(name: String, unitOfMeasurement: UnitOfMeasurement): Histogram @@ -86,7 +69,7 @@ trait UserMetricsExtension extends Kamon.Extension { } -class UserMetricsExtensionImpl(instrumentFactory: InstrumentFactory) extends GenericEntityRecorder(instrumentFactory) with UserMetricsExtension { +private[kamon] class UserMetricsExtensionImpl(instrumentFactory: InstrumentFactory) extends GenericEntityRecorder(instrumentFactory) with UserMetricsExtension { override def histogram(name: String): Histogram = super.histogram(name) @@ -206,4 +189,16 @@ class UserMetricsExtensionImpl(instrumentFactory: InstrumentFactory) extends Gen override def removeCounter(key: CounterKey): Unit = super.removeCounter(key) +} + +private[kamon] object UserMetricsExtensionImpl { + val UserMetricEntity = Entity("user-metric", "user-metric") + + def apply(metricsExtension: MetricsExtension): UserMetricsExtensionImpl = { + val instrumentFactory = metricsExtension.instrumentFactory(UserMetricEntity.category) + val userMetricsExtension = new UserMetricsExtensionImpl(instrumentFactory) + + metricsExtension.register(UserMetricEntity, userMetricsExtension).recorder + } + }
\ No newline at end of file |