diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2015-08-30 13:36:27 +0200 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2015-08-30 13:36:27 +0200 |
commit | 539b54c3b43c68ad418ca77032f557a4da3e3a59 (patch) | |
tree | 8f7a5f7528bc6fc16afb0351661e1d4b5687f41a /kamon-annotation/src | |
parent | 110fff9745a0c1f154ee3d7a5149cd9f162a879f (diff) | |
download | Kamon-539b54c3b43c68ad418ca77032f557a4da3e3a59.tar.gz Kamon-539b54c3b43c68ad418ca77032f557a4da3e3a59.tar.bz2 Kamon-539b54c3b43c68ad418ca77032f557a4da3e3a59.zip |
wip: only the modules that actually require an actor system are getting one.
Diffstat (limited to 'kamon-annotation/src')
6 files changed, 14 insertions, 26 deletions
diff --git a/kamon-annotation/src/main/scala/kamon/annotation/Annotation.scala b/kamon-annotation/src/main/scala/kamon/annotation/Annotation.scala index 6ddf57cf..4a1eed94 100644 --- a/kamon-annotation/src/main/scala/kamon/annotation/Annotation.scala +++ b/kamon-annotation/src/main/scala/kamon/annotation/Annotation.scala @@ -18,17 +18,12 @@ package kamon.annotation import akka.actor.{ ExtendedActorSystem, Extension, ExtensionId, ExtensionIdProvider } import akka.event.Logging import kamon.Kamon +import org.slf4j.LoggerFactory -object Annotation extends ExtensionId[AnnotationExtension] with ExtensionIdProvider { - override def lookup(): ExtensionId[_ <: Extension] = Annotation - override def createExtension(system: ExtendedActorSystem): AnnotationExtension = new AnnotationExtension(system) -} - -class AnnotationExtension(system: ExtendedActorSystem) extends Kamon.Extension { - val log = Logging(system, classOf[AnnotationExtension]) - log.info(s"Starting the Kamon(Annotation) extension") +object AnnotationExtension { + val log = LoggerFactory.getLogger("kamon.annotation.Annotation") - val config = system.settings.config.getConfig("kamon.annotation") + val config = Kamon.config.getConfig("kamon.annotation") val arraySize = config.getInt("instruments-array-size") } diff --git a/kamon-annotation/src/main/scala/kamon/annotation/el/EnhancedELProcessor.scala b/kamon-annotation/src/main/scala/kamon/annotation/el/EnhancedELProcessor.scala index f407930b..a0e42afd 100644 --- a/kamon-annotation/src/main/scala/kamon/annotation/el/EnhancedELProcessor.scala +++ b/kamon-annotation/src/main/scala/kamon/annotation/el/EnhancedELProcessor.scala @@ -18,8 +18,7 @@ package kamon.annotation.el import javax.el.ELProcessor -import kamon.Kamon -import kamon.annotation.Annotation +import kamon.annotation.AnnotationExtension import scala.util.{ Failure, Success, Try } @@ -36,7 +35,7 @@ object EnhancedELProcessor { eval[String](str) match { case Success(value) ⇒ value case Failure(cause) ⇒ - Kamon(Annotation).log.error(s"${cause.getMessage} -> we will complete the operation with 'unknown' string") + AnnotationExtension.log.error(s"${cause.getMessage} -> we will complete the operation with 'unknown' string") "unknown" } } getOrElse expression @@ -45,7 +44,7 @@ object EnhancedELProcessor { eval[Map[String, String]](s"{$str}") match { case Success(value) ⇒ value.asInstanceOf[java.util.HashMap[String, String]].asScala.toMap case Failure(cause) ⇒ - Kamon(Annotation).log.error(s"${cause.getMessage} -> we will complete the operation with an empty map") + AnnotationExtension.log.error(s"${cause.getMessage} -> we will complete the operation with an empty map") Map.empty[String, String] } } getOrElse Map.empty[String, String] diff --git a/kamon-annotation/src/main/scala/kamon/annotation/instrumentation/AnnotationInstrumentation.scala b/kamon-annotation/src/main/scala/kamon/annotation/instrumentation/AnnotationInstrumentation.scala index bfeac62a..e5d1aff9 100644 --- a/kamon-annotation/src/main/scala/kamon/annotation/instrumentation/AnnotationInstrumentation.scala +++ b/kamon-annotation/src/main/scala/kamon/annotation/instrumentation/AnnotationInstrumentation.scala @@ -29,7 +29,7 @@ class AnnotationInstrumentation extends BaseAnnotationInstrumentation { @After("execution((@kamon.annotation.EnableKamon AnnotationInstruments+).new(..)) && this(obj)") def creation(jps: JoinPoint.StaticPart, obj: AnnotationInstruments): Unit = { - val size = Kamon(Annotation).arraySize + val size = AnnotationExtension.arraySize obj.traces = new AtomicReferenceArray[TraceContextInfo](size) obj.segments = new AtomicReferenceArray[SegmentInfo](size) obj.counters = new AtomicReferenceArray[Counter](size) diff --git a/kamon-annotation/src/main/scala/kamon/annotation/instrumentation/StaticAnnotationInstrumentation.scala b/kamon-annotation/src/main/scala/kamon/annotation/instrumentation/StaticAnnotationInstrumentation.scala index 2320cc09..73112f5c 100644 --- a/kamon-annotation/src/main/scala/kamon/annotation/instrumentation/StaticAnnotationInstrumentation.scala +++ b/kamon-annotation/src/main/scala/kamon/annotation/instrumentation/StaticAnnotationInstrumentation.scala @@ -18,8 +18,7 @@ package kamon.annotation.instrumentation import java.util.concurrent.atomic.AtomicReferenceArray -import kamon.Kamon -import kamon.annotation.Annotation +import kamon.annotation.AnnotationExtension import kamon.metric.instrument import kamon.metric.instrument.{ Counter, MinMaxCounter } import org.aspectj.lang.annotation.{ After, AfterReturning, Around, Aspect } @@ -30,7 +29,7 @@ class StaticAnnotationInstrumentation extends BaseAnnotationInstrumentation with @After("staticinitialization(*) && !within(kamon.annotation.instrumentation.*)") def creation(jps: JoinPoint.StaticPart): Unit = { - val size = Kamon(Annotation).arraySize + val size = AnnotationExtension.arraySize traces = new AtomicReferenceArray[TraceContextInfo](size) segments = new AtomicReferenceArray[SegmentInfo](size) counters = new AtomicReferenceArray[Counter](size) diff --git a/kamon-annotation/src/test/resources/application.conf b/kamon-annotation/src/test/resources/application.conf new file mode 100644 index 00000000..89840bd3 --- /dev/null +++ b/kamon-annotation/src/test/resources/application.conf @@ -0,0 +1,4 @@ +kamon.metric { + tick-interval = 1 hour + default-collection-context-buffer-size = 100 +}
\ No newline at end of file diff --git a/kamon-annotation/src/test/scala/kamon/annotation/AnnotationInstrumentationSpec.scala b/kamon-annotation/src/test/scala/kamon/annotation/AnnotationInstrumentationSpec.scala index 3d94d246..142707a4 100644 --- a/kamon-annotation/src/test/scala/kamon/annotation/AnnotationInstrumentationSpec.scala +++ b/kamon-annotation/src/test/scala/kamon/annotation/AnnotationInstrumentationSpec.scala @@ -22,15 +22,6 @@ import kamon.testkit.BaseKamonSpec import kamon.trace.SegmentCategory class AnnotationInstrumentationSpec extends BaseKamonSpec("annotation-instrumentation-spec") { - override lazy val config = - ConfigFactory.parseString( - """ - |kamon.metric { - | tick-interval = 1 hour - | default-collection-context-buffer-size = 100 - |} - """.stripMargin) - "the Kamon Annotation module" should { "create a new trace when is invoked a method annotated with @Trace" in { for (id ← 1 to 10) Annotated(id).trace() |