diff options
4 files changed, 30 insertions, 8 deletions
diff --git a/kamon-system-metrics/src/main/resources/reference.conf b/kamon-system-metrics/src/main/resources/reference.conf index 4d564e38..3de463b3 100644 --- a/kamon-system-metrics/src/main/resources/reference.conf +++ b/kamon-system-metrics/src/main/resources/reference.conf @@ -49,6 +49,8 @@ kamon { tx-bytes = ${kamon.metrics.precision.default-histogram-precision} rx-errors = ${kamon.metrics.precision.default-histogram-precision} tx-errors = ${kamon.metrics.precision.default-histogram-precision} + rx-dropped = ${kamon.metrics.precision.default-histogram-precision} + tx-dropped = ${kamon.metrics.precision.default-histogram-precision} } memory { diff --git a/kamon-system-metrics/src/main/scala/kamon/metrics/NetworkMetrics.scala b/kamon-system-metrics/src/main/scala/kamon/metrics/NetworkMetrics.scala index f348bb0c..d8a38f6d 100644 --- a/kamon-system-metrics/src/main/scala/kamon/metrics/NetworkMetrics.scala +++ b/kamon-system-metrics/src/main/scala/kamon/metrics/NetworkMetrics.scala @@ -31,31 +31,35 @@ object NetworkMetrics extends MetricGroupCategory { case object TxBytes extends MetricIdentity { val name = "tx-bytes" } case object RxErrors extends MetricIdentity { val name = "rx-errors" } case object TxErrors extends MetricIdentity { val name = "tx-errors" } + case object RxDropped extends MetricIdentity { val name = "rx-dropped" } + case object TxDropped extends MetricIdentity { val name = "tx-dropped" } - case class NetworkMetricRecorder(rxBytes: Histogram, txBytes: Histogram, rxErrors: Histogram, txErrors: Histogram) + case class NetworkMetricRecorder(rxBytes: Histogram, txBytes: Histogram, rxErrors: Histogram, txErrors: Histogram, rxDropped: Histogram, txDropped: Histogram) extends MetricGroupRecorder { def collect(context: CollectionContext): MetricGroupSnapshot = { - NetworkMetricSnapshot(rxBytes.collect(context), txBytes.collect(context), rxErrors.collect(context), txErrors.collect(context)) + NetworkMetricSnapshot(rxBytes.collect(context), txBytes.collect(context), rxErrors.collect(context), txErrors.collect(context), rxDropped.collect(context), txDropped.collect(context)) } def cleanup: Unit = {} } - case class NetworkMetricSnapshot(rxBytes: Histogram.Snapshot, txBytes: Histogram.Snapshot, rxErrors: Histogram.Snapshot, txErrors: Histogram.Snapshot) + case class NetworkMetricSnapshot(rxBytes: Histogram.Snapshot, txBytes: Histogram.Snapshot, rxErrors: Histogram.Snapshot, txErrors: Histogram.Snapshot, rxDropped: Histogram.Snapshot, txDropped: Histogram.Snapshot) extends MetricGroupSnapshot { type GroupSnapshotType = NetworkMetricSnapshot def merge(that: GroupSnapshotType, context: CollectionContext): GroupSnapshotType = { - NetworkMetricSnapshot(rxBytes.merge(that.rxBytes, context), txBytes.merge(that.txBytes, context), rxErrors.merge(that.rxErrors, context), txErrors.merge(that.txErrors, context)) + NetworkMetricSnapshot(rxBytes.merge(that.rxBytes, context), txBytes.merge(that.txBytes, context), rxErrors.merge(that.rxErrors, context), txErrors.merge(that.txErrors, context), rxDropped.merge(that.rxDropped, context), txDropped.merge(that.txDropped, context)) } val metrics: Map[MetricIdentity, MetricSnapshot] = Map( RxBytes -> rxBytes, TxBytes -> txBytes, RxErrors -> rxErrors, - TxErrors -> txErrors) + TxErrors -> txErrors, + RxDropped -> rxDropped, + TxDropped -> txDropped) } val Factory = NetworkMetricGroupFactory @@ -73,11 +77,15 @@ case object NetworkMetricGroupFactory extends MetricGroupFactory { val txBytesConfig = settings.getConfig("tx-bytes") val rxErrorsConfig = settings.getConfig("rx-errors") val txErrorsConfig = settings.getConfig("tx-errors") + val rxDroppedConfig = settings.getConfig("rx-dropped") + val txDroppedConfig = settings.getConfig("tx-dropped") new NetworkMetricRecorder( Histogram.fromConfig(rxBytesConfig, Scale.Kilo), Histogram.fromConfig(txBytesConfig, Scale.Kilo), Histogram.fromConfig(rxErrorsConfig), - Histogram.fromConfig(txErrorsConfig)) + Histogram.fromConfig(txErrorsConfig), + Histogram.fromConfig(rxDroppedConfig), + Histogram.fromConfig(txDroppedConfig)) } }
\ No newline at end of file diff --git a/kamon-system-metrics/src/main/scala/kamon/system/SystemMetricsCollector.scala b/kamon-system-metrics/src/main/scala/kamon/system/SystemMetricsCollector.scala index 8094cac4..c200091e 100644 --- a/kamon-system-metrics/src/main/scala/kamon/system/SystemMetricsCollector.scala +++ b/kamon-system-metrics/src/main/scala/kamon/system/SystemMetricsCollector.scala @@ -104,6 +104,8 @@ class SystemMetricsCollector(collectInterval: FiniteDuration) extends Actor with nr.txBytes.record(collect(sigar, interfaces)(net ⇒ toKB(net.getTxBytes))) nr.rxErrors.record(collect(sigar, interfaces)(net ⇒ net.getRxErrors)) nr.txErrors.record(collect(sigar, interfaces)(net ⇒ net.getTxErrors)) + nr.rxDropped.record(collect(sigar, interfaces)(net ⇒ net.getRxDropped)) + nr.txDropped.record(collect(sigar, interfaces)(net ⇒ net.getTxDropped)) def collect(sigar: SigarProxy, interfaces: Set[String])(block: NetInterfaceStat ⇒ Long): Long = { interfaces.foldLeft(0L) { (totalBytes, interface) ⇒ @@ -197,5 +199,5 @@ object SystemMetricsCollector { def isLinux: Boolean = System.getProperty("os.name").indexOf("Linux") != -1 } - def props(collectInterval: FiniteDuration): Props = Props[SystemMetricsCollector](new SystemMetricsCollector(collectInterval)) + def props(collectInterval: FiniteDuration): Props = Props(classOf[SystemMetricsCollector], collectInterval) }
\ No newline at end of file diff --git a/kamon-system-metrics/src/test/scala/kamon/metrics/SystemMetricsSpec.scala b/kamon-system-metrics/src/test/scala/kamon/metrics/SystemMetricsSpec.scala index 714a1e6d..5f0c4a10 100644 --- a/kamon-system-metrics/src/test/scala/kamon/metrics/SystemMetricsSpec.scala +++ b/kamon-system-metrics/src/test/scala/kamon/metrics/SystemMetricsSpec.scala @@ -136,6 +136,14 @@ class SystemMetricsSpec extends TestKitBase with WordSpecLike with Matchers with | highest-trackable-value = 3600000000000 | significant-value-digits = 2 | } + | rx-dropped { + | highest-trackable-value = 3600000000000 + | significant-value-digits = 2 + | } + | tx-dropped { + | highest-trackable-value = 3600000000000 + | significant-value-digits = 2 + | } | } | heap { | used { @@ -213,7 +221,7 @@ class SystemMetricsSpec extends TestKitBase with WordSpecLike with Matchers with } "the Kamon Network Metrics" should { - "record rxBytes, txBytes, rxErrors, txErrors metrics" in new NetworkMetricsListenerFixture { + "record rxBytes, txBytes, rxErrors, txErrors, rxDropped, txDropped metrics" in new NetworkMetricsListenerFixture { val metricsListener = subscribeToMetrics() val NetworkMetrics = expectNetworkMetrics(metricsListener, 3 seconds) @@ -221,6 +229,8 @@ class SystemMetricsSpec extends TestKitBase with WordSpecLike with Matchers with NetworkMetrics.txBytes.max should be >= 0L NetworkMetrics.rxErrors.max should be >= 0L NetworkMetrics.txErrors.max should be >= 0L + NetworkMetrics.rxDropped.max should be >= 0L + NetworkMetrics.txDropped.max should be >= 0L } } |