From 3ae632dea4dd208ba22e56510c51ab222ea89148 Mon Sep 17 00:00:00 2001 From: Ivan Topolnjak Date: Fri, 4 Jul 2014 01:51:58 -0300 Subject: + core: introduce the new kamon.metrics.default-collection-context-buffer-size setting --- .../test/scala/kamon/metric/TickMetricSnapshotBufferSpec.scala | 3 ++- kamon-core/src/test/scala/kamon/metric/TraceMetricsSpec.scala | 4 +++- kamon-core/src/test/scala/kamon/metric/UserMetricsSpec.scala | 5 +++-- .../src/test/scala/kamon/metric/instrument/GaugeSpec.scala | 10 ++++++---- 4 files changed, 14 insertions(+), 8 deletions(-) (limited to 'kamon-core/src/test') diff --git a/kamon-core/src/test/scala/kamon/metric/TickMetricSnapshotBufferSpec.scala b/kamon-core/src/test/scala/kamon/metric/TickMetricSnapshotBufferSpec.scala index ee851672..0af1ae85 100644 --- a/kamon-core/src/test/scala/kamon/metric/TickMetricSnapshotBufferSpec.scala +++ b/kamon-core/src/test/scala/kamon/metric/TickMetricSnapshotBufferSpec.scala @@ -31,6 +31,7 @@ class TickMetricSnapshotBufferSpec extends TestKitBase with WordSpecLike with Ma """ |kamon.metrics { | tick-interval = 1 hour + | default-collection-context-buffer-size = 10 | filters = [ | { | trace { @@ -86,7 +87,7 @@ class TickMetricSnapshotBufferSpec extends TestKitBase with WordSpecLike with Ma } trait SnapshotFixtures { - val collectionContext = CollectionContext.default + val collectionContext = Kamon(Metrics).buildDefaultCollectionContext val testTraceIdentity = TraceMetrics("buffer-spec-test-trace") val traceRecorder = Kamon(Metrics).register(testTraceIdentity, TraceMetrics.Factory).get diff --git a/kamon-core/src/test/scala/kamon/metric/TraceMetricsSpec.scala b/kamon-core/src/test/scala/kamon/metric/TraceMetricsSpec.scala index dab9b52a..39eaaf9e 100644 --- a/kamon-core/src/test/scala/kamon/metric/TraceMetricsSpec.scala +++ b/kamon-core/src/test/scala/kamon/metric/TraceMetricsSpec.scala @@ -14,6 +14,7 @@ class TraceMetricsSpec extends TestKitBase with WordSpecLike with Matchers with """ |kamon.metrics { | tick-interval = 1 hour + | default-collection-context-buffer-size = 10 | filters = [ | { | trace { @@ -87,6 +88,7 @@ class TraceMetricsSpec extends TestKitBase with WordSpecLike with Matchers with def takeSnapshotOf(traceName: String): TraceMetricsSnapshot = { val recorder = Kamon(Metrics).register(TraceMetrics(traceName), TraceMetrics.Factory) - recorder.get.collect(CollectionContext.default) + val collectionContext = Kamon(Metrics).buildDefaultCollectionContext + recorder.get.collect(collectionContext) } } diff --git a/kamon-core/src/test/scala/kamon/metric/UserMetricsSpec.scala b/kamon-core/src/test/scala/kamon/metric/UserMetricsSpec.scala index 57bc3d0d..00a933f1 100644 --- a/kamon-core/src/test/scala/kamon/metric/UserMetricsSpec.scala +++ b/kamon-core/src/test/scala/kamon/metric/UserMetricsSpec.scala @@ -15,6 +15,7 @@ class UserMetricsSpec extends TestKitBase with WordSpecLike with Matchers with I """ |kamon.metrics { | flush-interval = 1 hour + | default-collection-context-buffer-size = 10 | precision { | default-histogram-precision { | highest-trackable-value = 10000 @@ -111,7 +112,7 @@ class UserMetricsSpec extends TestKitBase with WordSpecLike with Matchers with I } "generate a snapshot containing all the registered user metrics and reset all instruments" in { - val context = CollectionContext.default + val context = Kamon(Metrics).buildDefaultCollectionContext val userMetricsRecorder = Kamon(Metrics).register(UserMetrics, UserMetrics.Factory).get val histogramWithSettings = Kamon(UserMetrics).registerHistogram("histogram-with-settings", Histogram.Precision.Normal, 10000L) @@ -219,7 +220,7 @@ class UserMetricsSpec extends TestKitBase with WordSpecLike with Matchers with I } "generate a snapshot that can be merged with another" in { - val context = CollectionContext.default + val context = Kamon(Metrics).buildDefaultCollectionContext val userMetricsRecorder = Kamon(Metrics).register(UserMetrics, UserMetrics.Factory).get val histogram = Kamon(UserMetrics).registerHistogram("histogram-for-merge") diff --git a/kamon-core/src/test/scala/kamon/metric/instrument/GaugeSpec.scala b/kamon-core/src/test/scala/kamon/metric/instrument/GaugeSpec.scala index b3ff3c9f..9192d999 100644 --- a/kamon-core/src/test/scala/kamon/metric/instrument/GaugeSpec.scala +++ b/kamon-core/src/test/scala/kamon/metric/instrument/GaugeSpec.scala @@ -4,15 +4,17 @@ import java.util.concurrent.atomic.AtomicLong import akka.actor.ActorSystem import com.typesafe.config.ConfigFactory -import kamon.metric.{ Scale, CollectionContext } +import kamon.Kamon +import kamon.metric.{ Metrics, Scale, CollectionContext } import org.scalatest.{ Matchers, WordSpecLike } import scala.concurrent.duration._ class GaugeSpec extends WordSpecLike with Matchers { - val system = ActorSystem("gauge-spec", ConfigFactory.parseString( + implicit val system = ActorSystem("gauge-spec", ConfigFactory.parseString( """ |kamon.metrics { | flush-interval = 1 hour + | default-collection-context-buffer-size = 10 | precision { | default-gauge-precision { | refresh-interval = 100 milliseconds @@ -50,7 +52,7 @@ class GaugeSpec extends WordSpecLike with Matchers { Thread.sleep(1.second.toMillis) gauge.cleanup - val snapshot = gauge.collect(CollectionContext.default) + val snapshot = gauge.collect(Kamon(Metrics).buildDefaultCollectionContext) snapshot.numberOfMeasurements should be(10L +- 1L) snapshot.min should be(1) @@ -61,7 +63,7 @@ class GaugeSpec extends WordSpecLike with Matchers { val numberOfValuesRecorded = new AtomicLong(0) val gauge = Gauge(Histogram.Precision.Normal, 10000L, Scale.Unit, 1 hour, system)(() ⇒ numberOfValuesRecorded.addAndGet(1)) - val snapshot = gauge.collect(CollectionContext.default) + val snapshot = gauge.collect(Kamon(Metrics).buildDefaultCollectionContext) snapshot.numberOfMeasurements should be(0) numberOfValuesRecorded.get() should be(0) -- cgit v1.2.3