|
28 | 28 | default="false" |
29 | 29 | optional="true"> |
30 | 30 | <inputs> |
31 | | - <enum id="provider" |
32 | | - name="Select a Metrics Provider" |
33 | | - default="microprofile" |
34 | | - optional="true" |
35 | | - if="${flavor} == 'mp'"> |
36 | | - <option value="microprofile" |
37 | | - name="MicroProfile" |
38 | | - description="Expose metrics using the MicroProfile API"> |
39 | | - <output> |
40 | | - <model> |
41 | | - <list key="readme-sections"> |
42 | | - <value><![CDATA[ |
43 | | -## Try metrics |
44 | | -
|
45 | | -``` |
46 | | -# Prometheus Format |
47 | | -curl -s -X GET http://localhost:8080/metrics |
48 | | -# TYPE base:gc_g1_young_generation_count gauge |
49 | | -. . . |
50 | | -
|
51 | | -# JSON Format |
52 | | -curl -H 'Accept: application/json' -X GET http://localhost:8080/metrics |
53 | | -{"base":... |
54 | | -. . . |
55 | | -``` |
56 | | -
|
57 | | -]]></value> |
58 | | - </list> |
59 | | - <list key="dependencies"> |
60 | | - <map order="800"> |
61 | | - <value key="groupId">org.eclipse.microprofile.metrics</value> |
62 | | - <value key="artifactId">microprofile-metrics-api</value> |
63 | | - </map> |
64 | | - <map order="800"> |
65 | | - <value key="groupId">io.helidon.microprofile.metrics</value> |
66 | | - <value key="artifactId">helidon-microprofile-metrics</value> |
67 | | - </map> |
68 | | - </list> |
69 | | - <list key="SimpleGreetService-imports"> |
70 | | - <value>org.eclipse.microprofile.metrics.MetricUnits</value> |
71 | | - <value>org.eclipse.microprofile.metrics.annotation.Counted</value> |
72 | | - <value>org.eclipse.microprofile.metrics.annotation.Timed</value> |
73 | | - <value>jakarta.ws.rs.PathParam</value> |
74 | | - </list> |
75 | | - <list key="SimpleGreetResource-static-fields"> |
76 | | - <value><![CDATA[ |
77 | | - private static final String PERSONALIZED_GETS_COUNTER_NAME = "personalizedGets"; |
78 | | - private static final String PERSONALIZED_GETS_COUNTER_DESCRIPTION = "Counts personalized GET operations"; |
79 | | - private static final String GETS_TIMER_NAME = "allGets"; |
80 | | - private static final String GETS_TIMER_DESCRIPTION = "Tracks all GET operations";]]></value> |
81 | | - </list> |
82 | | - <list key="SimpleGreetService-methods"> |
83 | | - <value><![CDATA[ |
84 | | - @Path("/{name}") |
85 | | - @GET |
86 | | - @Produces(MediaType.APPLICATION_JSON) |
87 | | - @Counted(name = PERSONALIZED_GETS_COUNTER_NAME, |
88 | | - absolute = true, |
89 | | - description = PERSONALIZED_GETS_COUNTER_DESCRIPTION) |
90 | | - @Timed(name = GETS_TIMER_NAME, |
91 | | - description = GETS_TIMER_DESCRIPTION, |
92 | | - unit = MetricUnits.SECONDS, |
93 | | - absolute = true) |
94 | | - public String getMessage(@PathParam("name") String name) { |
95 | | - return String.format("Hello %s", name); |
96 | | - }]]></value> |
97 | | - </list> |
98 | | - <list key="MainTest-java-imports"> |
99 | | - <value>org.eclipse.microprofile.metrics.Counter</value> |
100 | | - <value>org.eclipse.microprofile.metrics.MetricRegistry</value> |
101 | | - </list> |
102 | | - <list key="MainTest-static-imports"> |
103 | | - <value>static org.junit.jupiter.api.Assertions.assertEquals</value> |
104 | | - </list> |
105 | | - <list key="MainTest-methods"> |
106 | | - <value><![CDATA[ |
107 | | - @Test |
108 | | - void testMicroprofileMetrics() { |
109 | | - String message = target.path("simple-greet/Joe") |
110 | | - .request() |
111 | | - .get(String.class); |
112 | | -
|
113 | | - assertThat(message, is("Hello Joe")); |
114 | | - Counter counter = registry.counter("personalizedGets"); |
115 | | - double before = counter.getCount(); |
116 | | -
|
117 | | - message = target.path("simple-greet/Eric") |
118 | | - .request() |
119 | | - .get(String.class); |
120 | | -
|
121 | | - assertThat(message, is("Hello Eric")); |
122 | | - double after = counter.getCount(); |
123 | | - assertEquals(1d, after - before, "Difference in personalized greeting counter between successive calls"); |
124 | | - }]]></value> |
125 | | - </list> |
126 | | - <list key="MainTest-static-fields"> |
127 | | - <value><![CDATA[ |
128 | | - @Inject |
129 | | - private MetricRegistry registry;]]></value> |
130 | | - </list> |
131 | | - <list key="module-requires"> |
132 | | - <value>io.helidon.microprofile.metrics</value> |
133 | | - </list> |
134 | | - </model> |
135 | | - </output> |
136 | | - </option> |
137 | | - <option value="micrometer" |
138 | | - name="Micrometer" |
139 | | - description="Expose metrics using the Micrometer API"> |
140 | | - <output> |
141 | | - <model> |
142 | | - <list key="dependencies"> |
143 | | - <map> |
144 | | - <value key="groupId">io.helidon.integrations.micrometer</value> |
145 | | - <value key="artifactId">helidon-integrations-micrometer-cdi</value> |
146 | | - </map> |
147 | | - </list> |
148 | | - <list key="SimpleGreetService-imports"> |
149 | | - <value>io.micrometer.core.annotation.Counted</value> |
150 | | - <value>io.micrometer.core.annotation.Timed</value> |
151 | | - <value>jakarta.ws.rs.PathParam</value> |
152 | | - </list> |
153 | | - <list key="SimpleGreetResource-static-fields"> |
154 | | - <value><![CDATA[ |
155 | | - private static final String PERSONALIZED_GETS_COUNTER_NAME = "personalizedGets"; |
156 | | - private static final String PERSONALIZED_GETS_COUNTER_DESCRIPTION = "Counts personalized GET operations"; |
157 | | - private static final String GETS_TIMER_NAME = "allGets"; |
158 | | - private static final String GETS_TIMER_DESCRIPTION = "Tracks all GET operations";]]></value> |
159 | | - </list> |
160 | | - <list key="SimpleGreetService-methods"> |
161 | | - <value><![CDATA[ |
162 | | - @Path("/{name}") |
163 | | - @GET |
164 | | - @Produces(MediaType.APPLICATION_JSON) |
165 | | - @Counted(value = PERSONALIZED_GETS_COUNTER_NAME, description = PERSONALIZED_GETS_COUNTER_DESCRIPTION) |
166 | | - @Timed(value = GETS_TIMER_NAME, description = GETS_TIMER_DESCRIPTION, histogram = true) |
167 | | - public String getMessage(@PathParam("name") String name) { |
168 | | - return String.format("Hello %s", name); |
169 | | - }]]></value> |
170 | | - </list> |
171 | | - <list key="Main-helidon-imports"> |
172 | | - <value>io.helidon.integrations.micrometer.MicrometerSupport</value> |
173 | | - </list> |
174 | | - <list key="Main-createRouting"> |
175 | | - <value><![CDATA[ MicrometerSupport micrometerSupport = MicrometerSupport.create();]]></value> |
176 | | - </list> |
177 | | - <list key="Main-routingBuilder"> |
178 | | - <value><![CDATA[ .register(micrometerSupport) |
179 | | - .register("/micrometer-greet", new SimpleGreetService(config, micrometerSupport.registry()))]]></value> |
180 | | - </list> |
181 | | - <list key="MainTest-methods"> |
182 | | - <value><![CDATA[ |
183 | | - @Test |
184 | | - void testMicrometerMetrics() { |
185 | | - String message = target.path("simple-greet/Joe") |
186 | | - .request() |
187 | | - .get(String.class); |
188 | | -
|
189 | | - assertThat(message, is("Hello Joe")); |
190 | | - Counter counter = registry.counter("personalizedGets"); |
191 | | - double before = counter.count(); |
192 | | -
|
193 | | - message = target.path("simple-greet/Eric") |
194 | | - .request() |
195 | | - .get(String.class); |
196 | | -
|
197 | | - assertThat(message, is("Hello Eric")); |
198 | | - double after = counter.count(); |
199 | | - assertEquals(1d, after - before, "Difference in personalized greeting counter between successive calls"); |
200 | | - }]]></value> |
201 | | - </list> |
202 | | - <list key="MainTest-static-fields"> |
203 | | - <value><![CDATA[ |
204 | | - @Inject |
205 | | - private MeterRegistry registry;]]></value> |
206 | | - </list> |
207 | | - <list key="MainTest-java-imports"> |
208 | | - <value>io.micrometer.core.instrument.Counter</value> |
209 | | - <value>io.micrometer.core.instrument.MeterRegistry</value> |
210 | | - </list> |
211 | | - <list key="MainTest-static-imports"> |
212 | | - <value>static org.junit.jupiter.api.Assertions.assertEquals</value> |
213 | | - </list> |
214 | | - <list key="module-requires"> |
215 | | - <value>io.helidon.integrations.micrometer</value> |
216 | | - </list> |
217 | | - <list key="readme-sections"> |
218 | | - <value><![CDATA[ |
219 | | -## Using Micrometer |
220 | | -
|
221 | | -Access the `/micrometer` endpoint which reports the newly-added timer and counter. |
222 | | -
|
223 | | -```bash |
224 | | -curl http://localhost:8080/micrometer |
225 | | -``` |
226 | | -`SimpleGreetService` has a micrometer counter that is incremented each time a GET request is made at |
227 | | -`http://localhost:8080/greet-count`. The counter name is `allRequests` and is shown in the console |
228 | | -with the number of time it was triggered. |
229 | | -
|
230 | | -``` |
231 | | -curl http://localhost:8080/micrometer |
232 | | -# HELP allRequests_total |
233 | | -# TYPE allRequests_total counter |
234 | | -allRequests_total 0.0 |
235 | | -``` |
236 | | -]]></value> |
237 | | - </list> |
238 | | - </model> |
239 | | - </output> |
240 | | - </option> |
241 | | - </enum> |
242 | 31 | <boolean id="builtin" |
243 | 32 | name="Built-in Metrics" |
244 | 33 | description="Expose common metrics" |
245 | 34 | default="true" |
246 | | - optional="true"> |
247 | | - <output> |
248 | | - <model> |
249 | | - <list key="dependencies"> |
250 | | - <map order="800" if="${flavor} == 'se'"> |
251 | | - <value key="groupId">io.helidon.metrics</value> |
252 | | - <value key="artifactId">helidon-metrics</value> |
253 | | - </map> |
254 | | - </list> |
255 | | - <list key="Main-helidon-imports" if="${flavor} == 'se'"> |
256 | | - <value>io.helidon.metrics.MetricsSupport</value> |
257 | | - </list> |
258 | | - <list key="Main-routingBuilder" if="${flavor} == 'se'"> |
259 | | - <value><![CDATA[ .register(MetricsSupport.create()) // Metrics at "/metrics"]]></value> |
260 | | - </list> |
261 | | - <list key="MainTest-methods"> |
262 | | - <value if="${flavor} == 'mp'"><![CDATA[ |
263 | | - @Test |
264 | | - void testMetrics() { |
265 | | - Response response = target |
266 | | - .path("metrics") |
267 | | - .request() |
268 | | - .get(); |
269 | | - assertThat(response.getStatus(), is(200)); |
270 | | - }]]></value> |
271 | | - <value if="${flavor} == 'se'"><![CDATA[ |
272 | | - @Test |
273 | | - void testMetrics() { |
274 | | - WebClientResponse response = webClient.get() |
275 | | - .path("/metrics") |
276 | | - .request() |
277 | | - .await(Duration.ofSeconds(5)); |
278 | | - assertThat(response.status().code(), is(200)); |
279 | | - }]]></value> |
280 | | - </list> |
281 | | - <list key="module-requires" if="${flavor} == 'se'"> |
282 | | - <value>io.helidon.metrics</value> |
283 | | - </list> |
284 | | - <list key="readme-sections" if="${flavor} == 'se'"> |
285 | | - <value><![CDATA[ |
286 | | -## Try metrics |
287 | | -
|
288 | | -``` |
289 | | -# Prometheus Format |
290 | | -curl -s -X GET http://localhost:8080/metrics |
291 | | -# TYPE base:gc_g1_young_generation_count gauge |
292 | | -. . . |
293 | | -
|
294 | | -# JSON Format |
295 | | -curl -H 'Accept: application/json' -X GET http://localhost:8080/metrics |
296 | | -{"base":... |
297 | | -. . . |
298 | | -``` |
299 | | -
|
300 | | -]]></value> |
301 | | - </list> |
302 | | - </model> |
303 | | - </output> |
304 | | - </boolean> |
| 35 | + optional="true" |
| 36 | + if="${flavor} == 'se'"/> |
305 | 37 | </inputs> |
306 | | - <output if="${db} && ${flavor} == 'se'"> |
307 | | - <model> |
308 | | - <list key="dependencies"> |
309 | | - <map> |
310 | | - <value key="groupId">io.helidon.dbclient</value> |
311 | | - <value key="artifactId">helidon-dbclient-metrics-jdbc</value> |
312 | | - </map> |
313 | | - <map> |
314 | | - <value key="groupId">io.helidon.dbclient</value> |
315 | | - <value key="artifactId">helidon-dbclient-metrics</value> |
316 | | - </map> |
317 | | - </list> |
318 | | - </model> |
319 | | - </output> |
320 | 38 | </boolean> |
321 | 39 | <boolean id="health" |
322 | 40 | name="Health Checks" |
@@ -484,8 +202,7 @@ curl -s -X GET http://localhost:8080/health |
484 | 202 | <!-- TODO https://github.com/oracle/helidon-build-tools/issues/609 --> |
485 | 203 | <model> |
486 | 204 | <value key="metrics" if="${metrics}">true</value> |
487 | | - <value key="metrics.provider" if="${metrics} && ${flavor} == 'mp'">${metrics.provider}</value> |
488 | | - <value key="metrics.builtin" if="${metrics}">${metrics.builtin}</value> |
| 205 | + <value key="metrics.builtin" if="${metrics} && ${flavor} == 'se'">${metrics.builtin}</value> |
489 | 206 | <value key="health" if="${health}">true</value> |
490 | 207 | <value key="health.builtin" if="${health}">${health.builtin}</value> |
491 | 208 | <value key="tracing" if="${tracing}">true</value> |
|
0 commit comments