diff options
Diffstat (limited to 'kamon-newrelic/src/main/scala')
6 files changed, 26 insertions, 33 deletions
diff --git a/kamon-newrelic/src/main/scala/kamon/newrelic/Agent.scala b/kamon-newrelic/src/main/scala/kamon/newrelic/Agent.scala index a73f390a..299773e4 100644 --- a/kamon-newrelic/src/main/scala/kamon/newrelic/Agent.scala +++ b/kamon-newrelic/src/main/scala/kamon/newrelic/Agent.scala @@ -49,7 +49,6 @@ class Agent extends Actor with RequestBuilding with ResponseTransformation with "marshal_format" -> "json", "protocol_version" -> "12") - def receive = { case Initialize(runId, collector) ⇒ log.info("Agent initialized with runID: [{}] and collector: [{}]", runId, collector) @@ -77,12 +76,11 @@ class Agent extends Actor with RequestBuilding with ResponseTransformation with } import AgentJsonProtocol._ - val compressedPipeline: HttpRequest ⇒ Future[HttpResponse] = logRequest(println(_)) ~>encode(Deflate) ~> sendReceive ~> logResponse(println(_)) + val compressedPipeline: HttpRequest ⇒ Future[HttpResponse] = encode(Deflate) ~> sendReceive val compressedToJsonPipeline: HttpRequest ⇒ Future[JsValue] = compressedPipeline ~> toJson def toJson(response: HttpResponse): JsValue = response.entity.asString.asJson - def selectCollector: Future[String] = { val query = ("method" -> "get_redirect_host") +: baseQuery val getRedirectHostUri = Uri("http://collector.newrelic.com/agent_listener/invoke_raw_method").withQuery(query) diff --git a/kamon-newrelic/src/main/scala/kamon/newrelic/MetricTranslator.scala b/kamon-newrelic/src/main/scala/kamon/newrelic/MetricTranslator.scala index c3438df5..0162dd9c 100644 --- a/kamon-newrelic/src/main/scala/kamon/newrelic/MetricTranslator.scala +++ b/kamon-newrelic/src/main/scala/kamon/newrelic/MetricTranslator.scala @@ -16,14 +16,14 @@ package kamon.newrelic -import akka.actor.{Props, ActorRef, Actor} +import akka.actor.{ Props, ActorRef, Actor } import kamon.metrics.Subscriptions.TickMetricSnapshot import kamon.newrelic.MetricTranslator.TimeSliceMetrics class MetricTranslator(receiver: ActorRef) extends Actor with WebTransactionMetrics { def receive = { - case TickMetricSnapshot(from, to, metrics) => + case TickMetricSnapshot(from, to, metrics) ⇒ val scaledFrom = (from / 1E3).toInt val scaledTo = (to / 1E3).toInt val allMetrics = collectWebTransactionMetrics(metrics) diff --git a/kamon-newrelic/src/main/scala/kamon/newrelic/NewRelic.scala b/kamon-newrelic/src/main/scala/kamon/newrelic/NewRelic.scala index 92191842..6c7c11bd 100644 --- a/kamon-newrelic/src/main/scala/kamon/newrelic/NewRelic.scala +++ b/kamon-newrelic/src/main/scala/kamon/newrelic/NewRelic.scala @@ -18,11 +18,10 @@ package kamon.newrelic import akka.actor._ import scala.concurrent.duration._ import kamon.Kamon -import kamon.metrics.{TickMetricSnapshotBuffer, TraceMetrics, Metrics} +import kamon.metrics.{ TickMetricSnapshotBuffer, TraceMetrics, Metrics } import kamon.metrics.Subscriptions.TickMetricSnapshot import akka.actor - class NewRelicExtension(system: ExtendedActorSystem) extends Kamon.Extension { val config = system.settings.config.getConfig("kamon.newrelic") @@ -40,11 +39,10 @@ class NewRelicManager extends Actor with ActorLogging { val buffer = context.actorOf(TickMetricSnapshotBuffer.props(1 minute, translator), "metric-buffer") def receive = { - case tick: TickMetricSnapshot => buffer.forward(tick) + case tick: TickMetricSnapshot ⇒ buffer.forward(tick) } } - object NewRelic extends ExtensionId[NewRelicExtension] with ExtensionIdProvider { def lookup(): ExtensionId[_ <: actor.Extension] = NewRelic def createExtension(system: ExtendedActorSystem): NewRelicExtension = new NewRelicExtension(system) diff --git a/kamon-newrelic/src/main/scala/kamon/newrelic/NewRelicErrorLogger.scala b/kamon-newrelic/src/main/scala/kamon/newrelic/NewRelicErrorLogger.scala index 65a98cb1..0f177b9e 100644 --- a/kamon-newrelic/src/main/scala/kamon/newrelic/NewRelicErrorLogger.scala +++ b/kamon-newrelic/src/main/scala/kamon/newrelic/NewRelicErrorLogger.scala @@ -18,7 +18,7 @@ package kamon.newrelic import akka.actor.Actor import akka.event.Logging.Error import akka.event.Logging.{ LoggerInitialized, InitializeLogger } -import com.newrelic.api.agent.{NewRelic => NR} +import com.newrelic.api.agent.{ NewRelic ⇒ NR } import kamon.trace.TraceContextAware class NewRelicErrorLogger extends Actor { diff --git a/kamon-newrelic/src/main/scala/kamon/newrelic/WebTransactionMetrics.scala b/kamon-newrelic/src/main/scala/kamon/newrelic/WebTransactionMetrics.scala index 31a3669d..11312104 100644 --- a/kamon-newrelic/src/main/scala/kamon/newrelic/WebTransactionMetrics.scala +++ b/kamon-newrelic/src/main/scala/kamon/newrelic/WebTransactionMetrics.scala @@ -22,7 +22,7 @@ import akka.actor.Actor import kamon.Kamon trait WebTransactionMetrics { - self: Actor => + self: Actor ⇒ def collectWebTransactionMetrics(metrics: Map[MetricGroupIdentity, MetricGroupSnapshot]): Seq[NewRelic.Metric] = { val apdexBuilder = new ApdexBuilder("Apdex", None, (NewRelic)(context.system).apdexT) @@ -32,9 +32,9 @@ trait WebTransactionMetrics { case (TraceMetrics(name), groupSnapshot) ⇒ groupSnapshot.metrics collect { - case (ElapsedTime, snapshot) => + case (ElapsedTime, snapshot) ⇒ accumulatedHttpDispatcher = accumulatedHttpDispatcher.merge(snapshot) - snapshot.measurementLevels.foreach(level => apdexBuilder.record(level.value / 1E9D, level.count)) + snapshot.measurementLevels.foreach(level ⇒ apdexBuilder.record(level.value / 1E9D, level.count)) toNewRelicMetric(s"WebTransaction/Custom/$name", None, snapshot) } @@ -55,13 +55,12 @@ class ApdexBuilder(name: String, scope: Option[String], apdexT: Double) { var frustrating = 0L def record(duration: Double, count: Long): Unit = - if(duration <= apdexT) + if (duration <= apdexT) satisfying += count + else if (duration <= frustratingThreshold) + tolerating += count else - if(duration <= frustratingThreshold) - tolerating += count - else - frustrating += count + frustrating += count // NewRelic reuses the same metric structure for recording the Apdex.. weird, but that's how it works. def build: NewRelic.Metric = NewRelic.Metric(name, scope, satisfying, tolerating, frustrating, apdexT, apdexT, 0) diff --git a/kamon-newrelic/src/main/scala/kamon/newrelic/package.scala b/kamon-newrelic/src/main/scala/kamon/newrelic/package.scala index bf83b049..76b40748 100644 --- a/kamon-newrelic/src/main/scala/kamon/newrelic/package.scala +++ b/kamon-newrelic/src/main/scala/kamon/newrelic/package.scala @@ -1,18 +1,16 @@ -/* +/*========================================================================================= + * Copyright © 2013 the kamon project <http://kamon.io/> * - * * ========================================================================================= - * * Copyright © 2013 the kamon project <http://kamon.io/> - * * - * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file - * * except in compliance with the License. You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software distributed under the - * * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * * either express or implied. See the License for the specific language governing permissions - * * and limitations under the License. - * * ========================================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the + * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + * ========================================================================================= * */ @@ -27,7 +25,7 @@ package object newrelic { var sumOfSquares: Double = 0D val measurementLevels = snapshot.measurementLevels.iterator - while(measurementLevels.hasNext) { + while (measurementLevels.hasNext) { val level = measurementLevels.next() // NewRelic metrics need to be scaled to seconds. |