aboutsummaryrefslogtreecommitdiff
path: root/kamon-core/src/main/scala/kamon/metrics/instruments
diff options
context:
space:
mode:
Diffstat (limited to 'kamon-core/src/main/scala/kamon/metrics/instruments')
-rw-r--r--kamon-core/src/main/scala/kamon/metrics/instruments/ContinuousHdrRecorder.scala52
-rw-r--r--kamon-core/src/main/scala/kamon/metrics/instruments/CounterRecorder.scala38
-rw-r--r--kamon-core/src/main/scala/kamon/metrics/instruments/HdrRecorder.scala78
-rw-r--r--kamon-core/src/main/scala/kamon/metrics/instruments/MinMaxCounter.scala58
4 files changed, 0 insertions, 226 deletions
diff --git a/kamon-core/src/main/scala/kamon/metrics/instruments/ContinuousHdrRecorder.scala b/kamon-core/src/main/scala/kamon/metrics/instruments/ContinuousHdrRecorder.scala
deleted file mode 100644
index 3a39ec69..00000000
--- a/kamon-core/src/main/scala/kamon/metrics/instruments/ContinuousHdrRecorder.scala
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * =========================================================================================
- * 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.
- * =========================================================================================
- */
-
-package kamon.metrics.instruments
-
-import org.HdrHistogram.HdrRecorder
-import kamon.metrics.{ Scale, MetricSnapshotLike }
-
-/**
- * This recorder keeps track of the last value recoded and automatically adds it after collecting a snapshot. This is
- * useful in cases where the absence of recordings does not necessarily mean the absence of values. For example, if this
- * recorder is used for recording the mailbox size of an actor, and it only gets updated upon message enqueue o dequeue,
- * the absence of recordings during 1 second means that the size hasn't change (example: the actor being blocked doing
- * some work) and it should keep its last known value, instead of dropping to zero and then going back to the real value
- * after a new event is processed.
- *
- */
-class ContinuousHdrRecorder(highestTrackableValue: Long, significantValueDigits: Int, scale: Scale)
- extends HdrRecorder(highestTrackableValue, significantValueDigits, scale) {
-
- @volatile private var lastRecordedValue: Long = 0
-
- override def record(value: Long): Unit = {
- lastRecordedValue = value
- super.record(value)
- }
-
- override def collect(): MetricSnapshotLike = {
- val snapshot = super.collect()
- super.record(lastRecordedValue)
-
- snapshot
- }
-}
-
-object ContinuousHdrRecorder {
- def apply(highestTrackableValue: Long, significantValueDigits: Int, scale: Scale) =
- new ContinuousHdrRecorder(highestTrackableValue, significantValueDigits, scale)
-} \ No newline at end of file
diff --git a/kamon-core/src/main/scala/kamon/metrics/instruments/CounterRecorder.scala b/kamon-core/src/main/scala/kamon/metrics/instruments/CounterRecorder.scala
deleted file mode 100644
index e5efbc15..00000000
--- a/kamon-core/src/main/scala/kamon/metrics/instruments/CounterRecorder.scala
+++ /dev/null
@@ -1,38 +0,0 @@
-package kamon.metrics.instruments
-/*
- * =========================================================================================
- * 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 kamon.metrics._
-import kamon.metrics.MetricSnapshot.Measurement
-
-import jsr166e.LongAdder
-
-class CounterRecorder extends MetricRecorder {
- private val counter = new LongAdder
-
- def record(value: Long): Unit = {
- counter.add(value)
- }
-
- def collect(): MetricSnapshotLike = {
- val sum = counter.sumThenReset()
- MetricSnapshot(InstrumentTypes.Counter, sum, Scale.Unit, Vector(Measurement(1, sum)))
- }
-}
-
-object CounterRecorder {
- def apply(): CounterRecorder = new CounterRecorder()
-} \ No newline at end of file
diff --git a/kamon-core/src/main/scala/kamon/metrics/instruments/HdrRecorder.scala b/kamon-core/src/main/scala/kamon/metrics/instruments/HdrRecorder.scala
deleted file mode 100644
index ce4fd76d..00000000
--- a/kamon-core/src/main/scala/kamon/metrics/instruments/HdrRecorder.scala
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * =========================================================================================
- * 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.
- * =========================================================================================
- */
-
-package org.HdrHistogram
-
-import java.util.concurrent.atomic.AtomicLongFieldUpdater
-import scala.annotation.tailrec
-import kamon.metrics._
-
-/**
- * This implementation aims to be used for real time data collection where data snapshots are taken often over time.
- * The snapshotAndReset() 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 HdrRecorder(highestTrackableValue: Long, significantValueDigits: Int, scale: Scale)
- extends AtomicHistogram(1L, highestTrackableValue, significantValueDigits) with MetricRecorder {
-
- import HdrRecorder.totalCountUpdater
-
- def record(value: Long): Unit = recordValue(value)
-
- def collect(): MetricSnapshotLike = {
- val entries = Vector.newBuilder[MetricSnapshot.Measurement]
- val countsLength = counts.length()
-
- @tailrec def iterate(index: Int, previousValue: Long, nrOfRecordings: Long, bucketLimit: Long, increment: Long): Long = {
- if (index < countsLength) {
- val currentValue = previousValue + increment
- val countAtValue = counts.getAndSet(index, 0)
-
- if (countAtValue > 0)
- entries += MetricSnapshot.Measurement(currentValue, countAtValue)
-
- if (currentValue == bucketLimit)
- iterate(index + 1, currentValue, nrOfRecordings + countAtValue, (bucketLimit << 1) + 1, increment << 1)
- else
- iterate(index + 1, currentValue, nrOfRecordings + countAtValue, bucketLimit, increment)
- } else {
- nrOfRecordings
- }
- }
-
- val nrOfRecordings = iterate(0, -1, 0, subBucketMask, 1)
-
- def tryUpdateTotalCount: Boolean = {
- val previousTotalCount = getTotalCount
- val newTotalCount = previousTotalCount - nrOfRecordings
-
- totalCountUpdater.compareAndSet(this, previousTotalCount, newTotalCount)
- }
-
- while (!tryUpdateTotalCount) {}
-
- MetricSnapshot(InstrumentTypes.Histogram, nrOfRecordings, scale, entries.result())
- }
-
-}
-
-object HdrRecorder {
- val totalCountUpdater = AtomicLongFieldUpdater.newUpdater(classOf[AtomicHistogram], "totalCount")
-
- def apply(highestTrackableValue: Long, significantValueDigits: Int, scale: Scale): HdrRecorder =
- new HdrRecorder(highestTrackableValue, significantValueDigits, scale)
-
-}
diff --git a/kamon-core/src/main/scala/kamon/metrics/instruments/MinMaxCounter.scala b/kamon-core/src/main/scala/kamon/metrics/instruments/MinMaxCounter.scala
deleted file mode 100644
index ba2550af..00000000
--- a/kamon-core/src/main/scala/kamon/metrics/instruments/MinMaxCounter.scala
+++ /dev/null
@@ -1,58 +0,0 @@
-package kamon.metrics.instruments
-
-/*
- * =========================================================================================
- * 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 java.lang.Math._
-import jsr166e.LongMaxUpdater
-import kamon.util.PaddedAtomicLong
-import kamon.metrics.instruments.MinMaxCounter.CounterMeasurement
-
-class MinMaxCounter {
- private val min = new LongMaxUpdater
- private val max = new LongMaxUpdater
- private val sum = new PaddedAtomicLong
-
- min.update(0L)
- max.update(0L)
-
- def increment(value: Long = 1L): Unit = {
- val currentValue = sum.addAndGet(value)
- max.update(currentValue)
- }
-
- def decrement(value: Long = 1L): Unit = {
- val currentValue = sum.addAndGet(-value)
- min.update(-currentValue)
- }
-
- def collect(): CounterMeasurement = {
- val currentValue = {
- val value = sum.get()
- if (value < 0) 0 else value
- }
- val result = CounterMeasurement(abs(min.maxThenReset()), max.maxThenReset(), currentValue)
- max.update(currentValue)
- min.update(-currentValue)
- result
- }
-}
-
-object MinMaxCounter {
- def apply() = new MinMaxCounter()
-
- case class CounterMeasurement(min: Long, max: Long, current: Long)
-}