Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c3deb51
New metrics validation framework fundamentals.
robsunday Nov 22, 2024
fcf2bf8
Spotless fixes
robsunday Nov 22, 2024
d833450
Improved check for not received metrics
robsunday Nov 25, 2024
8cb96ad
Cassandra integration test converted
robsunday Nov 25, 2024
f3bac7e
Fine tuning assertion messages.
robsunday Nov 25, 2024
c9eb0a7
ActiveMqIntegrationTest converted
robsunday Nov 25, 2024
2c85c38
Spotless fix
robsunday Nov 26, 2024
bd1947f
introduce 'register' API
SylvainJuge Nov 26, 2024
1e64f80
introduce dedicated assertThat for metrics
SylvainJuge Nov 26, 2024
f7c6373
refactor metrics verifier
SylvainJuge Nov 26, 2024
b10a340
add some javadoc & few comments
SylvainJuge Nov 26, 2024
65ddfb3
spotless & minor things
SylvainJuge Nov 26, 2024
db54835
add new assertion for attribute entries
SylvainJuge Nov 26, 2024
1bdf694
check for missing assertions
SylvainJuge Nov 26, 2024
9f8a394
verify attributes are checked in strict mode
SylvainJuge Nov 27, 2024
6fb7960
enhance datapoint attributes check
SylvainJuge Nov 27, 2024
a458c1c
comments, cleanup and inline a bit
SylvainJuge Nov 27, 2024
b9f054c
strict check avoids duplicate assertions
SylvainJuge Nov 28, 2024
cf72d19
remove obsolete comments in activemq yaml
SylvainJuge Nov 28, 2024
eab7c69
register -> add
SylvainJuge Nov 28, 2024
9c3390c
reformat
SylvainJuge Nov 28, 2024
9392780
refactor cassandra
SylvainJuge Nov 28, 2024
5ae735d
fix lint
SylvainJuge Nov 28, 2024
2c65318
refactor activemq
SylvainJuge Nov 28, 2024
a670561
refactor jvm metrics
SylvainJuge Nov 28, 2024
df09034
remove unused code
SylvainJuge Nov 28, 2024
06a968f
recycle assertions when we can
SylvainJuge Nov 28, 2024
0e5fd2c
Merge pull request #4 from SylvainJuge/assertions-refactoring-more
robsunday Nov 28, 2024
8062a96
Added some JavaDocs.
robsunday Nov 28, 2024
ba95efa
Merge branch 'main' into assertions-refactoring
robsunday Nov 29, 2024
4bed658
Cleanup
robsunday Nov 29, 2024
fddc5fc
Spotless fix
robsunday Nov 29, 2024
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,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
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +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.assertTypedGauge;
import static io.opentelemetry.contrib.jmxscraper.target_systems.MetricAssertions.assertTypedSum;

import io.opentelemetry.contrib.jmxscraper.JmxScraperContainer;
import io.opentelemetry.contrib.jmxscraper.TestAppContainer;
import java.nio.file.Path;
Expand Down Expand Up @@ -36,7 +32,7 @@ protected JmxScraperContainer customizeScraperContainer(
}

@Override
protected void verifyMetrics() {
protected MetricsVerifier createMetricsVerifier() {
// those values depend on the JVM GC configured
List<String> gcLabels =
Arrays.asList(
Expand All @@ -48,43 +44,30 @@ protected void verifyMetrics() {
"PS Survivor Space");
List<String> gcCollectionLabels = Arrays.asList("PS MarkSweep", "PS Scavenge");

waitAndAssertMetrics(
metric -> assertGauge(metric, "jvm.classes.loaded", "number of loaded classes", "1"),
metric ->
assertTypedSum(
metric,
"jvm.gc.collections.count",
"total number of collections that have occurred",
"1",
gcCollectionLabels),
metric ->
assertTypedSum(
metric,
"jvm.gc.collections.elapsed",
"the approximate accumulated collection elapsed time in milliseconds",
"ms",
gcCollectionLabels),
metric -> assertGauge(metric, "jvm.memory.heap.committed", "current heap usage", "by"),
metric -> assertGauge(metric, "jvm.memory.heap.init", "current heap usage", "by"),
metric -> assertGauge(metric, "jvm.memory.heap.max", "current heap usage", "by"),
metric -> assertGauge(metric, "jvm.memory.heap.used", "current heap usage", "by"),
metric ->
assertGauge(metric, "jvm.memory.nonheap.committed", "current non-heap usage", "by"),
metric -> assertGauge(metric, "jvm.memory.nonheap.init", "current non-heap usage", "by"),
metric -> assertGauge(metric, "jvm.memory.nonheap.max", "current non-heap usage", "by"),
metric -> assertGauge(metric, "jvm.memory.nonheap.used", "current non-heap usage", "by"),
metric ->
assertTypedGauge(
metric, "jvm.memory.pool.committed", "current memory pool usage", "by", gcLabels),
metric ->
assertTypedGauge(
metric, "jvm.memory.pool.init", "current memory pool usage", "by", gcLabels),
metric ->
assertTypedGauge(
metric, "jvm.memory.pool.max", "current memory pool usage", "by", gcLabels),
metric ->
assertTypedGauge(
metric, "jvm.memory.pool.used", "current memory pool usage", "by", gcLabels),
metric -> assertGauge(metric, "jvm.threads.count", "number of threads", "1"));
return MetricsVerifier.create()
.assertGauge("jvm.classes.loaded", "number of loaded classes", "1")
.assertTypedSum(
"jvm.gc.collections.count",
"total number of collections that have occurred",
"1",
gcCollectionLabels)
.assertTypedSum(
"jvm.gc.collections.elapsed",
"the approximate accumulated collection elapsed time in milliseconds",
"ms",
gcCollectionLabels)
.assertGauge("jvm.memory.heap.committed", "current heap usage", "by")
.assertGauge("jvm.memory.heap.init", "current heap usage", "by")
.assertGauge("jvm.memory.heap.max", "current heap usage", "by")
.assertGauge("jvm.memory.heap.used", "current heap usage", "by")
.assertGauge("jvm.memory.nonheap.committed", "current non-heap usage", "by")
.assertGauge("jvm.memory.nonheap.init", "current non-heap usage", "by")
.assertGauge("jvm.memory.nonheap.max", "current non-heap usage", "by")
.assertGauge("jvm.memory.nonheap.used", "current non-heap usage", "by")
.assertTypedGauge("jvm.memory.pool.committed", "current memory pool usage", "by", gcLabels)
.assertTypedGauge("jvm.memory.pool.init", "current memory pool usage", "by", gcLabels)
.assertTypedGauge("jvm.memory.pool.max", "current memory pool usage", "by", gcLabels)
.assertTypedGauge("jvm.memory.pool.used", "current memory pool usage", "by", gcLabels)
.assertGauge("jvm.threads.count", "number of threads", "1");
}
}
Loading
Loading