Skip to content

Commit

Permalink
Documentation Helidon MP: Update several guides for minor issues (#2616)
Browse files Browse the repository at this point in the history
* Remove GreetApplication from metrics guide

Signed-off-by: tvallin <thibault.vallin@oracle.com>

* Fix metrics guide

Signed-off-by: tvallin <thibault.vallin@oracle.com>

* Fix config guide

Signed-off-by: tvallin <thibault.vallin@oracle.com>
  • Loading branch information
tvallin authored Dec 17, 2020
1 parent 4f888f6 commit b78ad53
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 28 deletions.
35 changes: 35 additions & 0 deletions docs/mp/guides/03_config.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,41 @@ system properties, environment variables, and the contents of `META-INF/micropr
For example, if you specify a custom server port in `META-INF/microprofile-config.properties`
then your server will listen on that port.
A main class is also required to start up the server and run the
application. If you don't use Helidon's built-in main class you can
define your own:
[source,java]
.src/main/java/io/helidon/examples/quickstart/mp/Main.java
----
package io.helidon.examples.quickstart.mp;
import io.helidon.microprofile.server.Server;
import java.io.IOException;
public final class Main {
private Main() { } // <1>
public static void main(final String[] args) throws IOException {
Server server = startServer();
System.out.println("http://localhost:" + server.port() + "/greet");
}
static Server startServer() {
return Server.create().start(); // <2>
}
}
----
In this class, a `main` method is defined which starts the Helidon MP
server and prints out a message with the listen address.
<1> Notice that
this class has an empty no-args constructor to make sure this class
cannot be instantiated.
<2> The MicroProfile server is started with the default configuration.
In your application code, Helidon uses the default configuration when you create a `Server` object without a custom `Config` object.
See the following code from the project you created.
Expand Down
37 changes: 9 additions & 28 deletions docs/mp/guides/05_metrics.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,6 @@ curl -H "Accept: application/json" http://localhost:8080/metrics
"thread.max.count": 44
},
"vendor": {
"grpc.requests.count": 0,
"grpc.requests.meter": {
"count": 0,
"meanRate": 0.0,
"oneMinRate": 0.0,
"fiveMinRate": 0.0,
"fifteenMinRate": 0.0
},
"requests.count": 6,
"requests.meter": {
"count": 6,
Expand All @@ -163,26 +155,26 @@ curl -H "Accept: application/json" http://localhost:8080/metrics
You can get a single metric by specifying the name in the URL path.
[source,bash]
.Get the Helidon `grpc.requests.meter` metric:
.Get the Helidon `requests.meter` metric:
----
curl -H "Accept: application/json" http://localhost:8080/metrics/vendor/grpc.requests.meter
curl -H "Accept: application/json" http://localhost:8080/metrics/vendor/requests.meter
----
[source,json]
.JSON response:
----
{
"grpc.requests.meter": {
"count": 0,
"meanRate": 0.0,
"oneMinRate": 0.0,
"fiveMinRate": 0.0,
"fifteenMinRate": 0.0
"requests.meter": {
"count": 6,
"meanRate": 0.008275992296704147,
"oneMinRate": 0.01576418632772332,
"fiveMinRate": 0.006695060022357365,
"fifteenMinRate": 0.0036382699664488415
}
}
----
NOTE: You cannot get the individual fields of a metric. For example, you cannot target http://localhost:8080/metrics/vendor/grpc.requests.meter.count.
NOTE: You cannot get the individual fields of a metric. For example, you cannot target http://localhost:8080/metrics/vendor/requests.meter.count.
==== Controlling `REST.request` metrics
Helidon implements the optional family of metrics, all with the name `REST.request`, as described in the
Expand Down Expand Up @@ -311,17 +303,6 @@ The default behavior is to decrement when exiting the method. Here is an exampl
`@Counted(name = "any-card", monotonic = true)`.
[source,java]
.Update the `GreetApplication` class as follows:
----
@Override
public Set<Class<?>> getClasses() {
return Set.of(GreetResource.class, GreetingCards.class); // <1>
}
----
<1> Add the `GreetingCards` class to the set of classes managed by Helidon for this application.
[source,bash]
.Build and run the application, then invoke the application endpoints below:
----
Expand Down

0 comments on commit b78ad53

Please sign in to comment.