Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assertions refactoring #1566

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

package io.opentelemetry.contrib.jmxscraper.target_systems;

import static io.opentelemetry.contrib.jmxscraper.target_systems.MetricAssertions.assertGaugeWithAttributes;
import static io.opentelemetry.contrib.jmxscraper.target_systems.MetricAssertions.assertSumWithAttributes;
import static org.assertj.core.api.Assertions.entry;

import io.opentelemetry.contrib.jmxscraper.JmxScraperContainer;
Expand Down Expand Up @@ -39,112 +37,86 @@ protected JmxScraperContainer customizeScraperContainer(
}

@Override
protected void verifyMetrics() {
waitAndAssertMetrics(
metric ->
assertSumWithAttributes(
metric,
"activemq.consumer.count",
"The number of consumers currently reading from the broker.",
"{consumer}",
/* isMonotonic= */ false,
attrs ->
attrs.containsOnly(
entry("destination", "ActiveMQ.Advisory.MasterBroker"),
entry("broker", "localhost"))),
metric ->
assertSumWithAttributes(
metric,
"activemq.producer.count",
"The number of producers currently attached to the broker.",
"{producer}",
/* isMonotonic= */ false,
attrs ->
attrs.containsOnly(
entry("destination", "ActiveMQ.Advisory.MasterBroker"),
entry("broker", "localhost"))),
metric ->
assertSumWithAttributes(
metric,
"activemq.connection.count",
"The total number of current connections.",
"{connection}",
/* isMonotonic= */ false,
attrs -> attrs.containsOnly(entry("broker", "localhost"))),
metric ->
assertGaugeWithAttributes(
metric,
"activemq.memory.usage",
"The percentage of configured memory used.",
"%",
attrs ->
attrs.containsOnly(
entry("destination", "ActiveMQ.Advisory.MasterBroker"),
entry("broker", "localhost"))),
metric ->
assertGaugeWithAttributes(
metric,
"activemq.disk.store_usage",
"The percentage of configured disk used for persistent messages.",
"%",
attrs -> attrs.containsOnly(entry("broker", "localhost"))),
metric ->
assertGaugeWithAttributes(
metric,
"activemq.disk.temp_usage",
"The percentage of configured disk used for non-persistent messages.",
"%",
attrs -> attrs.containsOnly(entry("broker", "localhost"))),
metric ->
assertSumWithAttributes(
metric,
"activemq.message.current",
"The current number of messages waiting to be consumed.",
"{message}",
/* isMonotonic= */ false,
attrs ->
attrs.containsOnly(
entry("destination", "ActiveMQ.Advisory.MasterBroker"),
entry("broker", "localhost"))),
metric ->
assertSumWithAttributes(
metric,
"activemq.message.expired",
"The total number of messages not delivered because they expired.",
"{message}",
attrs ->
attrs.containsOnly(
entry("destination", "ActiveMQ.Advisory.MasterBroker"),
entry("broker", "localhost"))),
metric ->
assertSumWithAttributes(
metric,
"activemq.message.enqueued",
"The total number of messages received by the broker.",
"{message}",
attrs ->
attrs.containsOnly(
entry("destination", "ActiveMQ.Advisory.MasterBroker"),
entry("broker", "localhost"))),
metric ->
assertSumWithAttributes(
metric,
"activemq.message.dequeued",
"The total number of messages delivered to consumers.",
"{message}",
attrs ->
attrs.containsOnly(
entry("destination", "ActiveMQ.Advisory.MasterBroker"),
entry("broker", "localhost"))),
metric ->
assertGaugeWithAttributes(
metric,
"activemq.message.wait_time.avg",
"The average time a message was held on a destination.",
"ms",
attrs ->
attrs.containsOnly(
entry("destination", "ActiveMQ.Advisory.MasterBroker"),
entry("broker", "localhost"))));
protected MetricsVerifier createMetricsVerifier() {
return MetricsVerifier.create()
.assertUpDownCounterWithAttributes(
"activemq.consumer.count",
"The number of consumers currently reading from the broker.",
"{consumer}",
attrs ->
attrs.containsOnly(
entry("destination", "ActiveMQ.Advisory.MasterBroker"),
entry("broker", "localhost")))
.assertUpDownCounterWithAttributes(
"activemq.producer.count",
"The number of producers currently attached to the broker.",
"{producer}",
attrs ->
attrs.containsOnly(
entry("destination", "ActiveMQ.Advisory.MasterBroker"),
entry("broker", "localhost")))
.assertUpDownCounterWithAttributes(
"activemq.connection.count",
"The total number of current connections.",
"{connection}",
attrs -> attrs.containsOnly(entry("broker", "localhost")))
.assertGaugeWithAttributes(
"activemq.memory.usage",
"The percentage of configured memory used.",
"%",
attrs ->
attrs.containsOnly(
entry("destination", "ActiveMQ.Advisory.MasterBroker"),
entry("broker", "localhost")))
.assertGaugeWithAttributes(
"activemq.disk.store_usage",
"The percentage of configured disk used for persistent messages.",
"%",
attrs -> attrs.containsOnly(entry("broker", "localhost")))
.assertGaugeWithAttributes(
"activemq.disk.temp_usage",
"The percentage of configured disk used for non-persistent messages.",
"%",
attrs -> attrs.containsOnly(entry("broker", "localhost")))
.assertUpDownCounterWithAttributes(
"activemq.message.current",
"The current number of messages waiting to be consumed.",
"{message}",
attrs ->
attrs.containsOnly(
entry("destination", "ActiveMQ.Advisory.MasterBroker"),
entry("broker", "localhost")))
.assertCounterWithAttributes(
"activemq.message.expired",
"The total number of messages not delivered because they expired.",
"{message}",
attrs ->
attrs.containsOnly(
entry("destination", "ActiveMQ.Advisory.MasterBroker"),
entry("broker", "localhost")))
.assertCounterWithAttributes(
"activemq.message.enqueued",
"The total number of messages received by the broker.",
"{message}",
attrs ->
attrs.containsOnly(
entry("destination", "ActiveMQ.Advisory.MasterBroker"),
entry("broker", "localhost")))
.assertCounterWithAttributes(
"activemq.message.dequeued",
"The total number of messages delivered to consumers.",
"{message}",
attrs ->
attrs.containsOnly(
entry("destination", "ActiveMQ.Advisory.MasterBroker"),
entry("broker", "localhost")))
.assertGaugeWithAttributes(
"activemq.message.wait_time.avg",
"The average time a message was held on a destination.",
"ms",
attrs ->
attrs.containsOnly(
entry("destination", "ActiveMQ.Advisory.MasterBroker"),
entry("broker", "localhost")));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@

package io.opentelemetry.contrib.jmxscraper.target_systems;

import static io.opentelemetry.contrib.jmxscraper.target_systems.MetricAssertions.assertGauge;
import static io.opentelemetry.contrib.jmxscraper.target_systems.MetricAssertions.assertSum;
import static io.opentelemetry.contrib.jmxscraper.target_systems.MetricAssertions.assertSumWithAttributes;
import static org.assertj.core.api.Assertions.entry;

import io.opentelemetry.contrib.jmxscraper.JmxScraperContainer;
Expand Down Expand Up @@ -44,110 +41,74 @@ protected JmxScraperContainer customizeScraperContainer(
}

@Override
protected void verifyMetrics() {
waitAndAssertMetrics(
metric ->
assertGauge(
metric,
"cassandra.client.request.range_slice.latency.50p",
"Token range read request latency - 50th percentile",
"us"),
metric ->
assertGauge(
metric,
"cassandra.client.request.range_slice.latency.99p",
"Token range read request latency - 99th percentile",
"us"),
metric ->
assertGauge(
metric,
"cassandra.client.request.range_slice.latency.max",
"Maximum token range read request latency",
"us"),
metric ->
assertGauge(
metric,
"cassandra.client.request.read.latency.50p",
"Standard read request latency - 50th percentile",
"us"),
metric ->
assertGauge(
metric,
"cassandra.client.request.read.latency.99p",
"Standard read request latency - 99th percentile",
"us"),
metric ->
assertGauge(
metric,
"cassandra.client.request.read.latency.max",
"Maximum standard read request latency",
"us"),
metric ->
assertGauge(
metric,
"cassandra.client.request.write.latency.50p",
"Regular write request latency - 50th percentile",
"us"),
metric ->
assertGauge(
metric,
"cassandra.client.request.write.latency.99p",
"Regular write request latency - 99th percentile",
"us"),
metric ->
assertGauge(
metric,
"cassandra.client.request.write.latency.max",
"Maximum regular write request latency",
"us"),
metric ->
assertSum(
metric,
"cassandra.compaction.tasks.completed",
"Number of completed compactions since server [re]start",
"1"),
metric ->
assertGauge(
metric,
"cassandra.compaction.tasks.pending",
"Estimated number of compactions remaining to perform",
"1"),
metric ->
assertSum(
metric,
"cassandra.storage.load.count",
"Size of the on disk data size this node manages",
"by",
/* isMonotonic= */ false),
metric ->
assertSum(
metric,
"cassandra.storage.total_hints.count",
"Number of hint messages written to this node since [re]start",
"1"),
metric ->
assertSum(
metric,
"cassandra.storage.total_hints.in_progress.count",
"Number of hints attempting to be sent currently",
"1",
/* isMonotonic= */ false),
metric ->
assertSumWithAttributes(
metric,
"cassandra.client.request.count",
"Number of requests by operation",
"1",
attrs -> attrs.containsOnly(entry("operation", "RangeSlice")),
attrs -> attrs.containsOnly(entry("operation", "Read")),
attrs -> attrs.containsOnly(entry("operation", "Write"))),
metric ->
assertSumWithAttributes(
metric,
"cassandra.client.request.error.count",
"Number of request errors by operation",
"1",
getRequestErrorCountAttributes()));
protected MetricsVerifier createMetricsVerifier() {
return MetricsVerifier.create()
.assertGauge(
"cassandra.client.request.range_slice.latency.50p",
"Token range read request latency - 50th percentile",
"us")
.assertGauge(
"cassandra.client.request.range_slice.latency.99p",
"Token range read request latency - 99th percentile",
"us")
.assertGauge(
"cassandra.client.request.range_slice.latency.max",
"Maximum token range read request latency",
"us")
.assertGauge(
"cassandra.client.request.read.latency.50p",
"Standard read request latency - 50th percentile",
"us")
.assertGauge(
"cassandra.client.request.read.latency.99p",
"Standard read request latency - 99th percentile",
"us")
.assertGauge(
"cassandra.client.request.read.latency.max",
"Maximum standard read request latency",
"us")
.assertGauge(
"cassandra.client.request.write.latency.50p",
"Regular write request latency - 50th percentile",
"us")
.assertGauge(
"cassandra.client.request.write.latency.99p",
"Regular write request latency - 99th percentile",
"us")
.assertGauge(
"cassandra.client.request.write.latency.max",
"Maximum regular write request latency",
"us")
.assertCounter(
"cassandra.compaction.tasks.completed",
"Number of completed compactions since server [re]start",
"1")
.assertGauge(
"cassandra.compaction.tasks.pending",
"Estimated number of compactions remaining to perform",
"1")
.assertUpDownCounter(
"cassandra.storage.load.count", "Size of the on disk data size this node manages", "by")
.assertCounter(
"cassandra.storage.total_hints.count",
"Number of hint messages written to this node since [re]start",
"1")
.assertUpDownCounter(
"cassandra.storage.total_hints.in_progress.count",
"Number of hints attempting to be sent currently",
"1")
.assertCounterWithAttributes(
"cassandra.client.request.count",
"Number of requests by operation",
"1",
attrs -> attrs.containsOnly(entry("operation", "RangeSlice")),
attrs -> attrs.containsOnly(entry("operation", "Read")),
attrs -> attrs.containsOnly(entry("operation", "Write")))
.assertCounterWithAttributes(
"cassandra.client.request.error.count",
"Number of request errors by operation",
"1",
getRequestErrorCountAttributes());
}

@SuppressWarnings("unchecked")
Expand Down
Loading
Loading