Skip to content

Commit

Permalink
Merge branch 'main' into issue7694
Browse files Browse the repository at this point in the history
Signed-off-by: Jorge Bescos Gascon <jorge.bescos.gascon@oracle.com>
  • Loading branch information
jbescos committed Apr 23, 2024
2 parents 81265f7 + 9d3de35 commit cd1b59b
Show file tree
Hide file tree
Showing 156 changed files with 1,275 additions and 877 deletions.
209 changes: 2 additions & 207 deletions archetypes/archetypes/src/main/archetype/common/observability.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,215 +35,10 @@
if="${flavor} == 'mp'">
<option value="microprofile"
name="MicroProfile"
description="Expose metrics using the MicroProfile API">
<output>
<model>
<list key="readme-sections">
<value><![CDATA[
## Try metrics
```
# Prometheus Format
curl -s -X GET http://localhost:8080/metrics
# TYPE base:gc_g1_young_generation_count gauge
. . .
# JSON Format
curl -H 'Accept: application/json' -X GET http://localhost:8080/metrics
{"base":...
. . .
```
]]></value>
</list>
<list key="dependencies">
<map>
<value key="groupId">org.eclipse.microprofile.metrics</value>
<value key="artifactId">microprofile-metrics-api</value>
</map>
<map>
<value key="groupId">io.helidon.microprofile.metrics</value>
<value key="artifactId">helidon-microprofile-metrics</value>
</map>
</list>
<list key="SimpleGreetService-imports">
<value>org.eclipse.microprofile.metrics.MetricUnits</value>
<value>org.eclipse.microprofile.metrics.annotation.Counted</value>
<value>org.eclipse.microprofile.metrics.annotation.Timed</value>
<value>jakarta.ws.rs.PathParam</value>
</list>
<list key="SimpleGreetResource-static-fields">
<value><![CDATA[
private static final String PERSONALIZED_GETS_COUNTER_NAME = "personalizedGets";
private static final String PERSONALIZED_GETS_COUNTER_DESCRIPTION = "Counts personalized GET operations";
private static final String GETS_TIMER_NAME = "allGets";
private static final String GETS_TIMER_DESCRIPTION = "Tracks all GET operations";]]></value>
</list>
<list key="SimpleGreetService-methods">
<value><![CDATA[
@Path("/{name}")
@GET
@Produces(MediaType.APPLICATION_JSON)
@Counted(name = PERSONALIZED_GETS_COUNTER_NAME,
absolute = true,
description = PERSONALIZED_GETS_COUNTER_DESCRIPTION)
@Timed(name = GETS_TIMER_NAME,
description = GETS_TIMER_DESCRIPTION,
unit = MetricUnits.SECONDS,
absolute = true)
public String getMessage(@PathParam("name") String name) {
return String.format("Hello %s", name);
}]]></value>
</list>
<list key="MainTest-java-imports">
<value>org.eclipse.microprofile.metrics.Counter</value>
<value>org.eclipse.microprofile.metrics.MetricRegistry</value>
</list>
<list key="MainTest-helidon-imports">
<value>io.helidon.metrics.api.MetricsFactory</value>
</list>
<list key="MainTest-other-imports">
<value>org.junit.jupiter.api.AfterAll</value>
</list>
<list key="MainTest-static-imports">
<value>static org.junit.jupiter.api.Assertions.assertEquals</value>
</list>
<list key="MainTest-methods" order="999">
<value><![CDATA[
@AfterAll
static void clear() {
MetricsFactory.closeAll();
}
]]></value>
</list>
<list key="MainTest-methods">
<value><![CDATA[
@Test
void testMicroprofileMetrics() {
String message = target.path("simple-greet/Joe")
.request()
.get(String.class);
assertThat(message, is("Hello Joe"));
Counter counter = registry.counter("personalizedGets");
double before = counter.getCount();
message = target.path("simple-greet/Eric")
.request()
.get(String.class);
assertThat(message, is("Hello Eric"));
double after = counter.getCount();
assertEquals(1d, after - before, "Difference in personalized greeting counter between successive calls");
}]]></value>
</list>
<list key="MainTest-static-fields">
<value><![CDATA[
@Inject
private MetricRegistry registry;]]></value>
</list>
<list key="module-requires">
<value>io.helidon.microprofile.metrics</value>
</list>
</model>
</output>
</option>
description="Expose metrics using the MicroProfile API"/>
<option value="micrometer"
name="Micrometer"
description="Expose metrics using the Micrometer API">
<output>
<model>
<list key="dependencies">
<map>
<value key="groupId">io.helidon.webserver.observe</value>
<value key="artifactId">helidon-webserver-observe-metrics</value>
</map>
<map>
<value key="groupId">io.helidon.metrics</value>
<value key="artifactId">helidon-metrics-system-meters</value>
<value key="scope">runtime</value>
</map>
<map>
<value key="groupId">org.eclipse.microprofile.metrics</value>
<value key="artifactId">microprofile-metrics-api</value>
</map>
</list>
<list key="SimpleGreetService-imports">
<value>org.eclipse.microprofile.metrics.annotation.Counted</value>
<value>org.eclipse.microprofile.metrics.annotation.Timed</value>
<value>jakarta.ws.rs.PathParam</value>
</list>
<list key="SimpleGreetResource-static-fields">
<value><![CDATA[
private static final String PERSONALIZED_GETS_COUNTER_NAME = "personalizedGets";
private static final String PERSONALIZED_GETS_COUNTER_DESCRIPTION = "Counts personalized GET operations";
private static final String GETS_TIMER_NAME = "allGets";
private static final String GETS_TIMER_DESCRIPTION = "Tracks all GET operations";]]></value>
</list>
<list key="SimpleGreetService-methods">
<value><![CDATA[
@Path("/{name}")
@GET
@Produces(MediaType.APPLICATION_JSON)
@Counted(name = PERSONALIZED_GETS_COUNTER_NAME, description = PERSONALIZED_GETS_COUNTER_DESCRIPTION, absolute = true)
@Timed(name = GETS_TIMER_NAME, description = GETS_TIMER_DESCRIPTION, absolute = true)
public String getMessage(@PathParam("name") String name) {
return String.format("Hello %s", name);
}]]></value>
</list>
<list key="MainTest-java-imports">
<value>org.eclipse.microprofile.metrics.Counter</value>
<value>org.eclipse.microprofile.metrics.MetricRegistry</value>
</list>
<list key="MainTest-helidon-imports">
<value>io.helidon.metrics.api.MetricsFactory</value>
</list>
<list key="MainTest-other-imports">
<value>org.junit.jupiter.api.AfterAll</value>
</list>
<list key="MainTest-static-fields">
<value><![CDATA[
@Inject
private MetricRegistry registry;]]></value>
</list>
<list key="MainTest-methods" order="999">
<value><![CDATA[
@AfterAll
static void clear() {
MetricsFactory.closeAll();
}
]]></value>
</list>
<list key="MainTest-methods">
<value><![CDATA[
@Test
void testMicrometerMetrics() {
String message = target.path("simple-greet/Joe")
.request()
.get(String.class);
assertThat(message, is("Hello Joe"));
Counter counter = registry.counter("personalizedGets");
double before = counter.getCount();
message = target.path("simple-greet/Eric")
.request()
.get(String.class);
assertThat(message, is("Hello Eric"));
double after = counter.getCount();
assertEquals(1d, after - before, "Difference in personalized greeting counter between successive calls");
}]]></value>
</list>
<list key="MainTest-static-imports">
<value>static org.junit.jupiter.api.Assertions.assertEquals</value>
</list>
<list key="module-requires">
<value>io.helidon.microprofile.metrics</value>
</list>
</model>
</output>
</option>
description="Expose metrics using the Micrometer API"/>
</enum>
<boolean id="builtin"
name="Built-in Metrics"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@
<value key="artifactId">jandex</value>
<value key="scope">runtime</value>
</map>
<map>
<value key="groupId">jakarta.activation</value>
<value key="artifactId">jakarta.activation-api</value>
</map>
<map order="0">
<value key="groupId">org.junit.jupiter</value>
<value key="artifactId">junit-jupiter-api</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class SimpleGreetResource {
/**
* Return a worldly greeting message.
*
* @return {@link JsonObject}
* @return {@link String}
*/
@GET
@Produces(MediaType.TEXT_PLAIN)
Expand Down
Loading

0 comments on commit cd1b59b

Please sign in to comment.