|
5 | 5 |
|
6 | 6 | package io.opentelemetry.contrib.jmxscraper.target_systems; |
7 | 7 |
|
8 | | -import static io.opentelemetry.contrib.jmxscraper.target_systems.MetricAssertions.assertGaugeWithAttributes; |
9 | | -import static io.opentelemetry.contrib.jmxscraper.target_systems.MetricAssertions.assertSumWithAttributes; |
10 | 8 | import static org.assertj.core.api.Assertions.entry; |
11 | 9 |
|
12 | 10 | import io.opentelemetry.contrib.jmxscraper.JmxScraperContainer; |
@@ -39,112 +37,86 @@ protected JmxScraperContainer customizeScraperContainer( |
39 | 37 | } |
40 | 38 |
|
41 | 39 | @Override |
42 | | - protected void verifyMetrics() { |
43 | | - waitAndAssertMetrics( |
44 | | - metric -> |
45 | | - assertSumWithAttributes( |
46 | | - metric, |
| 40 | + protected MetricsVerifier createMetricsVerifier() { |
| 41 | + return MetricsVerifier.create() |
| 42 | + .assertUpDownCounterWithAttributes( |
47 | 43 | "activemq.consumer.count", |
48 | 44 | "The number of consumers currently reading from the broker.", |
49 | 45 | "{consumer}", |
50 | | - /* isMonotonic= */ false, |
51 | 46 | attrs -> |
52 | 47 | attrs.containsOnly( |
53 | 48 | entry("destination", "ActiveMQ.Advisory.MasterBroker"), |
54 | | - entry("broker", "localhost"))), |
55 | | - metric -> |
56 | | - assertSumWithAttributes( |
57 | | - metric, |
| 49 | + entry("broker", "localhost"))) |
| 50 | + .assertUpDownCounterWithAttributes( |
58 | 51 | "activemq.producer.count", |
59 | 52 | "The number of producers currently attached to the broker.", |
60 | 53 | "{producer}", |
61 | | - /* isMonotonic= */ false, |
62 | 54 | attrs -> |
63 | 55 | attrs.containsOnly( |
64 | 56 | entry("destination", "ActiveMQ.Advisory.MasterBroker"), |
65 | | - entry("broker", "localhost"))), |
66 | | - metric -> |
67 | | - assertSumWithAttributes( |
68 | | - metric, |
| 57 | + entry("broker", "localhost"))) |
| 58 | + .assertUpDownCounterWithAttributes( |
69 | 59 | "activemq.connection.count", |
70 | 60 | "The total number of current connections.", |
71 | 61 | "{connection}", |
72 | | - /* isMonotonic= */ false, |
73 | | - attrs -> attrs.containsOnly(entry("broker", "localhost"))), |
74 | | - metric -> |
75 | | - assertGaugeWithAttributes( |
76 | | - metric, |
| 62 | + attrs -> attrs.containsOnly(entry("broker", "localhost"))) |
| 63 | + .assertGaugeWithAttributes( |
77 | 64 | "activemq.memory.usage", |
78 | 65 | "The percentage of configured memory used.", |
79 | 66 | "%", |
80 | 67 | attrs -> |
81 | 68 | attrs.containsOnly( |
82 | 69 | entry("destination", "ActiveMQ.Advisory.MasterBroker"), |
83 | | - entry("broker", "localhost"))), |
84 | | - metric -> |
85 | | - assertGaugeWithAttributes( |
86 | | - metric, |
| 70 | + entry("broker", "localhost"))) |
| 71 | + .assertGaugeWithAttributes( |
87 | 72 | "activemq.disk.store_usage", |
88 | 73 | "The percentage of configured disk used for persistent messages.", |
89 | 74 | "%", |
90 | | - attrs -> attrs.containsOnly(entry("broker", "localhost"))), |
91 | | - metric -> |
92 | | - assertGaugeWithAttributes( |
93 | | - metric, |
| 75 | + attrs -> attrs.containsOnly(entry("broker", "localhost"))) |
| 76 | + .assertGaugeWithAttributes( |
94 | 77 | "activemq.disk.temp_usage", |
95 | 78 | "The percentage of configured disk used for non-persistent messages.", |
96 | 79 | "%", |
97 | | - attrs -> attrs.containsOnly(entry("broker", "localhost"))), |
98 | | - metric -> |
99 | | - assertSumWithAttributes( |
100 | | - metric, |
| 80 | + attrs -> attrs.containsOnly(entry("broker", "localhost"))) |
| 81 | + .assertUpDownCounterWithAttributes( |
101 | 82 | "activemq.message.current", |
102 | 83 | "The current number of messages waiting to be consumed.", |
103 | 84 | "{message}", |
104 | | - /* isMonotonic= */ false, |
105 | 85 | attrs -> |
106 | 86 | attrs.containsOnly( |
107 | 87 | entry("destination", "ActiveMQ.Advisory.MasterBroker"), |
108 | | - entry("broker", "localhost"))), |
109 | | - metric -> |
110 | | - assertSumWithAttributes( |
111 | | - metric, |
| 88 | + entry("broker", "localhost"))) |
| 89 | + .assertCounterWithAttributes( |
112 | 90 | "activemq.message.expired", |
113 | 91 | "The total number of messages not delivered because they expired.", |
114 | 92 | "{message}", |
115 | 93 | attrs -> |
116 | 94 | attrs.containsOnly( |
117 | 95 | entry("destination", "ActiveMQ.Advisory.MasterBroker"), |
118 | | - entry("broker", "localhost"))), |
119 | | - metric -> |
120 | | - assertSumWithAttributes( |
121 | | - metric, |
| 96 | + entry("broker", "localhost"))) |
| 97 | + .assertCounterWithAttributes( |
122 | 98 | "activemq.message.enqueued", |
123 | 99 | "The total number of messages received by the broker.", |
124 | 100 | "{message}", |
125 | 101 | attrs -> |
126 | 102 | attrs.containsOnly( |
127 | 103 | entry("destination", "ActiveMQ.Advisory.MasterBroker"), |
128 | | - entry("broker", "localhost"))), |
129 | | - metric -> |
130 | | - assertSumWithAttributes( |
131 | | - metric, |
| 104 | + entry("broker", "localhost"))) |
| 105 | + .assertCounterWithAttributes( |
132 | 106 | "activemq.message.dequeued", |
133 | 107 | "The total number of messages delivered to consumers.", |
134 | 108 | "{message}", |
135 | 109 | attrs -> |
136 | 110 | attrs.containsOnly( |
137 | 111 | entry("destination", "ActiveMQ.Advisory.MasterBroker"), |
138 | | - entry("broker", "localhost"))), |
139 | | - metric -> |
140 | | - assertGaugeWithAttributes( |
141 | | - metric, |
| 112 | + entry("broker", "localhost"))) |
| 113 | + .assertGaugeWithAttributes( |
142 | 114 | "activemq.message.wait_time.avg", |
143 | 115 | "The average time a message was held on a destination.", |
144 | 116 | "ms", |
145 | 117 | attrs -> |
146 | 118 | attrs.containsOnly( |
147 | 119 | entry("destination", "ActiveMQ.Advisory.MasterBroker"), |
148 | | - entry("broker", "localhost")))); |
| 120 | + entry("broker", "localhost"))); |
149 | 121 | } |
150 | 122 | } |
0 commit comments