From ee009e02a20a94ee6011cf5ddf537722c173e44f Mon Sep 17 00:00:00 2001 From: Colin Smith Date: Wed, 14 Oct 2015 08:17:03 +0100 Subject: = newrelic: Associate logged errors with correct transaction Previously, errors were associated with transactions named "OtherTransaction/", with this change they are associated with "WebTransaction/Uri/ 0) params.put("ErrorMessage", message) + val uri = s"/${Tracer.currentContext.name}" + val transaction = s"WebTransaction/Uri$uri" + LoggedException(cause, params, transaction, uri); } -} \ No newline at end of file + + def reportError(error: ThrowableError) = ServiceFactory.getRPMService().getErrorService().reportError(error) + +} + +case class LoggedMessage(message: String) extends Throwable(message) with NoStackTrace + +case class LoggedException(cause: Throwable, params: util.HashMap[String, String], transaction: String, uri: String) + extends ThrowableError(null, transaction, cause, uri, System.currentTimeMillis(), null, null, null, params, null) diff --git a/kamon-newrelic/src/main/scala/kamon/newrelic/WebTransactionMetricExtractor.scala b/kamon-newrelic/src/main/scala/kamon/newrelic/WebTransactionMetricExtractor.scala index 1a31ac58..604969ab 100644 --- a/kamon-newrelic/src/main/scala/kamon/newrelic/WebTransactionMetricExtractor.scala +++ b/kamon-newrelic/src/main/scala/kamon/newrelic/WebTransactionMetricExtractor.scala @@ -43,7 +43,7 @@ object WebTransactionMetricExtractor extends MetricExtractor { apdexBuilder.record(Time.Nanoseconds.scale(Time.Seconds)(record.level), record.count) } - Metric(elapsedTime, Time.Nanoseconds, "WebTransaction/Custom/" + entity.name, None) + Metric(elapsedTime, Time.Nanoseconds, "WebTransaction/Uri/" + entity.name, None) } // Accumulate all segment metrics @@ -89,7 +89,7 @@ object WebTransactionMetricExtractor extends MetricExtractor { val externalScopedByHostAndLibrary = externalScopedByHostAndLibrarySnapshots.map { case ((host, library, traceName), snapshots) ⇒ val mergedSnapshots = snapshots.foldLeft(Histogram.Snapshot.empty)(_.merge(_, collectionContext)) - Metric(mergedSnapshots, Time.Nanoseconds, s"External/$host/$library", Some("WebTransaction/Custom/" + traceName)) + Metric(mergedSnapshots, Time.Nanoseconds, s"External/$host/$library", Some("WebTransaction/Uri/" + traceName)) } Map(httpDispatcher, webTransaction, webTransactionTotal, externalAllWeb, externalAll, apdexBuilder.build) ++ diff --git a/project/Dependencies.scala b/project/Dependencies.scala index a10b3bb2..3b9b7980 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -35,7 +35,7 @@ object Dependencies { val scalatest = "org.scalatest" %% "scalatest" % "2.2.1" val logback = "ch.qos.logback" % "logback-classic" % "1.0.13" val aspectJ = "org.aspectj" % "aspectjweaver" % aspectjVersion - val newrelic = "com.newrelic.agent.java" % "newrelic-api" % "3.11.0" + val newrelic = "com.newrelic.agent.java" % "newrelic-agent" % "3.11.0" val hdrHistogram = "org.hdrhistogram" % "HdrHistogram" % "2.1.7" val sprayCan = "io.spray" %% "spray-can" % sprayVersion val sprayRouting = "io.spray" %% "spray-routing" % sprayVersion diff --git a/project/Projects.scala b/project/Projects.scala index a68677ef..f375acb8 100644 --- a/project/Projects.scala +++ b/project/Projects.scala @@ -99,7 +99,7 @@ object Projects extends Build { .settings( libraryDependencies ++= compile(sprayCan, sprayClient, sprayRouting, sprayJson, sprayJsonLenses, newrelic, akkaSlf4j) ++ - provided(aspectJ) ++ + provided(aspectJ, newrelic) ++ test(scalatest, akkaTestKit, sprayTestkit, slf4Api, akkaSlf4j)) @@ -212,7 +212,7 @@ object Projects extends Build { .settings(formatSettings: _*) .settings( libraryDependencies ++= - compile(sprayCan, sprayClient, sprayRouting, sprayJson, sprayJsonLenses, newrelic, akkaSlf4j) ++ + compile(sprayCan, sprayClient, sprayRouting, sprayJson, sprayJsonLenses, akkaSlf4j) ++ test(scalatest, akkaTestKit, slf4Api, slf4nop)) val noPublishing = Seq(publish := (), publishLocal := (), publishArtifact := false) -- cgit v1.2.3