diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2014-12-05 02:22:25 +0100 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2014-12-05 02:22:25 +0100 |
commit | 355b910f9e7c2e82217ef2443b734e3220752555 (patch) | |
tree | 186090266302e3393d45ef6c2d4eef677fa3caf1 /kamon-newrelic/src/test/scala/kamon/newrelic | |
parent | 816503da6a4b28c4739dce518261cc791c7ae81e (diff) | |
download | Kamon-355b910f9e7c2e82217ef2443b734e3220752555.tar.gz Kamon-355b910f9e7c2e82217ef2443b734e3220752555.tar.bz2 Kamon-355b910f9e7c2e82217ef2443b734e3220752555.zip |
+ newrelic: react correctly to restart and shutdown events from the New Relic collector.
Diffstat (limited to 'kamon-newrelic/src/test/scala/kamon/newrelic')
-rw-r--r-- | kamon-newrelic/src/test/scala/kamon/newrelic/AgentSpec.scala | 10 | ||||
-rw-r--r-- | kamon-newrelic/src/test/scala/kamon/newrelic/MetricReporterSpec.scala | 23 |
2 files changed, 18 insertions, 15 deletions
diff --git a/kamon-newrelic/src/test/scala/kamon/newrelic/AgentSpec.scala b/kamon-newrelic/src/test/scala/kamon/newrelic/AgentSpec.scala index 7db9f2d0..adab1a34 100644 --- a/kamon-newrelic/src/test/scala/kamon/newrelic/AgentSpec.scala +++ b/kamon-newrelic/src/test/scala/kamon/newrelic/AgentSpec.scala @@ -44,8 +44,8 @@ class AgentSpec extends TestKitBase with WordSpecLike with BeforeAndAfterAll wit | newrelic { | app-name = kamon | license-key = 1111111111 - | initialize-retry-delay = 1 second - | max-initialize-retries = 3 + | connect-retry-delay = 1 second + | max-connect-retries = 3 | } |} | @@ -88,7 +88,7 @@ class AgentSpec extends TestKitBase with WordSpecLike with BeforeAndAfterAll wit }) // Receive the runID - EventFilter.info(message = "Agent initialized with runID: [161221111] and collector: [collector-8.newrelic.com]", occurrences = 1).intercept { + EventFilter.info(message = "Configuring New Relic reporters to use runID: [161221111] and collector: [collector-8.newrelic.com]", occurrences = 1).intercept { httpManager.reply(jsonResponse( """ | { @@ -147,7 +147,7 @@ class AgentSpec extends TestKitBase with WordSpecLike with BeforeAndAfterAll wit // Receive the runID EventFilter.info( - message = "Agent initialized with runID: [161221112] and collector: [collector-8.newrelic.com]", occurrences = 1).intercept { + message = "Configuring New Relic reporters to use runID: [161221112] and collector: [collector-8.newrelic.com]", occurrences = 1).intercept { httpManager.reply(jsonResponse( """ @@ -184,7 +184,7 @@ class AgentSpec extends TestKitBase with WordSpecLike with BeforeAndAfterAll wit }) // Give up on connecting. - EventFilter[RuntimeException](message = "Giving up while trying to set up a connection with the New Relic collector.", occurrences = 1).intercept { + EventFilter.error(message = "Giving up while trying to set up a connection with the New Relic collector. The New Relic module is shutting down itself.", occurrences = 1).intercept { httpManager.reply(Timedout(request)) } } diff --git a/kamon-newrelic/src/test/scala/kamon/newrelic/MetricReporterSpec.scala b/kamon-newrelic/src/test/scala/kamon/newrelic/MetricReporterSpec.scala index 0001072e..ff977398 100644 --- a/kamon-newrelic/src/test/scala/kamon/newrelic/MetricReporterSpec.scala +++ b/kamon-newrelic/src/test/scala/kamon/newrelic/MetricReporterSpec.scala @@ -19,9 +19,10 @@ package kamon.newrelic import akka.actor.{ ActorRef, ActorSystem } import akka.io.IO import akka.testkit._ +import akka.util.Timeout import com.typesafe.config.ConfigFactory import kamon.metric.{ TraceMetrics, Metrics } -import kamon.{ Kamon, AkkaExtensionSwap } +import kamon.{ MilliTimestamp, Kamon, AkkaExtensionSwap } import kamon.metric.Subscriptions.TickMetricSnapshot import org.scalatest.{ Matchers, WordSpecLike } import spray.can.Http @@ -49,7 +50,7 @@ class MetricReporterSpec extends TestKitBase with WordSpecLike with Matchers wit | """.stripMargin)) - val agentSettings = Agent.Settings("1111111111", "kamon", "test-host", 1, 1, 30 seconds, 1D) + val agentSettings = AgentSettings("1111111111", "kamon", "test-host", 1, Timeout(5 seconds), 1, 30 seconds, 1D) val baseQuery = Query( "license_key" -> agentSettings.licenseKey, "marshal_format" -> "json", @@ -59,8 +60,9 @@ class MetricReporterSpec extends TestKitBase with WordSpecLike with Matchers wit "the MetricReporter" should { "report metrics to New Relic upon arrival" in new FakeTickSnapshotsFixture { val httpManager = setHttpManager(TestProbe()) - val metricReporter = system.actorOf(MetricReporter.props(agentSettings, 9999, baseCollectorUri)) + val metricReporter = system.actorOf(MetricReporter.props(agentSettings)) + metricReporter ! Agent.Configure("collector-1.newrelic.com", 9999) metricReporter ! firstSnapshot val metricPost = httpManager.expectMsgType[HttpRequest] @@ -70,8 +72,8 @@ class MetricReporterSpec extends TestKitBase with WordSpecLike with Matchers wit val postedBatch = Deflate.decode(metricPost).entity.asString.parseJson.convertTo[MetricBatch] postedBatch.runID should be(9999) - postedBatch.timeSliceMetrics.from should be(1415587618) - postedBatch.timeSliceMetrics.to should be(1415587678) + postedBatch.timeSliceMetrics.from.seconds should be(1415587618) + postedBatch.timeSliceMetrics.to.seconds should be(1415587678) val metrics = postedBatch.timeSliceMetrics.metrics metrics(MetricID("Apdex", None)).callCount should be(3) @@ -81,8 +83,9 @@ class MetricReporterSpec extends TestKitBase with WordSpecLike with Matchers wit "accumulate metrics if posting fails" in new FakeTickSnapshotsFixture { val httpManager = setHttpManager(TestProbe()) - val metricReporter = system.actorOf(MetricReporter.props(agentSettings, 9999, baseCollectorUri)) + val metricReporter = system.actorOf(MetricReporter.props(agentSettings)) + metricReporter ! Agent.Configure("collector-1.newrelic.com", 9999) metricReporter ! firstSnapshot val request = httpManager.expectMsgType[HttpRequest] httpManager.reply(Timedout(request)) @@ -96,8 +99,8 @@ class MetricReporterSpec extends TestKitBase with WordSpecLike with Matchers wit val postedBatch = Deflate.decode(metricPost).entity.asString.parseJson.convertTo[MetricBatch] postedBatch.runID should be(9999) - postedBatch.timeSliceMetrics.from should be(1415587618) - postedBatch.timeSliceMetrics.to should be(1415587738) + postedBatch.timeSliceMetrics.from.seconds should be(1415587618) + postedBatch.timeSliceMetrics.to.seconds should be(1415587738) val metrics = postedBatch.timeSliceMetrics.metrics metrics(MetricID("Apdex", None)).callCount should be(6) @@ -139,11 +142,11 @@ class MetricReporterSpec extends TestKitBase with WordSpecLike with Matchers wit recorder.elapsedTime.record(1000000) recorder.elapsedTime.record(2000000) recorder.elapsedTime.record(3000000) - val firstSnapshot = TickMetricSnapshot(1415587618000L, 1415587678000L, Map(testTraceID -> collectRecorder)) + val firstSnapshot = TickMetricSnapshot(new MilliTimestamp(1415587618000L), new MilliTimestamp(1415587678000L), Map(testTraceID -> collectRecorder)) recorder.elapsedTime.record(6000000) recorder.elapsedTime.record(5000000) recorder.elapsedTime.record(4000000) - val secondSnapshot = TickMetricSnapshot(1415587678000L, 1415587738000L, Map(testTraceID -> collectRecorder)) + val secondSnapshot = TickMetricSnapshot(new MilliTimestamp(1415587678000L), new MilliTimestamp(1415587738000L), Map(testTraceID -> collectRecorder)) } }
\ No newline at end of file |