diff options
67 files changed, 775 insertions, 152 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..7b6b3653 --- /dev/null +++ b/.gitignore @@ -0,0 +1,57 @@ +*.class +*.log +.history +*.sc +.pygments-cache +.DS_Store + +# sbt specific +dist/* +target/ +lib_managed/ +src_managed/ +project/boot/ +project/plugins/project/ +.ensime +.ensime_cache + +# Scala-IDE specific +.scala_dependencies +.idea +.idea_modules + +# Intellij +.idea/ +*.iml +*.iws + +# Eclipse +.project +.settings +.classpath +.cache +.cache-main +.cache-tests +bin/ + +_site + +# Ignore Play! working directory # +db +eclipse +lib +log +logs +modules +precompiled +project/project +project/target +target +tmp +test-result +server.pid +*.iml +*.eml + +# Default sigar library provision location. +native/ diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..ba4e71a6 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,12 @@ +language: scala +script: + - ./travis-test.sh +scala: + - 2.11.8 +jdk: + - oraclejdk8 +before_script: + - mkdir $TRAVIS_BUILD_DIR/tmp + - export SBT_OPTS="-Djava.io.tmpdir=$TRAVIS_BUILD_DIR/tmp" +sudo: false + diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..29221124 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,35 @@ +Contributing to Kamon +===================== + +Thanks for your intention on collaborating to the Kamon Project! It doesn't matter if you want to provide a small change +to our docs, are lost in configuration or want contribute a brand new feature, we value all of your contributions and +the time you take to use our tool and prepare a contribution, we only ask you to follow this guidance depending on your +situation: + +If you are experiencing a bug +----------------------------- + +If you see weird exceptions in your log or something definitely is working improperly please [open an issue] and include +the Kamon, Akka and Spray/Play! versions that you are using along with as many useful information you can find related +to the issue. If you can provide a gist or a short way to reproduce the issue we will be more than happy! + +If you don't know what is wrong +------------------------------- + +If you don't see any metrics at all or features are not working maybe you have a setup or configuration problem, to +address this kind of problems please send us a emails to our [mailing list] and we will reply as soon as we can! Again, +please include the relevant version and current setup information to speed up the process. If you are in doubt of +whether you have a bug or a configuration problem, email us and we will take care of openning a issue if necessary. + +If you want to make a code contribution to the project +------------------------------------------------------ + +Awesome! First, please note that we try to follow the [commit message conventions] used by the Spray guys and we need +you to electronically fill our [CLA] before accepting your contribution. Also, if your PR contains various commits, +please squash them into a single commit. Let the PR rain begin! + + +[open an issue]: https://github.com/kamon-io/Kamon/issues/new +[mailing list]: https://groups.google.com/forum/#!forum/kamon-user +[commit message conventions]: http://spray.io/project-info/contributing/ +[CLA]: https://docs.google.com/forms/d/1G_IDrBTFzOMwHvhxfKRBwNtpRelSa_MZ6jecH8lpTlc/viewform diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..1f48b3d5 --- /dev/null +++ b/LICENSE @@ -0,0 +1,15 @@ +This software is licensed under the Apache 2 license, quoted below. + +Copyright © 2013-2014 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.
\ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 00000000..175fb966 --- /dev/null +++ b/README.md @@ -0,0 +1,60 @@ +Kamon [![Build Status](https://travis-ci.org/kamon-io/Kamon.svg?branch=master)](https://travis-ci.org/kamon-io/Kamon) +========= + +Kamon is a set of tools for monitoring applications running on the JVM. + +[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/kamon-io/Kamon?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.kamon/kamon-core_2.11/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.kamon/kamon-core_2.11) + + +Modules +============ + +[Play Framework] ![Build Status](https://travis-ci.org/kamon-io/kamon-play.svg?branch=master) +[Spray] ![Build Status](https://travis-ci.org/kamon-io/kamon-spray.svg?branch=master) +[Akka] ![Build Status](https://travis-ci.org/kamon-io/kamon-akka.svg?branch=master) +[Akka Remote] ![Build Status](https://travis-ci.org/kamon-io/kamon-akka-remote.svg?branch=master) +[Akka Http] ![Build Status](https://travis-ci.org/kamon-io/kamon-akka-http.svg?branch=master) +[Scala] ![Build Status](https://travis-ci.org/kamon-io/kamon-scala.svg?branch=master) +[Annotation] ![Build Status](https://travis-ci.org/kamon-io/kamon-annotation.svg?branch=master) +[System Metrics] ![Build Status](https://travis-ci.org/kamon-io/kamon-system-metrics.svg?branch=master) +[JDBC] ![Build Status](https://travis-ci.org/kamon-io/kamon-jdbc.svg?branch=master) +[Elasticsearch] ![Build Status](https://travis-ci.org/kamon-io/kamon-elasticsearch.svg?branch=master) + +Backends +======== + +[Log Reporter] ![Build Status](https://travis-ci.org/kamon-io/kamon-log-reporter.svg?branch=master) +[StatsD] ![Build Status](https://travis-ci.org/kamon-io/kamon-statsd.svg?branch=master) +[Datadog] ![Build Status](https://travis-ci.org/kamon-io/kamon-datadog.svg?branch=master) +[SPM] ![Build Status](https://travis-ci.org/kamon-io/kamon-spm.svg?branch=master) +[InfluxDB] ![Build Status](https://travis-ci.org/kamon-io/kamon-influxdb.svg?branch=master) +[New Relic] ![Build Status](https://travis-ci.org/kamon-io/kamon-newrelic.svg?branch=master) +[FluentD] ![Build Status](https://travis-ci.org/kamon-io/kamon-fluentd.svg?branch=master) +[JMX] ![Build Status](https://travis-ci.org/kamon-io/kamon-jmx.svg?branch=master) +[Riemann] ![Build Status](https://travis-ci.org/kamon-io/kamon-riemann.svg?branch=master) +[Krhonus] ![Build Status](https://travis-ci.org/kamon-io/kamon-khronus.svg?branch=master) + + +[Play Framework]: https://github.com/kamon-io/kamon-play +[Spray]: https://github.com/kamon-io/kamon-spray +[Akka]:https://github.com/kamon-io/kamon-akka +[Akka Remote]: https://github.com/kamon-io/kamon-akka-remote +[Akka Http]: https://github.com/kamon-io/kamon-akka-http +[Scala]: https://github.com/kamon-io/kamon-scala +[Annotation]: https://github.com/kamon-io/kamon-annotation +[System Metrics]: https://github.com/kamon-io/kamon-system-metrics +[JDBC]: https://github.com/kamon-io/kamon-jdbc +[Elasticsearch]: https://github.com/kamon-io/kamon-elasticsearch + +[Log Reporter]: https://github.com/kamon-io/kamon-log-reporter +[SPM]: https://github.com/kamon-io/kamon-spm +[Datadog]: https://github.com/kamon-io/kamon-datadog +[FluentD]: https://github.com/kamon-io/kamon-fluentd +[JMX]: https://github.com/kamon-io/kamon-jmx +[StatsD]: https://github.com/kamon-io/kamon-statsd +[Riemann]: https://github.com/kamon-io/kamon-riemann +[Krhonus]: https://github.com/kamon-io/kamon-khronus +[New Relic]: https://github.com/kamon-io/kamon-newrelic +[InfluxDB]: https://github.com/kamon-io/kamon-influxdb + diff --git a/build.sbt b/build.sbt new file mode 100644 index 00000000..a8a3a7d2 --- /dev/null +++ b/build.sbt @@ -0,0 +1,60 @@ +/* ========================================================================================= + * Copyright © 2013-2016 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. + * ========================================================================================= + */ + + +import Settings._ +import Dependencies._ + +lazy val kamon = (project in file(".")) + .settings(moduleName := "root") + .settings(basicSettings: _*) + .settings(formatSettings: _*) + .settings(noPublishing: _*) + .aggregate(core, autoweave, testkit) + + +lazy val core = (project in file("kamon-core")) + .settings(basicSettings: _*) + .settings(formatSettings: _*) + .settings( + libraryDependencies ++= + compileScope(akkaActor, hdrHistogram, slf4jApi) ++ + providedScope(aspectJ) ++ + optionalScope(logback) ++ + testScope(scalatest, akkaTestKit, akkaSlf4j, logback)) + + +lazy val autoweave = (project in file("kamon-autoweave")) + .dependsOn(core) + .settings(basicSettings: _*) + .settings(formatSettings: _*) + .settings( + libraryDependencies ++= + compileScope(aspectJ) ++ + testScope(scalatest, slf4jApi)) + + +lazy val testkit = (project in file("kamon-testkit")) + .dependsOn(core) + .settings(basicSettings: _*) + .settings(formatSettings: _*) + .settings( + libraryDependencies ++= + compileScope(akkaActor, akkaTestKit) ++ + providedScope(aspectJ) ++ + testScope(slf4jApi, slf4jnop)) + + +lazy val noPublishing = Seq(publish := (), publishLocal := (), publishArtifact := false) diff --git a/kamon-autoweave/src/main/scala/kamon/autoweave/loader/AgentLoader.scala b/kamon-autoweave/src/main/scala/kamon/autoweave/loader/AgentLoader.scala index 5f865cb3..5271e987 100644 --- a/kamon-autoweave/src/main/scala/kamon/autoweave/loader/AgentLoader.scala +++ b/kamon-autoweave/src/main/scala/kamon/autoweave/loader/AgentLoader.scala @@ -15,10 +15,10 @@ package kamon.autoweave.loader -import java.io.{ File, FileOutputStream, InputStream } +import java.io.{File, FileOutputStream, InputStream} import java.lang.management.ManagementFactory import java.util.jar.Attributes.Name -import java.util.jar.{ JarEntry, JarOutputStream, Manifest } +import java.util.jar.{JarEntry, JarOutputStream, Manifest} import scala.util.control.NoStackTrace diff --git a/kamon-autoweave/src/main/scala/kamon/autoweave/loader/AttachmentProviders.scala b/kamon-autoweave/src/main/scala/kamon/autoweave/loader/AttachmentProviders.scala index fff23735..242d4ff8 100644 --- a/kamon-autoweave/src/main/scala/kamon/autoweave/loader/AttachmentProviders.scala +++ b/kamon-autoweave/src/main/scala/kamon/autoweave/loader/AttachmentProviders.scala @@ -16,11 +16,11 @@ package kamon.autoweave.loader import java.io.File -import java.net.{ URL, URLClassLoader } -import java.security.{ AccessController, PrivilegedAction } +import java.net.{URL, URLClassLoader} +import java.security.{AccessController, PrivilegedAction} import scala.util.control.NonFatal -import scala.util.{ Failure, Success, Try } +import scala.util.{Failure, Success, Try} object AttachmentProviders { diff --git a/kamon-core/src/main/scala/kamon/Kamon.scala b/kamon-core/src/main/scala/kamon/Kamon.scala index 4704ead1..46e75b4e 100644 --- a/kamon-core/src/main/scala/kamon/Kamon.scala +++ b/kamon-core/src/main/scala/kamon/Kamon.scala @@ -16,13 +16,13 @@ package kamon import _root_.akka.actor import _root_.akka.actor._ -import com.typesafe.config.{ Config, ConfigFactory, ConfigParseOptions, ConfigResolveOptions } +import com.typesafe.config.{Config, ConfigFactory, ConfigParseOptions, ConfigResolveOptions} import kamon.metric._ import kamon.trace.TracerModuleImpl import kamon.util.logger.LazyLogger import _root_.scala.util.control.NonFatal -import _root_.scala.util.{ Failure, Success, Try } +import _root_.scala.util.{Failure, Success, Try} object Kamon { diff --git a/kamon-core/src/main/scala/kamon/ModuleLoader.scala b/kamon-core/src/main/scala/kamon/ModuleLoader.scala index 989d8cd9..f1b5f414 100644 --- a/kamon-core/src/main/scala/kamon/ModuleLoader.scala +++ b/kamon-core/src/main/scala/kamon/ModuleLoader.scala @@ -20,7 +20,7 @@ import _root_.akka.actor import _root_.akka.actor._ import kamon.util.logger.LazyLogger import org.aspectj.lang.ProceedingJoinPoint -import org.aspectj.lang.annotation.{ Around, Aspect, Pointcut } +import org.aspectj.lang.annotation.{Around, Aspect, Pointcut} private[kamon] object ModuleLoader extends ExtensionId[ModuleLoaderExtension] with ExtensionIdProvider { def lookup(): ExtensionId[_ <: actor.Extension] = ModuleLoader diff --git a/kamon-core/src/main/scala/kamon/metric/EntityRecorder.scala b/kamon-core/src/main/scala/kamon/metric/EntityRecorder.scala index 810475b7..e3b136dd 100644 --- a/kamon-core/src/main/scala/kamon/metric/EntityRecorder.scala +++ b/kamon-core/src/main/scala/kamon/metric/EntityRecorder.scala @@ -59,7 +59,7 @@ private[kamon] sealed trait SingleInstrumentEntityRecorder extends EntityRecorde def instrument: Instrument def collect(collectionContext: CollectionContext): EntitySnapshot = - new DefaultEntitySnapshot(Map(key -> instrument.collect(collectionContext))) + new DefaultEntitySnapshot(Map(key → instrument.collect(collectionContext))) def cleanup: Unit = instrument.cleanup } @@ -225,7 +225,7 @@ abstract class GenericEntityRecorder(instrumentFactory: InstrumentFactory) exten def collect(collectionContext: CollectionContext): EntitySnapshot = { val snapshots = Map.newBuilder[MetricKey, InstrumentSnapshot] _instruments.foreach { - case (key, instrument) ⇒ snapshots += key -> instrument.collect(collectionContext) + case (key, instrument) ⇒ snapshots += key → instrument.collect(collectionContext) } new DefaultEntitySnapshot(snapshots.result()) diff --git a/kamon-core/src/main/scala/kamon/metric/EntitySnapshot.scala b/kamon-core/src/main/scala/kamon/metric/EntitySnapshot.scala index 7ebb79e2..16edecd8 100644 --- a/kamon-core/src/main/scala/kamon/metric/EntitySnapshot.scala +++ b/kamon-core/src/main/scala/kamon/metric/EntitySnapshot.scala @@ -16,7 +16,7 @@ package kamon.metric -import kamon.metric.instrument.{ Counter, Histogram, CollectionContext, InstrumentSnapshot } +import kamon.metric.instrument.{Counter, Histogram, CollectionContext, InstrumentSnapshot} import kamon.util.MapMerge import scala.reflect.ClassTag diff --git a/kamon-core/src/main/scala/kamon/metric/MetricScaleDecorator.scala b/kamon-core/src/main/scala/kamon/metric/MetricScaleDecorator.scala index e096429d..06de65ef 100644 --- a/kamon-core/src/main/scala/kamon/metric/MetricScaleDecorator.scala +++ b/kamon-core/src/main/scala/kamon/metric/MetricScaleDecorator.scala @@ -16,7 +16,7 @@ package kamon.metric -import akka.actor.{ Actor, ActorRef, Props } +import akka.actor.{Actor, ActorRef, Props} import kamon.metric.SubscriptionsDispatcher.TickMetricSnapshot import kamon.metric.instrument._ @@ -28,8 +28,10 @@ import kamon.metric.instrument._ * @param receiver Receiver of scaled metrics snapshot, usually a backend sender */ class MetricScaleDecorator(timeUnits: Option[Time], memoryUnits: Option[Memory], receiver: ActorRef) extends Actor { - require(timeUnits.isDefined || memoryUnits.isDefined, - "Use MetricScaleDecorator only when any of units is defined") + require( + timeUnits.isDefined || memoryUnits.isDefined, + "Use MetricScaleDecorator only when any of units is defined" + ) override def receive: Receive = { case tick: TickMetricSnapshot ⇒ @@ -41,7 +43,7 @@ class MetricScaleDecorator(timeUnits: Option[Time], memoryUnits: Option[Memory], case (memory: Memory, _, Some(to)) ⇒ metricSnapshot.scale(memory, to) case _ ⇒ metricSnapshot } - metricKey -> scaledSnapshot + metricKey → scaledSnapshot }) }) receiver forward scaled diff --git a/kamon-core/src/main/scala/kamon/metric/MetricsModule.scala b/kamon-core/src/main/scala/kamon/metric/MetricsModule.scala index 8b5a6188..75ef0851 100755 --- a/kamon-core/src/main/scala/kamon/metric/MetricsModule.scala +++ b/kamon-core/src/main/scala/kamon/metric/MetricsModule.scala @@ -18,7 +18,7 @@ package kamon.metric import akka.actor._ import com.typesafe.config.Config -import kamon.metric.SubscriptionsDispatcher.{ Subscribe, Unsubscribe } +import kamon.metric.SubscriptionsDispatcher.{Subscribe, Unsubscribe} import kamon.metric.instrument.Gauge.CurrentValueCollector import kamon.metric.instrument.Histogram.DynamicRange import kamon.metric.instrument._ @@ -248,8 +248,10 @@ private[kamon] class MetricsModuleImpl(config: Config) extends MetricsModule { val histogramEntity = Entity(name, SingleInstrumentEntityRecorder.Histogram, tags) val recorder = _trackedEntities.atomicGetOrElseUpdate(histogramEntity, { val factory = instrumentFactory(histogramEntity.category) - HistogramRecorder(HistogramKey(histogramEntity.category, unitOfMeasurement.getOrElse(UnitOfMeasurement.Unknown)), - factory.createHistogram(name, dynamicRange)) + HistogramRecorder( + HistogramKey(histogramEntity.category, unitOfMeasurement.getOrElse(UnitOfMeasurement.Unknown)), + factory.createHistogram(name, dynamicRange) + ) }, _.cleanup) recorder.asInstanceOf[HistogramRecorder].instrument @@ -264,8 +266,10 @@ private[kamon] class MetricsModuleImpl(config: Config) extends MetricsModule { val minMaxCounterEntity = Entity(name, SingleInstrumentEntityRecorder.MinMaxCounter, tags) val recorder = _trackedEntities.atomicGetOrElseUpdate(minMaxCounterEntity, { val factory = instrumentFactory(minMaxCounterEntity.category) - MinMaxCounterRecorder(MinMaxCounterKey(minMaxCounterEntity.category, unitOfMeasurement.getOrElse(UnitOfMeasurement.Unknown)), - factory.createMinMaxCounter(name, dynamicRange, refreshInterval)) + MinMaxCounterRecorder( + MinMaxCounterKey(minMaxCounterEntity.category, unitOfMeasurement.getOrElse(UnitOfMeasurement.Unknown)), + factory.createMinMaxCounter(name, dynamicRange, refreshInterval) + ) }, _.cleanup) recorder.asInstanceOf[MinMaxCounterRecorder].instrument @@ -281,8 +285,10 @@ private[kamon] class MetricsModuleImpl(config: Config) extends MetricsModule { val gaugeEntity = Entity(name, SingleInstrumentEntityRecorder.Gauge, tags) val recorder = _trackedEntities.atomicGetOrElseUpdate(gaugeEntity, { val factory = instrumentFactory(gaugeEntity.category) - GaugeRecorder(GaugeKey(gaugeEntity.category, unitOfMeasurement.getOrElse(UnitOfMeasurement.Unknown)), - factory.createGauge(name, dynamicRange, refreshInterval, valueCollector)) + GaugeRecorder( + GaugeKey(gaugeEntity.category, unitOfMeasurement.getOrElse(UnitOfMeasurement.Unknown)), + factory.createGauge(name, dynamicRange, refreshInterval, valueCollector) + ) }, _.cleanup) recorder.asInstanceOf[GaugeRecorder].instrument @@ -297,8 +303,10 @@ private[kamon] class MetricsModuleImpl(config: Config) extends MetricsModule { val counterEntity = Entity(name, SingleInstrumentEntityRecorder.Counter, tags) val recorder = _trackedEntities.atomicGetOrElseUpdate(counterEntity, { val factory = instrumentFactory(counterEntity.category) - CounterRecorder(CounterKey(counterEntity.category, unitOfMeasurement.getOrElse(UnitOfMeasurement.Unknown)), - factory.createCounter()) + CounterRecorder( + CounterKey(counterEntity.category, unitOfMeasurement.getOrElse(UnitOfMeasurement.Unknown)), + factory.createCounter() + ) }, _.cleanup) recorder.asInstanceOf[CounterRecorder].instrument diff --git a/kamon-core/src/main/scala/kamon/metric/MetricsSettings.scala b/kamon-core/src/main/scala/kamon/metric/MetricsSettings.scala index 018a6584..592e8f67 100644 --- a/kamon-core/src/main/scala/kamon/metric/MetricsSettings.scala +++ b/kamon-core/src/main/scala/kamon/metric/MetricsSettings.scala @@ -34,7 +34,8 @@ case class MetricsSettings( entityFilters: Map[String, EntityFilter], instrumentFactories: Map[String, InstrumentFactory], defaultInstrumentFactory: InstrumentFactory, - refreshScheduler: RefreshScheduler) { + refreshScheduler: RefreshScheduler +) { private[kamon] def pointScheduler(targetScheduler: RefreshScheduler): Unit = refreshScheduler match { case lrs: LazyRefreshScheduler ⇒ lrs.point(targetScheduler) diff --git a/kamon-core/src/main/scala/kamon/metric/SubscriptionsDispatcher.scala b/kamon-core/src/main/scala/kamon/metric/SubscriptionsDispatcher.scala index 9f8c7be3..09bf58ad 100644 --- a/kamon-core/src/main/scala/kamon/metric/SubscriptionsDispatcher.scala +++ b/kamon-core/src/main/scala/kamon/metric/SubscriptionsDispatcher.scala @@ -18,7 +18,7 @@ package kamon.metric import akka.actor._ import kamon.metric.SubscriptionsDispatcher._ -import kamon.util.{ MilliTimestamp, GlobPathFilter } +import kamon.util.{MilliTimestamp, GlobPathFilter} import scala.concurrent.duration.FiniteDuration /** diff --git a/kamon-core/src/main/scala/kamon/metric/TickMetricSnapshotBuffer.scala b/kamon-core/src/main/scala/kamon/metric/TickMetricSnapshotBuffer.scala index dfc5d5f0..22557974 100644 --- a/kamon-core/src/main/scala/kamon/metric/TickMetricSnapshotBuffer.scala +++ b/kamon-core/src/main/scala/kamon/metric/TickMetricSnapshotBuffer.scala @@ -16,7 +16,7 @@ package kamon.metric -import akka.actor.{ Props, Actor, ActorRef } +import akka.actor.{Props, Actor, ActorRef} import kamon.Kamon import kamon.metric.SubscriptionsDispatcher.TickMetricSnapshot import kamon.metric.TickMetricSnapshotBuffer.FlushBuffer diff --git a/kamon-core/src/main/scala/kamon/metric/TraceMetrics.scala b/kamon-core/src/main/scala/kamon/metric/TraceMetrics.scala index 014825cd..eaeebb97 100644 --- a/kamon-core/src/main/scala/kamon/metric/TraceMetrics.scala +++ b/kamon-core/src/main/scala/kamon/metric/TraceMetrics.scala @@ -16,7 +16,7 @@ package kamon.metric -import kamon.metric.instrument.{ Time, InstrumentFactory } +import kamon.metric.instrument.{Time, InstrumentFactory} class TraceMetrics(instrumentFactory: InstrumentFactory) extends GenericEntityRecorder(instrumentFactory) { diff --git a/kamon-core/src/main/scala/kamon/metric/instrument/Gauge.scala b/kamon-core/src/main/scala/kamon/metric/instrument/Gauge.scala index 61b53df2..39571d3d 100644 --- a/kamon-core/src/main/scala/kamon/metric/instrument/Gauge.scala +++ b/kamon-core/src/main/scala/kamon/metric/instrument/Gauge.scala @@ -16,7 +16,7 @@ package kamon.metric.instrument -import java.util.concurrent.atomic.{ AtomicLong, AtomicLongFieldUpdater, AtomicReference } +import java.util.concurrent.atomic.{AtomicLong, AtomicLongFieldUpdater, AtomicReference} import akka.actor.Cancellable import kamon.metric.instrument.Gauge.CurrentValueCollector diff --git a/kamon-core/src/main/scala/kamon/metric/instrument/Histogram.scala b/kamon-core/src/main/scala/kamon/metric/instrument/Histogram.scala index b390cefe..212d4225 100644 --- a/kamon-core/src/main/scala/kamon/metric/instrument/Histogram.scala +++ b/kamon-core/src/main/scala/kamon/metric/instrument/Histogram.scala @@ -18,15 +18,15 @@ package kamon.metric.instrument import java.nio.LongBuffer -import kamon.metric.instrument.Histogram.{ DynamicRange, Snapshot } +import kamon.metric.instrument.Histogram.{DynamicRange, Snapshot} import kamon.util.logger.LazyLogger import org.HdrHistogram.ModifiedAtomicHistogram trait Histogram extends Instrument { type SnapshotType = Histogram.Snapshot - def record(value: Long) - def record(value: Long, count: Long) + def record(value: Long): Unit + def record(value: Long, count: Long): Unit } object Histogram { @@ -145,8 +145,10 @@ object HdrHistogram { * The collect(..) operation extracts all the recorded values from the histogram and resets the counts, but still * leave it in a consistent state even in the case of concurrent modification while the snapshot is being taken. */ -class HdrHistogram(dynamicRange: DynamicRange) extends ModifiedAtomicHistogram(dynamicRange.lowestDiscernibleValue, - dynamicRange.highestTrackableValue, dynamicRange.precision) with Histogram { +class HdrHistogram(dynamicRange: DynamicRange) extends ModifiedAtomicHistogram( + dynamicRange.lowestDiscernibleValue, + dynamicRange.highestTrackableValue, dynamicRange.precision +) with Histogram { import HdrHistogram.log def record(value: Long): Unit = tryRecord(value, 1L) diff --git a/kamon-core/src/main/scala/kamon/metric/instrument/InstrumentSettings.scala b/kamon-core/src/main/scala/kamon/metric/instrument/InstrumentSettings.scala index f7516262..e4d6f547 100644 --- a/kamon-core/src/main/scala/kamon/metric/instrument/InstrumentSettings.scala +++ b/kamon-core/src/main/scala/kamon/metric/instrument/InstrumentSettings.scala @@ -13,8 +13,10 @@ case class InstrumentCustomSettings(lowestDiscernibleValue: Option[Long], highes DynamicRange( lowestDiscernibleValue.getOrElse(that.dynamicRange.lowestDiscernibleValue), highestTrackableValue.getOrElse(that.dynamicRange.highestTrackableValue), - precision.getOrElse(that.dynamicRange.precision)), - refreshInterval.orElse(that.refreshInterval)) + precision.getOrElse(that.dynamicRange.precision) + ), + refreshInterval.orElse(that.refreshInterval) + ) } object InstrumentCustomSettings { @@ -25,7 +27,8 @@ object InstrumentCustomSettings { if (config.hasPath("lowest-discernible-value")) Some(config.getLong("lowest-discernible-value")) else None, if (config.hasPath("highest-trackable-value")) Some(config.getLong("highest-trackable-value")) else None, if (config.hasPath("precision")) Some(InstrumentSettings.parsePrecision(config.getString("precision"))) else None, - if (config.hasPath("refresh-interval")) Some(config.getFiniteDuration("refresh-interval")) else None) + if (config.hasPath("refresh-interval")) Some(config.getFiniteDuration("refresh-interval")) else None + ) } @@ -37,7 +40,8 @@ object InstrumentSettings { DynamicRange( config.getLong("lowest-discernible-value"), config.getLong("highest-trackable-value"), - parsePrecision(config.getString("precision"))) + parsePrecision(config.getString("precision")) + ) def parsePrecision(stringValue: String): Int = stringValue match { case "low" ⇒ 1 @@ -55,10 +59,14 @@ object DefaultInstrumentSettings { import kamon.util.ConfigTools.Syntax val histogramSettings = InstrumentSettings(InstrumentSettings.readDynamicRange(config.getConfig("histogram")), None) - val minMaxCounterSettings = InstrumentSettings(InstrumentSettings.readDynamicRange(config.getConfig("min-max-counter")), - Some(config.getFiniteDuration("min-max-counter.refresh-interval"))) - val gaugeSettings = InstrumentSettings(InstrumentSettings.readDynamicRange(config.getConfig("gauge")), - Some(config.getFiniteDuration("gauge.refresh-interval"))) + val minMaxCounterSettings = InstrumentSettings( + InstrumentSettings.readDynamicRange(config.getConfig("min-max-counter")), + Some(config.getFiniteDuration("min-max-counter.refresh-interval")) + ) + val gaugeSettings = InstrumentSettings( + InstrumentSettings.readDynamicRange(config.getConfig("gauge")), + Some(config.getFiniteDuration("gauge.refresh-interval")) + ) DefaultInstrumentSettings(histogramSettings, minMaxCounterSettings, gaugeSettings) } diff --git a/kamon-core/src/main/scala/kamon/metric/instrument/MinMaxCounter.scala b/kamon-core/src/main/scala/kamon/metric/instrument/MinMaxCounter.scala index 0828c8a9..76fc2c2a 100644 --- a/kamon-core/src/main/scala/kamon/metric/instrument/MinMaxCounter.scala +++ b/kamon-core/src/main/scala/kamon/metric/instrument/MinMaxCounter.scala @@ -29,8 +29,8 @@ trait MinMaxCounter extends Instrument { def increment(): Unit def increment(times: Long): Unit - def decrement() - def decrement(times: Long) + def decrement(): Unit + def decrement(times: Long): Unit def refreshValues(): Unit } diff --git a/kamon-core/src/main/scala/kamon/metric/instrument/RefreshScheduler.scala b/kamon-core/src/main/scala/kamon/metric/instrument/RefreshScheduler.scala index 4809ac0d..6bc02dc3 100644 --- a/kamon-core/src/main/scala/kamon/metric/instrument/RefreshScheduler.scala +++ b/kamon-core/src/main/scala/kamon/metric/instrument/RefreshScheduler.scala @@ -16,7 +16,7 @@ package kamon.metric.instrument -import akka.actor.{ Scheduler, Cancellable } +import akka.actor.{Scheduler, Cancellable} import org.HdrHistogram.WriterReaderPhaser import scala.collection.concurrent.TrieMap diff --git a/kamon-core/src/main/scala/kamon/trace/Incubator.scala b/kamon-core/src/main/scala/kamon/trace/Incubator.scala index 05279d95..fe5ad569 100644 --- a/kamon-core/src/main/scala/kamon/trace/Incubator.scala +++ b/kamon-core/src/main/scala/kamon/trace/Incubator.scala @@ -16,9 +16,9 @@ package kamon.trace -import akka.actor.{ ActorLogging, Props, Actor, ActorRef } -import kamon.trace.Incubator.{ CheckForCompletedTraces, IncubatingTrace } -import kamon.util.{ NanoInterval, RelativeNanoTimestamp } +import akka.actor.{ActorLogging, Props, Actor, ActorRef} +import kamon.trace.Incubator.{CheckForCompletedTraces, IncubatingTrace} +import kamon.util.{NanoInterval, RelativeNanoTimestamp} import scala.annotation.tailrec import scala.collection.immutable.Queue import kamon.util.ConfigTools.Syntax diff --git a/kamon-core/src/main/scala/kamon/trace/MetricsOnlyContext.scala b/kamon-core/src/main/scala/kamon/trace/MetricsOnlyContext.scala index c1e23d91..bc0bedba 100644 --- a/kamon-core/src/main/scala/kamon/trace/MetricsOnlyContext.scala +++ b/kamon-core/src/main/scala/kamon/trace/MetricsOnlyContext.scala @@ -20,19 +20,21 @@ import java.util.concurrent.ConcurrentLinkedQueue import akka.event.LoggingAdapter import kamon.Kamon -import kamon.metric.{ SegmentMetrics, TraceMetrics } -import kamon.util.{ NanoInterval, RelativeNanoTimestamp } +import kamon.metric.{SegmentMetrics, TraceMetrics} +import kamon.util.{NanoInterval, RelativeNanoTimestamp} import scala.annotation.tailrec import scala.collection.concurrent.TrieMap -private[kamon] class MetricsOnlyContext(traceName: String, +private[kamon] class MetricsOnlyContext( + traceName: String, val token: String, traceTags: Map[String, String], currentStatus: Status, val levelOfDetail: LevelOfDetail, val startTimestamp: RelativeNanoTimestamp, - log: LoggingAdapter) extends TraceContext { + log: LoggingAdapter +) extends TraceContext { @volatile private var _name = traceName @volatile private var _status = currentStatus @@ -86,9 +88,10 @@ private[kamon] class MetricsOnlyContext(traceName: String, val segment = _finishedSegments.poll() if (segment != null) { val defaultTags = Map( - "trace" -> name, - "category" -> segment.category, - "library" -> segment.library) + "trace" → name, + "category" → segment.category, + "library" → segment.library + ) if (Kamon.metrics.shouldTrack(segment.name, SegmentMetrics.category)) { val segmentEntity = Kamon.metrics.entity(SegmentMetrics, segment.name, defaultTags ++ segment.tags) @@ -99,12 +102,14 @@ private[kamon] class MetricsOnlyContext(traceName: String, } } - protected def finishSegment(segmentName: String, + protected def finishSegment( + segmentName: String, category: String, library: String, duration: NanoInterval, segmentTags: Map[String, String], - isFinishedWithError: Boolean): Unit = { + isFinishedWithError: Boolean + ): Unit = { _finishedSegments.add(SegmentLatencyData(segmentName, category, library, duration, segmentTags, isFinishedWithError)) @@ -120,10 +125,12 @@ private[kamon] class MetricsOnlyContext(traceName: String, // will be returned. def elapsedTime: NanoInterval = _elapsedTime - class MetricsOnlySegment(segmentName: String, + class MetricsOnlySegment( + segmentName: String, val category: String, val library: String, - segmentTags: Map[String, String]) extends Segment { + segmentTags: Map[String, String] + ) extends Segment { private val _startTimestamp = RelativeNanoTimestamp.now private val _tags = TrieMap.empty[String, String] ++= segmentTags @@ -169,9 +176,11 @@ private[kamon] class MetricsOnlyContext(traceName: String, } } -case class SegmentLatencyData(name: String, +case class SegmentLatencyData( + name: String, category: String, library: String, duration: NanoInterval, tags: Map[String, String], - isFinishedWithError: Boolean)
\ No newline at end of file + isFinishedWithError: Boolean +)
\ No newline at end of file diff --git a/kamon-core/src/main/scala/kamon/trace/Sampler.scala b/kamon-core/src/main/scala/kamon/trace/Sampler.scala index 8480ecff..234c67bb 100644 --- a/kamon-core/src/main/scala/kamon/trace/Sampler.scala +++ b/kamon-core/src/main/scala/kamon/trace/Sampler.scala @@ -18,7 +18,7 @@ package kamon.trace import java.net.InetAddress import java.util.concurrent.atomic.AtomicLong -import kamon.util.{ NanoTimestamp, NanoInterval, Sequencer } +import kamon.util.{NanoTimestamp, NanoInterval, Sequencer} import scala.concurrent.forkjoin.ThreadLocalRandom import scala.util.Try diff --git a/kamon-core/src/main/scala/kamon/trace/TraceContext.scala b/kamon-core/src/main/scala/kamon/trace/TraceContext.scala index c5704caa..bbf40d8d 100644 --- a/kamon-core/src/main/scala/kamon/trace/TraceContext.scala +++ b/kamon-core/src/main/scala/kamon/trace/TraceContext.scala @@ -21,7 +21,7 @@ import java.util import kamon.trace.Status.Closed import kamon.trace.TraceContextAware.DefaultTraceContextAware -import kamon.util.{ Function, RelativeNanoTimestamp, SameThreadExecutionContext, Supplier } +import kamon.util.{Function, RelativeNanoTimestamp, SameThreadExecutionContext, Supplier} import scala.concurrent.Future @@ -38,7 +38,7 @@ trait TraceContext { def rename(newName: String): Unit def startSegment(segmentName: String, category: String, library: String): Segment def startSegment(segmentName: String, category: String, library: String, tags: Map[String, String]): Segment - def addMetadata(key: String, value: String) + def addMetadata(key: String, value: String): Unit def addTag(key: String, value: String): Unit def removeTag(key: String, value: String): Boolean def startTimestamp: RelativeNanoTimestamp diff --git a/kamon-core/src/main/scala/kamon/trace/TraceSubscriptions.scala b/kamon-core/src/main/scala/kamon/trace/TraceSubscriptions.scala index f2da404c..47455ec5 100644 --- a/kamon-core/src/main/scala/kamon/trace/TraceSubscriptions.scala +++ b/kamon-core/src/main/scala/kamon/trace/TraceSubscriptions.scala @@ -16,7 +16,7 @@ package kamon.trace -import akka.actor.{ Terminated, ActorRef, Actor } +import akka.actor.{Terminated, ActorRef, Actor} class TraceSubscriptions extends Actor { import TraceSubscriptions._ diff --git a/kamon-core/src/main/scala/kamon/trace/TracerModule.scala b/kamon-core/src/main/scala/kamon/trace/TracerModule.scala index a60b1617..b7b6c17a 100644 --- a/kamon-core/src/main/scala/kamon/trace/TracerModule.scala +++ b/kamon-core/src/main/scala/kamon/trace/TracerModule.scala @@ -19,7 +19,7 @@ package kamon.trace import java.util import akka.actor._ -import akka.event.{ Logging, LoggingAdapter } +import akka.event.{Logging, LoggingAdapter} import com.typesafe.config.Config import kamon.Kamon import kamon.metric.MetricsModule diff --git a/kamon-core/src/main/scala/kamon/trace/TracingContext.scala b/kamon-core/src/main/scala/kamon/trace/TracingContext.scala index 4cada1d0..1ea35526 100644 --- a/kamon-core/src/main/scala/kamon/trace/TracingContext.scala +++ b/kamon-core/src/main/scala/kamon/trace/TracingContext.scala @@ -20,11 +20,12 @@ import java.util.concurrent.ConcurrentLinkedQueue import java.util.concurrent.atomic.AtomicInteger import akka.event.LoggingAdapter -import kamon.util.{ NanoInterval, NanoTimestamp, RelativeNanoTimestamp } +import kamon.util.{NanoInterval, NanoTimestamp, RelativeNanoTimestamp} import scala.collection.concurrent.TrieMap -private[trace] class TracingContext(traceName: String, +private[trace] class TracingContext( + traceName: String, token: String, tags: Map[String, String], currentStatus: Status, @@ -32,7 +33,8 @@ private[trace] class TracingContext(traceName: String, isLocal: Boolean, startTimeztamp: RelativeNanoTimestamp, log: LoggingAdapter, - traceInfoSink: TracingContext ⇒ Unit) extends MetricsOnlyContext(traceName, token, tags, currentStatus, levelOfDetail, startTimeztamp, log) { + traceInfoSink: TracingContext ⇒ Unit +) extends MetricsOnlyContext(traceName, token, tags, currentStatus, levelOfDetail, startTimeztamp, log) { private val _openSegments = new AtomicInteger(0) private val _startTimestamp = NanoTimestamp.now @@ -87,10 +89,12 @@ private[trace] class TracingContext(traceName: String, TraceInfo(name, token, _startTimestamp, elapsedTime, _metadata.toMap, tags, segmentsInfo.result(), status) } - class TracingSegment(segmentName: String, + class TracingSegment( + segmentName: String, category: String, library: String, - tags: Map[String, String]) extends MetricsOnlySegment(segmentName, category, library, tags) { + tags: Map[String, String] + ) extends MetricsOnlySegment(segmentName, category, library, tags) { private val metadata = TrieMap.empty[String, String] override def addMetadata(key: String, value: String): Unit = metadata.put(key, value) diff --git a/kamon-core/src/main/scala/kamon/trace/logging/MdcKeysSupport.scala b/kamon-core/src/main/scala/kamon/trace/logging/MdcKeysSupport.scala index c757027c..556366b0 100644 --- a/kamon-core/src/main/scala/kamon/trace/logging/MdcKeysSupport.scala +++ b/kamon-core/src/main/scala/kamon/trace/logging/MdcKeysSupport.scala @@ -17,7 +17,7 @@ package kamon.trace.logging import kamon.trace.TraceLocal.AvailableToMdc -import kamon.trace.{ EmptyTraceContext, MetricsOnlyContext, TraceContext, Tracer } +import kamon.trace.{EmptyTraceContext, MetricsOnlyContext, TraceContext, Tracer} import kamon.util.Supplier import org.slf4j.MDC @@ -44,7 +44,7 @@ trait MdcKeysSupport { MDC.put(traceNameKey, ctx.name) defaultKeys ++ ctx.traceLocalStorage.underlyingStorage.collect { - case (available: AvailableToMdc, value) ⇒ Map(available.mdcKey -> String.valueOf(value)) + case (available: AvailableToMdc, value) ⇒ Map(available.mdcKey → String.valueOf(value)) }.flatMap { value ⇒ value.map { case (k, v) ⇒ MDC.put(k, v); k } } case EmptyTraceContext ⇒ Iterable.empty[String] diff --git a/kamon-core/src/main/scala/kamon/util/ConfigTools.scala b/kamon-core/src/main/scala/kamon/util/ConfigTools.scala index d0665764..cbf530e4 100644 --- a/kamon-core/src/main/scala/kamon/util/ConfigTools.scala +++ b/kamon-core/src/main/scala/kamon/util/ConfigTools.scala @@ -22,7 +22,7 @@ import com.typesafe.config.Config import scala.concurrent.duration.FiniteDuration -import kamon.metric.instrument.{ Memory, Time } +import kamon.metric.instrument.{Memory, Time} object ConfigTools { implicit class Syntax(val config: Config) extends AnyVal { diff --git a/kamon-core/src/main/scala/kamon/util/FastDispatch.scala b/kamon-core/src/main/scala/kamon/util/FastDispatch.scala index d2748847..7a94aefc 100644 --- a/kamon-core/src/main/scala/kamon/util/FastDispatch.scala +++ b/kamon-core/src/main/scala/kamon/util/FastDispatch.scala @@ -18,7 +18,7 @@ package kamon.util import akka.actor.ActorRef -import scala.concurrent.{ ExecutionContext, Future } +import scala.concurrent.{ExecutionContext, Future} /** * Extension for Future[ActorRef]. Try to dispatch a message to a Future[ActorRef] in the same thread if it has already diff --git a/kamon-core/src/main/scala/kamon/util/LazyActorRef.scala b/kamon-core/src/main/scala/kamon/util/LazyActorRef.scala index e2fb747a..a07abea6 100644 --- a/kamon-core/src/main/scala/kamon/util/LazyActorRef.scala +++ b/kamon-core/src/main/scala/kamon/util/LazyActorRef.scala @@ -19,7 +19,7 @@ package kamon.util import java.util import java.util.concurrent.ConcurrentLinkedQueue -import akka.actor.{ Actor, ActorRef } +import akka.actor.{Actor, ActorRef} import org.HdrHistogram.WriterReaderPhaser import scala.annotation.tailrec diff --git a/kamon-core/src/main/scala/kamon/util/MapMerge.scala b/kamon-core/src/main/scala/kamon/util/MapMerge.scala index 8573358b..6fc6fb15 100644 --- a/kamon-core/src/main/scala/kamon/util/MapMerge.scala +++ b/kamon-core/src/main/scala/kamon/util/MapMerge.scala @@ -28,7 +28,7 @@ object MapMerge { map.foreach { case (key, value) ⇒ val mergedValue = that.get(key).map(v ⇒ valueMerge(value, v)).getOrElse(value) - merged += key -> mergedValue + merged += key → mergedValue } that.foreach { diff --git a/kamon-core/src/main/scala/kamon/util/NeedToScale.scala b/kamon-core/src/main/scala/kamon/util/NeedToScale.scala index 19e1ae06..1397050f 100644 --- a/kamon-core/src/main/scala/kamon/util/NeedToScale.scala +++ b/kamon-core/src/main/scala/kamon/util/NeedToScale.scala @@ -17,7 +17,7 @@ package kamon.util import com.typesafe.config.Config -import kamon.metric.instrument.{ Memory, Time } +import kamon.metric.instrument.{Memory, Time} import kamon.util.ConfigTools._ object NeedToScale { @@ -30,7 +30,7 @@ object NeedToScale { val scaleMemoryTo: Option[Memory] = if (config.hasPath(MemoryUnits)) Some(config.memory(MemoryUnits)) else None - if (scaleTimeTo.isDefined || scaleMemoryTo.isDefined) Some(scaleTimeTo -> scaleMemoryTo) + if (scaleTimeTo.isDefined || scaleMemoryTo.isDefined) Some(scaleTimeTo → scaleMemoryTo) else None } } diff --git a/kamon-core/src/main/scala/kamon/util/executors/ExecutorMetricRecorder.scala b/kamon-core/src/main/scala/kamon/util/executors/ExecutorMetricRecorder.scala index 82655e9a..732e189e 100644 --- a/kamon-core/src/main/scala/kamon/util/executors/ExecutorMetricRecorder.scala +++ b/kamon-core/src/main/scala/kamon/util/executors/ExecutorMetricRecorder.scala @@ -16,9 +16,9 @@ package kamon.util.executors -import kamon.metric.{ EntityRecorderFactory, GenericEntityRecorder } -import kamon.metric.instrument.{ Gauge, MinMaxCounter, DifferentialValueCollector, InstrumentFactory } -import java.util.concurrent.{ ForkJoinPool ⇒ JavaForkJoinPool, ThreadPoolExecutor } +import kamon.metric.{EntityRecorderFactory, GenericEntityRecorder} +import kamon.metric.instrument.{Gauge, MinMaxCounter, DifferentialValueCollector, InstrumentFactory} +import java.util.concurrent.{ForkJoinPool ⇒ JavaForkJoinPool, ThreadPoolExecutor} import kamon.util.executors.ForkJoinPools.ForkJoinMetrics import scala.concurrent.forkjoin.ForkJoinPool diff --git a/kamon-core/src/main/scala/kamon/util/executors/ExecutorServiceMetrics.scala b/kamon-core/src/main/scala/kamon/util/executors/ExecutorServiceMetrics.scala index 98d2ea0c..60612beb 100644 --- a/kamon-core/src/main/scala/kamon/util/executors/ExecutorServiceMetrics.scala +++ b/kamon-core/src/main/scala/kamon/util/executors/ExecutorServiceMetrics.scala @@ -16,7 +16,7 @@ package kamon.util.executors -import java.util.concurrent.{ ExecutorService, ForkJoinPool ⇒ JavaForkJoinPool, ThreadPoolExecutor } +import java.util.concurrent.{ExecutorService, ForkJoinPool ⇒ JavaForkJoinPool, ThreadPoolExecutor} import kamon.Kamon import kamon.metric.Entity @@ -49,7 +49,7 @@ object ExecutorServiceMetrics { * @param tags The tags associated to the [[ThreadPoolExecutor]] */ @inline private def registerThreadPool(name: String, threadPool: ThreadPoolExecutor, tags: Map[String, String]): Entity = { - val threadPoolEntity = Entity(name, Category, tags + ("executor-type" -> "thread-pool-executor")) + val threadPoolEntity = Entity(name, Category, tags + ("executor-type" → "thread-pool-executor")) Kamon.metrics.entity(ThreadPoolExecutorMetrics.factory(threadPool, Category), threadPoolEntity) threadPoolEntity } @@ -63,7 +63,7 @@ object ExecutorServiceMetrics { * @param tags The tags associated to the [[ForkJoinPool]] */ @inline private def registerScalaForkJoin(name: String, forkJoinPool: ForkJoinPool, tags: Map[String, String]): Entity = { - val forkJoinEntity = Entity(name, Category, tags + ("executor-type" -> "fork-join-pool")) + val forkJoinEntity = Entity(name, Category, tags + ("executor-type" → "fork-join-pool")) Kamon.metrics.entity(ForkJoinPoolMetrics.factory(forkJoinPool, Category), forkJoinEntity) forkJoinEntity } @@ -77,7 +77,7 @@ object ExecutorServiceMetrics { * @param tags The tags associated to the [[JavaForkJoinPool]] */ @inline private def registerJavaForkJoin(name: String, forkJoinPool: JavaForkJoinPool, tags: Map[String, String]): Entity = { - val forkJoinEntity = Entity(name, Category, tags + ("executor-type" -> "fork-join-pool")) + val forkJoinEntity = Entity(name, Category, tags + ("executor-type" → "fork-join-pool")) Kamon.metrics.entity(ForkJoinPoolMetrics.factory(forkJoinPool, Category), forkJoinEntity) forkJoinEntity } @@ -97,7 +97,7 @@ object ExecutorServiceMetrics { case delegatedExecutor: ExecutorService if delegatedExecutor.getClass.isAssignableFrom(DelegatedExecutor) ⇒ registerDelegatedExecutor(name, delegatedExecutor, tags) case delegatedScheduledExecutor: ExecutorService if delegatedScheduledExecutor.getClass.isAssignableFrom(DelegateScheduled) ⇒ registerDelegatedExecutor(name, delegatedScheduledExecutor, tags) case finalizableDelegatedExecutor: ExecutorService if finalizableDelegatedExecutor.getClass.isAssignableFrom(FinalizableDelegated) ⇒ registerDelegatedExecutor(name, finalizableDelegatedExecutor, tags) - case other ⇒ throw new NotSupportedException(s"The ExecutorService $name is not supported.") + case other ⇒ throw NotSupportedException(s"The ExecutorService $name is not supported.") } //Java variant diff --git a/kamon-core/src/main/scala/kamon/util/http/HttpServerMetrics.scala b/kamon-core/src/main/scala/kamon/util/http/HttpServerMetrics.scala index 81e8fb8b..929fef4f 100644 --- a/kamon-core/src/main/scala/kamon/util/http/HttpServerMetrics.scala +++ b/kamon-core/src/main/scala/kamon/util/http/HttpServerMetrics.scala @@ -16,7 +16,7 @@ package kamon.util.http -import kamon.metric.{ EntityRecorderFactory, GenericEntityRecorder } +import kamon.metric.{EntityRecorderFactory, GenericEntityRecorder} import kamon.metric.instrument.InstrumentFactory /** diff --git a/kamon-core/src/main/scala/kamon/util/logger/LazyLogger.scala b/kamon-core/src/main/scala/kamon/util/logger/LazyLogger.scala index c70c316d..11be7bbe 100644 --- a/kamon-core/src/main/scala/kamon/util/logger/LazyLogger.scala +++ b/kamon-core/src/main/scala/kamon/util/logger/LazyLogger.scala @@ -15,7 +15,7 @@ package kamon.util.logger -import org.slf4j.{ Logger ⇒ SLF4JLogger } +import org.slf4j.{Logger ⇒ SLF4JLogger} class LazyLogger(val logger: SLF4JLogger) { @@ -41,7 +41,7 @@ class LazyLogger(val logger: SLF4JLogger) { } object LazyLogger { - import scala.reflect.{ classTag, ClassTag } + import scala.reflect.{classTag, ClassTag} def apply(name: String): LazyLogger = new LazyLogger(org.slf4j.LoggerFactory.getLogger(name)) def apply(cls: Class[_]): LazyLogger = apply(cls.getName) diff --git a/kamon-core/src/test/scala/kamon/metric/MetricScaleDecoratorSpec.scala b/kamon-core/src/test/scala/kamon/metric/MetricScaleDecoratorSpec.scala index 902102cd..d3d0f4fb 100644 --- a/kamon-core/src/test/scala/kamon/metric/MetricScaleDecoratorSpec.scala +++ b/kamon-core/src/test/scala/kamon/metric/MetricScaleDecoratorSpec.scala @@ -18,7 +18,7 @@ package kamon.metric import kamon.Kamon import kamon.metric.SubscriptionsDispatcher.TickMetricSnapshot -import kamon.metric.instrument.{ InstrumentFactory, Memory, Time, UnitOfMeasurement } +import kamon.metric.instrument.{InstrumentFactory, Memory, Time, UnitOfMeasurement} import kamon.testkit.BaseKamonSpec import kamon.util.MilliTimestamp import org.scalatest.OptionValues._ @@ -28,7 +28,8 @@ class MetricScaleDecoratorSpec extends BaseKamonSpec("metrics-scale-decorator-sp "receives a snapshot" which { val scaleDecorator = system.actorOf(MetricScaleDecorator.props( - Some(Time.Milliseconds), Some(Memory.KiloBytes), testActor)) + Some(Time.Milliseconds), Some(Memory.KiloBytes), testActor + )) "is empty" should { "do nothing for empty snapshots" in { scaleDecorator ! emptySnapshot @@ -94,7 +95,8 @@ trait SnapshotFixtures { recorder.kbyteMemory.increment(100L) val nonEmptySnapshot = TickMetricSnapshot(new MilliTimestamp(1000), new MilliTimestamp(2000), Map( - (testEntity -> recorder.collect(collectionContext)))) + (testEntity → recorder.collect(collectionContext)) + )) } diff --git a/kamon-core/src/test/scala/kamon/metric/SubscriptionsProtocolSpec.scala b/kamon-core/src/test/scala/kamon/metric/SubscriptionsProtocolSpec.scala index b8131f6e..36cc62c3 100644 --- a/kamon-core/src/test/scala/kamon/metric/SubscriptionsProtocolSpec.scala +++ b/kamon-core/src/test/scala/kamon/metric/SubscriptionsProtocolSpec.scala @@ -17,7 +17,7 @@ package kamon.metric import akka.actor._ -import akka.testkit.{ TestProbe, ImplicitSender } +import akka.testkit.{TestProbe, ImplicitSender} import com.typesafe.config.ConfigFactory import kamon.Kamon import kamon.metric.SubscriptionsDispatcher.TickMetricSnapshot @@ -31,10 +31,11 @@ class SubscriptionsProtocolSpec extends BaseKamonSpec("subscriptions-protocol-sp |kamon.metric { | tick-interval = 1 hour |} - """.stripMargin) + """.stripMargin + ) lazy val metricsModule = Kamon.metrics - import metricsModule.{ entity, subscribe, unsubscribe } + import metricsModule.{entity, subscribe, unsubscribe} "the Subscriptions messaging protocol" should { "allow subscribing for a single tick" in { diff --git a/kamon-core/src/test/scala/kamon/metric/TickMetricSnapshotBufferSpec.scala b/kamon-core/src/test/scala/kamon/metric/TickMetricSnapshotBufferSpec.scala index 97bf0e2c..6172a9e0 100644 --- a/kamon-core/src/test/scala/kamon/metric/TickMetricSnapshotBufferSpec.scala +++ b/kamon-core/src/test/scala/kamon/metric/TickMetricSnapshotBufferSpec.scala @@ -65,7 +65,8 @@ class TickMetricSnapshotBufferSpec extends BaseKamonSpec("trace-metrics-spec") w MutableRecord(10, 3), MutableRecord(20, 1), MutableRecord(30, 1), - MutableRecord(300, 1)) + MutableRecord(300, 1) + ) } } @@ -83,12 +84,14 @@ class TickMetricSnapshotBufferSpec extends BaseKamonSpec("trace-metrics-spec") w traceRecorder.elapsedTime.record(20L) traceRecorder.elapsedTime.record(30L) val firstNonEmpty = TickMetricSnapshot(new MilliTimestamp(1000), new MilliTimestamp(2000), Map( - (testTraceIdentity -> traceRecorder.collect(collectionContext)))) + (testTraceIdentity → traceRecorder.collect(collectionContext)) + )) traceRecorder.elapsedTime.record(10L) traceRecorder.elapsedTime.record(10L) traceRecorder.elapsedTime.record(300L) val secondNonEmpty = TickMetricSnapshot(new MilliTimestamp(1000), new MilliTimestamp(2000), Map( - (testTraceIdentity -> traceRecorder.collect(collectionContext)))) + (testTraceIdentity → traceRecorder.collect(collectionContext)) + )) } } diff --git a/kamon-core/src/test/scala/kamon/metric/TraceMetricsSpec.scala b/kamon-core/src/test/scala/kamon/metric/TraceMetricsSpec.scala index 7678991e..4c44dc07 100644 --- a/kamon-core/src/test/scala/kamon/metric/TraceMetricsSpec.scala +++ b/kamon-core/src/test/scala/kamon/metric/TraceMetricsSpec.scala @@ -47,9 +47,10 @@ class TraceMetricsSpec extends BaseKamonSpec("trace-metrics-spec") with Implicit val snapshot = takeSnapshotOf("test-segment", "trace-segment", tags = Map( - "trace" -> "trace-with-segments", - "category" -> "test-category", - "library" -> "test-library")) + "trace" → "trace-with-segments", + "category" → "test-category", + "library" → "test-library" + )) snapshot.histogram("elapsed-time").get.numberOfMeasurements should be(1) } @@ -69,18 +70,20 @@ class TraceMetricsSpec extends BaseKamonSpec("trace-metrics-spec") with Implicit takeSnapshotOf("test-segment", "trace-segment", tags = Map( - "trace" -> "closing-segment-after-trace", - "category" -> "test-category", - "library" -> "test-library")) + "trace" → "closing-segment-after-trace", + "category" → "test-category", + "library" → "test-library" + )) } segment.finish() val afterFinishSegmentSnapshot = takeSnapshotOf("test-segment", "trace-segment", tags = Map( - "trace" -> "closing-segment-after-trace", - "category" -> "test-category", - "library" -> "test-library")) + "trace" → "closing-segment-after-trace", + "category" → "test-category", + "library" → "test-library" + )) afterFinishSegmentSnapshot.histogram("elapsed-time").get.numberOfMeasurements should be(1) } @@ -106,9 +109,10 @@ class TraceMetricsSpec extends BaseKamonSpec("trace-metrics-spec") with Implicit val snapshot = takeSnapshotOf("test-segment-with-error", "trace-segment", tags = Map( - "trace" -> "trace-with-segments", - "category" -> "test-category", - "library" -> "test-library")) + "trace" → "trace-with-segments", + "category" → "test-category", + "library" → "test-library" + )) snapshot.histogram("elapsed-time").get.numberOfMeasurements should be(1) snapshot.counter("errors").get.count should be(1) diff --git a/kamon-core/src/test/scala/kamon/metric/instrument/CounterSpec.scala b/kamon-core/src/test/scala/kamon/metric/instrument/CounterSpec.scala index 850200d4..d5d651e5 100644 --- a/kamon-core/src/test/scala/kamon/metric/instrument/CounterSpec.scala +++ b/kamon-core/src/test/scala/kamon/metric/instrument/CounterSpec.scala @@ -18,7 +18,7 @@ package kamon.metric.instrument import java.nio.LongBuffer -import org.scalatest.{ Matchers, WordSpec } +import org.scalatest.{Matchers, WordSpec} class CounterSpec extends WordSpec with Matchers { diff --git a/kamon-core/src/test/scala/kamon/metric/instrument/HistogramSpec.scala b/kamon-core/src/test/scala/kamon/metric/instrument/HistogramSpec.scala index dd60fee1..9551c6ea 100644 --- a/kamon-core/src/test/scala/kamon/metric/instrument/HistogramSpec.scala +++ b/kamon-core/src/test/scala/kamon/metric/instrument/HistogramSpec.scala @@ -19,7 +19,7 @@ package kamon.metric.instrument import java.nio.LongBuffer import kamon.metric.instrument.Histogram.DynamicRange -import org.scalatest.{ Matchers, WordSpec } +import org.scalatest.{Matchers, WordSpec} import scala.util.Random @@ -62,12 +62,12 @@ class HistogramSpec extends WordSpec with Matchers { snapshot.sum should be(41300) snapshot.numberOfMeasurements should be(203) - val records = snapshot.recordsIterator.map(r ⇒ r.level -> r.count).toSeq + val records = snapshot.recordsIterator.map(r ⇒ r.level → r.count).toSeq records.size should be(4) - records(0) should be(100 -> 1) - records(1) should be(200 -> 200) - records(2) should be(300 -> 1) - records(3) should be(900 -> 1) + records(0) should be(100 → 1) + records(1) should be(200 → 200) + records(2) should be(300 → 1) + records(3) should be(900 → 1) } "can be scaled" in new HistogramFixture { @@ -86,12 +86,12 @@ class HistogramSpec extends WordSpec with Matchers { snapshot.sum should be(41300000) snapshot.numberOfMeasurements should be(203) - val records = snapshot.recordsIterator.map(r ⇒ r.level -> r.count).toSeq + val records = snapshot.recordsIterator.map(r ⇒ r.level → r.count).toSeq records.size should be(4) - records(0) should be(100000 -> 1) - records(1) should be(200000 -> 200) - records(2) should be(300000 -> 1) - records(3) should be(900000 -> 1) + records(0) should be(100000 → 1) + records(1) should be(200000 → 200) + records(2) should be(300000 → 1) + records(3) should be(900000 → 1) } "can be merged with another snapshot" in new MultipleHistogramFixture { diff --git a/kamon-core/src/test/scala/kamon/metric/instrument/MinMaxCounterSpec.scala b/kamon-core/src/test/scala/kamon/metric/instrument/MinMaxCounterSpec.scala index 7acfc229..d007d4cd 100644 --- a/kamon-core/src/test/scala/kamon/metric/instrument/MinMaxCounterSpec.scala +++ b/kamon-core/src/test/scala/kamon/metric/instrument/MinMaxCounterSpec.scala @@ -20,7 +20,7 @@ import java.nio.LongBuffer import akka.actor._ import akka.testkit.TestProbe import kamon.Kamon -import kamon.metric.instrument.Histogram.{ DynamicRange, MutableRecord } +import kamon.metric.instrument.Histogram.{DynamicRange, MutableRecord} import kamon.testkit.BaseKamonSpec import scala.concurrent.duration._ @@ -38,7 +38,8 @@ class MinMaxCounterSpec extends BaseKamonSpec("min-max-counter-spec") { snapshot.max should be(5) snapshot.recordsIterator.toStream should contain allOf ( MutableRecord(0, 1), // min - MutableRecord(5, 2)) // max and current + MutableRecord(5, 2) + ) // max and current } "track descending tendencies" in new MinMaxCounterFixture { @@ -53,7 +54,8 @@ class MinMaxCounterSpec extends BaseKamonSpec("min-max-counter-spec") { snapshot.max should be(5) snapshot.recordsIterator.toStream should contain allOf ( MutableRecord(0, 2), // min and current - MutableRecord(5, 1)) // max + MutableRecord(5, 1) + ) // max } "reset the min and max to the current value after taking a snapshot" in new MinMaxCounterFixture { @@ -67,14 +69,16 @@ class MinMaxCounterSpec extends BaseKamonSpec("min-max-counter-spec") { firstSnapshot.recordsIterator.toStream should contain allOf ( MutableRecord(0, 1), // min MutableRecord(2, 1), // current - MutableRecord(5, 1)) // max + MutableRecord(5, 1) + ) // max val secondSnapshot = collectCounterSnapshot() secondSnapshot.min should be(2) secondSnapshot.max should be(2) secondSnapshot.recordsIterator.toStream should contain( - MutableRecord(2, 3)) // min, max and current + MutableRecord(2, 3) + ) // min, max and current } "report zero as the min and current values if the current value fell bellow zero" in new MinMaxCounterFixture { @@ -85,7 +89,8 @@ class MinMaxCounterSpec extends BaseKamonSpec("min-max-counter-spec") { snapshot.min should be(0) snapshot.max should be(0) snapshot.recordsIterator.toStream should contain( - MutableRecord(0, 3)) // min, max and current (even while current really is -3 + MutableRecord(0, 3) + ) // min, max and current (even while current really is -3 } "never record values bellow zero in very busy situations" in new MinMaxCounterFixture { diff --git a/kamon-core/src/test/scala/kamon/metric/instrument/UnitOfMeasurementSpec.scala b/kamon-core/src/test/scala/kamon/metric/instrument/UnitOfMeasurementSpec.scala index 10604fe5..7133579e 100644 --- a/kamon-core/src/test/scala/kamon/metric/instrument/UnitOfMeasurementSpec.scala +++ b/kamon-core/src/test/scala/kamon/metric/instrument/UnitOfMeasurementSpec.scala @@ -17,7 +17,7 @@ package kamon.metric.instrument import kamon.metric.instrument.UnitOfMeasurement.Unknown -import org.scalatest.{ Matchers, WordSpec } +import org.scalatest.{Matchers, WordSpec} class UnitOfMeasurementSpec extends WordSpec with Matchers { diff --git a/kamon-core/src/test/scala/kamon/testkit/BaseKamonSpec.scala b/kamon-core/src/test/scala/kamon/testkit/BaseKamonSpec.scala index 78c8607b..d2e569ad 100644 --- a/kamon-core/src/test/scala/kamon/testkit/BaseKamonSpec.scala +++ b/kamon-core/src/test/scala/kamon/testkit/BaseKamonSpec.scala @@ -17,13 +17,13 @@ package kamon.testkit import akka.actor.ActorSystem -import akka.testkit.{ ImplicitSender, TestKitBase } +import akka.testkit.{ImplicitSender, TestKitBase} import com.typesafe.config.Config import kamon.Kamon -import kamon.metric.{ Entity, EntitySnapshot, SubscriptionsDispatcher } +import kamon.metric.{Entity, EntitySnapshot, SubscriptionsDispatcher} import kamon.trace.TraceContext import kamon.util.LazyActorRef -import org.scalatest.{ BeforeAndAfterAll, Matchers, WordSpecLike } +import org.scalatest.{BeforeAndAfterAll, Matchers, WordSpecLike} abstract class BaseKamonSpec(actorSystemName: String) extends TestKitBase with WordSpecLike with Matchers with ImplicitSender with BeforeAndAfterAll { lazy val collectionContext = Kamon.metrics.buildDefaultCollectionContext diff --git a/kamon-core/src/test/scala/kamon/trace/SimpleTraceSpec.scala b/kamon-core/src/test/scala/kamon/trace/SimpleTraceSpec.scala index f408ad93..faf127c1 100644 --- a/kamon-core/src/test/scala/kamon/trace/SimpleTraceSpec.scala +++ b/kamon-core/src/test/scala/kamon/trace/SimpleTraceSpec.scala @@ -88,9 +88,9 @@ class SimpleTraceSpec extends BaseKamonSpec("simple-trace-spec") { "send a TraceInfo when the trace has finished and all segments are finished and both contains tags" in { Kamon.tracer.subscribe(testActor) - Tracer.withContext(newContext("simple-trace-without-segments", "awesome-token", Map("environment" -> "production"))) { - Tracer.currentContext.startSegment("segment-one", "test-segment", "test", Map("segment-one-info" -> "info")).finish() - Tracer.currentContext.startSegment("segment-two", "test-segment", "test", Map("segment-two-info" -> "info")).finish() + Tracer.withContext(newContext("simple-trace-without-segments", "awesome-token", Map("environment" → "production"))) { + Tracer.currentContext.startSegment("segment-one", "test-segment", "test", Map("segment-one-info" → "info")).finish() + Tracer.currentContext.startSegment("segment-two", "test-segment", "test", Map("segment-two-info" → "info")).finish() Tracer.currentContext.finish() } @@ -98,14 +98,14 @@ class SimpleTraceSpec extends BaseKamonSpec("simple-trace-spec") { Kamon.tracer.unsubscribe(testActor) traceInfo.name should be("simple-trace-without-segments") - traceInfo.tags should be(Map("environment" -> "production")) + traceInfo.tags should be(Map("environment" → "production")) traceInfo.segments.size should be(2) val segmentOne = traceInfo.segments.find(_.name == "segment-one") val segmentTwo = traceInfo.segments.find(_.name == "segment-two") - segmentOne.get.tags should be(Map("segment-one-info" -> "info")) - segmentTwo.get.tags should be(Map("segment-two-info" -> "info")) + segmentOne.get.tags should be(Map("segment-one-info" → "info")) + segmentTwo.get.tags should be(Map("segment-two-info" → "info")) } "incubate the tracing context if there are open segments after finishing" in { diff --git a/kamon-core/src/test/scala/kamon/trace/TraceContextManipulationSpec.scala b/kamon-core/src/test/scala/kamon/trace/TraceContextManipulationSpec.scala index 58b51a73..d817186a 100644 --- a/kamon-core/src/test/scala/kamon/trace/TraceContextManipulationSpec.scala +++ b/kamon-core/src/test/scala/kamon/trace/TraceContextManipulationSpec.scala @@ -70,7 +70,7 @@ class TraceContextManipulationSpec extends BaseKamonSpec("trace-metrics-spec") { } Tracer.currentContext shouldBe empty - createdContext.tags shouldBe Map("trace-tag" -> "tag-1") + createdContext.tags shouldBe Map("trace-tag" → "tag-1") createdContext.removeTag("trace-tag", "tag-1") @@ -103,7 +103,7 @@ class TraceContextManipulationSpec extends BaseKamonSpec("trace-metrics-spec") { segment.tags should be(Map.empty) segment.addTag("segment-tag", "tag-1") - segment.tags should be(Map("segment-tag" -> "tag-1")) + segment.tags should be(Map("segment-tag" → "tag-1")) segment.removeTag("segment-tag", "tag-1") segment.tags should be(Map.empty) diff --git a/kamon-core/src/test/scala/kamon/trace/logging/MdcKeysSupportSpec.scala b/kamon-core/src/test/scala/kamon/trace/logging/MdcKeysSupportSpec.scala index 6193f028..39374e79 100644 --- a/kamon-core/src/test/scala/kamon/trace/logging/MdcKeysSupportSpec.scala +++ b/kamon-core/src/test/scala/kamon/trace/logging/MdcKeysSupportSpec.scala @@ -1,7 +1,7 @@ package kamon.trace.logging import kamon.testkit.BaseKamonSpec -import kamon.trace.{ EmptyTraceContext, Tracer } +import kamon.trace.{EmptyTraceContext, Tracer} import org.slf4j.MDC class MdcKeysSupportSpec extends BaseKamonSpec("mdc-keys-support-spec") { diff --git a/kamon-core/src/test/scala/kamon/util/GlobPathFilterSpec.scala b/kamon-core/src/test/scala/kamon/util/GlobPathFilterSpec.scala index ab98d0ac..7d585087 100644 --- a/kamon-core/src/test/scala/kamon/util/GlobPathFilterSpec.scala +++ b/kamon-core/src/test/scala/kamon/util/GlobPathFilterSpec.scala @@ -16,7 +16,7 @@ package kamon.util -import org.scalatest.{ Matchers, WordSpecLike } +import org.scalatest.{Matchers, WordSpecLike} class GlobPathFilterSpec extends WordSpecLike with Matchers { "The GlobPathFilter" should { diff --git a/kamon-core/src/test/scala/kamon/util/NeedToScaleSpec.scala b/kamon-core/src/test/scala/kamon/util/NeedToScaleSpec.scala index a53451b6..cba6ad98 100644 --- a/kamon-core/src/test/scala/kamon/util/NeedToScaleSpec.scala +++ b/kamon-core/src/test/scala/kamon/util/NeedToScaleSpec.scala @@ -17,8 +17,8 @@ package kamon.util import com.typesafe.config.ConfigFactory -import kamon.metric.instrument.{ Memory, Time } -import org.scalatest.{ Matchers, WordSpec } +import kamon.metric.instrument.{Memory, Time} +import org.scalatest.{Matchers, WordSpec} class NeedToScaleSpec extends WordSpec with Matchers { @@ -27,7 +27,8 @@ class NeedToScaleSpec extends WordSpec with Matchers { val config = ConfigFactory.parseString( """ |time-units = "ms" - """.stripMargin) + """.stripMargin + ) config match { case NeedToScale(timeUnits, memoryUnits) ⇒ @@ -39,7 +40,8 @@ class NeedToScaleSpec extends WordSpec with Matchers { val config = ConfigFactory.parseString( """ |memory-units = "kb" - """.stripMargin) + """.stripMargin + ) config match { case NeedToScale(timeUnits, memoryUnits) ⇒ @@ -51,7 +53,8 @@ class NeedToScaleSpec extends WordSpec with Matchers { val config = ConfigFactory.parseString( """ |some-other-key = "value" - """.stripMargin) + """.stripMargin + ) config match { case NeedToScale(timeUnits, memoryUnits) ⇒ diff --git a/kamon-core/src/test/scala/kamon/util/RegexPathFilterSpec.scala b/kamon-core/src/test/scala/kamon/util/RegexPathFilterSpec.scala index edbf14b3..a2cc8629 100644 --- a/kamon-core/src/test/scala/kamon/util/RegexPathFilterSpec.scala +++ b/kamon-core/src/test/scala/kamon/util/RegexPathFilterSpec.scala @@ -16,7 +16,7 @@ package kamon.util -import org.scalatest.{ Matchers, WordSpecLike } +import org.scalatest.{Matchers, WordSpecLike} class RegexPathFilterSpec extends WordSpecLike with Matchers { "The RegexPathFilter" should { diff --git a/kamon-core/src/test/scala/kamon/util/executors/ExecutorServiceMetricsSpec.scala b/kamon-core/src/test/scala/kamon/util/executors/ExecutorServiceMetricsSpec.scala index a0275b33..4e5394f8 100644 --- a/kamon-core/src/test/scala/kamon/util/executors/ExecutorServiceMetricsSpec.scala +++ b/kamon-core/src/test/scala/kamon/util/executors/ExecutorServiceMetricsSpec.scala @@ -19,7 +19,7 @@ package kamon.util.executors import java.util.concurrent.Executors import kamon.Kamon -import kamon.metric.{ Entity, EntityRecorder } +import kamon.metric.{Entity, EntityRecorder} import kamon.testkit.BaseKamonSpec class ExecutorServiceMetricsSpec extends BaseKamonSpec("executor-service-metrics-spec") { diff --git a/kamon-testkit/src/main/scala/testkit/AkkaExtensionSwap.scala b/kamon-testkit/src/main/scala/testkit/AkkaExtensionSwap.scala index 2f77df95..143c3374 100644 --- a/kamon-testkit/src/main/scala/testkit/AkkaExtensionSwap.scala +++ b/kamon-testkit/src/main/scala/testkit/AkkaExtensionSwap.scala @@ -18,7 +18,7 @@ package testkit import java.util.concurrent.ConcurrentHashMap -import akka.actor.{ ActorSystem, Extension, ExtensionId } +import akka.actor.{ActorSystem, Extension, ExtensionId} object AkkaExtensionSwap { def swap(system: ActorSystem, key: ExtensionId[_], value: Extension): Unit = { diff --git a/kamon-testkit/src/main/scala/testkit/TestProbeInstrumentation.scala b/kamon-testkit/src/main/scala/testkit/TestProbeInstrumentation.scala index 2850482b..da983405 100644 --- a/kamon-testkit/src/main/scala/testkit/TestProbeInstrumentation.scala +++ b/kamon-testkit/src/main/scala/testkit/TestProbeInstrumentation.scala @@ -17,7 +17,7 @@ package akka.testkit import org.aspectj.lang.annotation._ -import kamon.trace.{ Tracer, EmptyTraceContext, TraceContextAware } +import kamon.trace.{Tracer, EmptyTraceContext, TraceContextAware} import org.aspectj.lang.ProceedingJoinPoint import akka.testkit.TestActor.RealMessage diff --git a/project/Dependencies.scala b/project/Dependencies.scala new file mode 100644 index 00000000..bcc926f5 --- /dev/null +++ b/project/Dependencies.scala @@ -0,0 +1,46 @@ +/* ========================================================================================= + * Copyright © 2013-2016 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. + * ========================================================================================= + */ + +import sbt._ + +object Dependencies { + + val resolutionRepos = Seq( + "typesafe repo" at "http://repo.typesafe.com/typesafe/releases/", + "Kamon Repository Snapshots" at "http://snapshots.kamon.io" + ) + + val akkaVersion = "2.4.12" + val slf4jVersion = "1.7.7" + + val akkaSlf4j = "com.typesafe.akka" %% "akka-slf4j" % akkaVersion + val akkaTestKit = "com.typesafe.akka" %% "akka-testkit" % akkaVersion + val akkaActor = "com.typesafe.akka" %% "akka-actor" % akkaVersion + + val aspectJ = "org.aspectj" % "aspectjweaver" % "1.8.9" + val hdrHistogram = "org.hdrhistogram" % "HdrHistogram" % "2.1.9" + + val slf4jApi = "org.slf4j" % "slf4j-api" % slf4jVersion + val slf4jnop = "org.slf4j" % "slf4j-nop" % slf4jVersion + + val logback = "ch.qos.logback" % "logback-classic" % "1.0.13" + + val scalatest = "org.scalatest" %% "scalatest" % "3.0.1" + + def compileScope (deps: ModuleID*): Seq[ModuleID] = deps map (_ % "compile") + def testScope (deps: ModuleID*): Seq[ModuleID] = deps map (_ % "test") + def providedScope (deps: ModuleID*): Seq[ModuleID] = deps map (_ % "provided") + def optionalScope (deps: ModuleID*): Seq[ModuleID] = deps map (_ % "compile,optional") +} diff --git a/project/Publish.scala b/project/Publish.scala new file mode 100644 index 00000000..ddb64d2d --- /dev/null +++ b/project/Publish.scala @@ -0,0 +1,50 @@ +/* ========================================================================================= + * Copyright © 2013-2014 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. + * ========================================================================================= + */ + +import sbt._ +import sbt.Keys._ + +object Publish { + + lazy val settings = Seq( + crossPaths := true, + pomExtra := kamonPomExtra, + publishTo := kamonRepo, + organization := "io.kamon", + pomIncludeRepository := { x => false }, + publishMavenStyle := true, + publishArtifact in Test := false + ) + + def kamonRepo = Some(Resolver.sftp("Kamon Snapshots Repository", "snapshots.kamon.io", "/var/local/snapshots-repo")) + + def kamonPomExtra = { + <url>http://kamon.io</url> + <licenses> + <license> + <name>Apache 2</name> + <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> + </license> + </licenses> + <scm> + <url>git://github.com/kamon-io/Kamon.git</url> + <connection>scm:git:git@github.com:kamon-io/Kamon.git</connection> + </scm> + <developers> + <developer><id>ivantopo</id><name>Ivan Topolnjak</name><url>https://twitter.com/ivantopo</url></developer> + <developer><id>dpsoft</id><name>Diego Parra</name><url>https://twitter.com/diegolparra</url></developer> + </developers> + } +} diff --git a/project/Release.scala b/project/Release.scala new file mode 100644 index 00000000..a388a66f --- /dev/null +++ b/project/Release.scala @@ -0,0 +1,80 @@ +/* ========================================================================================= + * Copyright © 2013-2014 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. + * ========================================================================================= + */ + +import com.typesafe.sbt.pgp._ +import sbt._ +import sbt.Keys._ +import sbtrelease.ReleasePlugin._ +import sbtrelease.ReleaseStateTransformations._ +import sbtrelease.ReleaseStep +import sbtrelease.Utilities._ +import xerial.sbt.Sonatype._ + +object Release { + + def settings = Seq.empty ++ + releaseSettings ++ + Seq( + ReleaseKeys.releaseProcess := Seq[ReleaseStep]( + checkSnapshotDependencies, + inquireVersions, + runClean, + runTest, + setReleaseVersion, + commitReleaseVersion, // .copy(check = identity), // FIX 0: to skip "all changes committed" precondition + tagRelease, + publishSignedArtifacts, // FIX 1: publish signed. Otherwise sonatype won't sync artifact to maven central + setNextVersion, + commitNextVersion, + pushChanges, + refreshVersionWithSHA // FIX 2: update "version" by replacing the "-SNAPSHOT" with "-WHATEVER_COMMIT_SHA" + ) + ) ++ + sonatypeSettings ++ + Seq( + // sbt-sonatype overrides publishTo. So we need to restore kamon repo declaration for snapshots + publishTo := { if (isSnapshot.value) Publish.kamonRepo else publishTo.value } + ) + + + def kamonSonatypeCredentials = + Credentials.toDirect(Credentials(Path.userHome / ".ivy2" / "kamon-credentials-sonatype.properties")) + + /** + * Hijacked from [[sbtrelease.ReleaseStateTransformations.publishArtifacts]] + */ + lazy val publishSignedArtifacts = ReleaseStep( + action = { st: State => + val extracted = st.extract + val ref = extracted.get(thisProjectRef) + extracted.runAggregated(PgpKeys.publishSigned in Global in ref, st) + }, + check = st => { + // getPublishTo fails if no publish repository is set up. + val ex = st.extract + val ref = ex.get(thisProjectRef) + Classpaths.getPublishTo(ex.get(publishTo in Global in ref)) + st + }, + enableCrossBuild = true + ) + + lazy val refreshVersionWithSHA = ReleaseStep(st => { + reapply(Seq( + version in ThisBuild := VersionWithSHA.kamonVersionWithSHA(st.extract.get(version)) + ), st) + }) + +}
\ No newline at end of file diff --git a/project/Settings.scala b/project/Settings.scala new file mode 100644 index 00000000..d33b8a99 --- /dev/null +++ b/project/Settings.scala @@ -0,0 +1,70 @@ +/* ========================================================================================= + * Copyright © 2013-2016 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. + * ========================================================================================= + */ + +import sbt._ +import Keys._ +import com.typesafe.sbt.SbtScalariform +import com.typesafe.sbt.SbtScalariform.ScalariformKeys +import Publish.{settings => publishSettings} +import Release.{settings => releaseSettings} +import scalariform.formatter.preferences._ + +object Settings { + + val JavaVersion = "1.6" + val SVersion = "2.11.8" + + lazy val basicSettings = Seq( + scalaVersion := SVersion, + crossScalaVersions := Seq("2.10.5", SVersion, "2.12.0"), + resolvers ++= Dependencies.resolutionRepos, + fork in run := true, + parallelExecution in Global := false, + scalacOptions := commonScalacOptions, + javacOptions := commonJavaOptions + ) ++ publishSettings ++ releaseSettings + + lazy val commonJavaOptions = Seq( + "-Xlint:-options", + "-source", JavaVersion, "-target", JavaVersion) + + lazy val commonScalacOptions = Seq( + "-encoding", + "utf8", + "-g:vars", + "-feature", + "-unchecked", + "-deprecation", + "-language:postfixOps", + "-language:implicitConversions", + "-Xlog-reflective-calls" +// "-Yno-adapted-args", +// "-Ywarn-dead-code", +// "-Ywarn-numeric-widen", +// "-Ywarn-value-discard", + ) + + lazy val formatSettings = SbtScalariform.scalariformSettings ++ Seq( + ScalariformKeys.preferences in Compile := formattingPreferences, + ScalariformKeys.preferences in Test := formattingPreferences + ) + + def formattingPreferences = + FormattingPreferences() + .setPreference(RewriteArrowSymbols, true) + .setPreference(AlignParameters, false) + .setPreference(AlignSingleLineCaseStatements, true) + .setPreference(DoubleIndentClassDeclaration, true) +} diff --git a/project/VersionWithSHA.scala b/project/VersionWithSHA.scala new file mode 100644 index 00000000..58139f7f --- /dev/null +++ b/project/VersionWithSHA.scala @@ -0,0 +1,28 @@ +/* ========================================================================================= + * Copyright © 2013-2016 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. + * ========================================================================================= + */ + +import sbt.Process + +object VersionWithSHA { + + private lazy val VersionWithShaRegex = """(?:\d+\.)?(?:\d+\.)?(?:\d+)-[0-9a-f]{5,40}""" + + /** Don't use this. You should use version.value instead. */ + def kamonVersionWithSHA(version: String) = version.takeWhile(_ != '-') + "-" + Process("git rev-parse HEAD").lines.head + + /** Don't use this. You should use isSnapshot.value instead. */ + def kamonIsSnapshot(version: String) = (version matches VersionWithShaRegex) || (version endsWith "-SNAPSHOT") + +}
\ No newline at end of file diff --git a/project/build.properties b/project/build.properties new file mode 100644 index 00000000..5f32afe7 --- /dev/null +++ b/project/build.properties @@ -0,0 +1 @@ +sbt.version=0.13.13
\ No newline at end of file diff --git a/project/plugins.sbt b/project/plugins.sbt new file mode 100644 index 00000000..ee51c0a9 --- /dev/null +++ b/project/plugins.sbt @@ -0,0 +1,16 @@ +resolvers += "Sonatype snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/" + +resolvers += "Kamon Releases" at "http://repo.kamon.io" + +addSbtPlugin("com.typesafe.sbt" % "sbt-aspectj" % "0.10.6") + +addSbtPlugin("com.github.gseitz" % "sbt-release" % "0.8.2") + +addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.6.0") + +addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "0.2.1") + +addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % "0.8.1") + +addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.8.1") + diff --git a/travis-test.sh b/travis-test.sh new file mode 100755 index 00000000..5ccd9fe0 --- /dev/null +++ b/travis-test.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +# Licensed under the Apache License, Version 2.0 +# Adapted from https://github.com/paulp/psp-std/blob/master/bin/test + +runTests () { + sbt -Dakka.test.timefactor=1.5 \ + 'set concurrentRestrictions in Global += Tags.limit(Tags.Compile, 2)' \ + 'set testOptions in test in Global := Seq(Tests.Argument(TestFrameworks.ScalaTest, "-oUNCXHELPOQRM"))' \ + test || exit 1 + + echo "[info] $(date) - finished sbt test" +} + +stripTerminalEscapeCodes () { + sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGKM]//g" +} + +mkRegex () { ( IFS="|" && echo "$*" ); } + +filterOutput() { + while read line; do + if ! [[ $(echo $line | stripTerminalEscapeCodes) =~ $excludeRegex ]] ; then + echo $line + fi + done +} + +main() { + # sbt output filter + local excludeRegex=$(mkRegex \ + '\[info\] (Resolving|Loading|Updating|Packaging|Done updating|downloading| \[SUCCESSFUL \])' \ + 're[-]run with [-]unchecked for details' \ + 'one warning found' + ) + + echo "[info] $(date) - starting sbt test" + (set -o pipefail && runTests |& filterOutput) +} + +main $@
\ No newline at end of file diff --git a/version.sbt b/version.sbt new file mode 100644 index 00000000..25ac1ae3 --- /dev/null +++ b/version.sbt @@ -0,0 +1 @@ +version in ThisBuild := "0.6.4-SNAPSHOT" |