Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation Helidon SE: Update several guides for minor issues #2615

Merged
merged 7 commits into from
Dec 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -20,6 +20,6 @@ RUN echo "done!"

FROM debian:stretch-slim
WORKDIR /helidon
COPY --from=build /helidon/target/{{artifactId}} ./
COPY --from=build /helidon/target/{{artifactId}}-jri ./
ENTRYPOINT ["/bin/bash", "/helidon/bin/start"]
EXPOSE 8080
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ RUN echo "done!"

FROM debian:stretch-slim
WORKDIR /helidon
COPY --from=build /helidon/target/{{artifactId}} ./
COPY --from=build /helidon/target/{{artifactId}}-jri ./
batsatt marked this conversation as resolved.
Show resolved Hide resolved
ENTRYPOINT ["/bin/bash", "/helidon/bin/start"]
EXPOSE 8080
18 changes: 5 additions & 13 deletions docs/se/guides/04_health.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -71,30 +71,22 @@ from the root directory of your project (helidon-quickstart-se).
----

[source,java]
.Modify `Main.java`, import `HealthCheckReponse`, and replace the `createRouting` method:
.Have a look at `Main.java`, and the `createRouting` method:
----

import org.eclipse.microprofile.health.HealthCheckResponse; // <1>

...

private static Routing createRouting(Config config) {

HealthSupport health = HealthSupport.builder()
.addLiveness(HealthChecks.healthChecks()) // <2>
.addLiveness(HealthChecks.healthChecks()) // <1>
.build();

return Routing.builder()
.register(JsonSupport.create()) // <3>
.register(health) // <4>
.register(health) // <2>
.build();
}
----
<1> Import `HealthCheckResponse`.
<2> Add built-in health-checks (requires the `helidon-health-checks`
<1> Add built-in health-checks (requires the `helidon-health-checks`
dependency).
<3> Register the `JSON-P` support in the WebServer routing.
<4> Register the created health support with web server routing (adds the
<2> Register the created health support with web server routing (adds the
`/health` endpoint).


Expand Down
19 changes: 9 additions & 10 deletions docs/se/guides/05_metrics.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ already configured for both metrics and health-checks, but the following example
GreetService greetService = new GreetService(config);

return Routing.builder()
.register(JsonSupport.create())
.register(MetricsSupport.create()) // <1>
.register("/greet", greetService)
.build();
Expand Down Expand Up @@ -172,26 +171,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.

=== Metrics metadata

Expand Down
78 changes: 30 additions & 48 deletions docs/se/guides/06_tracing.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -144,28 +144,18 @@ tracing:
----

[source,java]
.Update the `Main` class; 1) Add a new import, 2) Change the code that initializes `serverConfig` to use the new `buildServerConfig` method., and 3) Add the `buildServerConfig` method:
.Update the `Main` class; Add Tracer to the WebServer builder
----
import io.helidon.tracing.TracerBuilder; // <1>
...
// Replace the existing line of code
// ServerConfiguration serverConfig = ServerConfiguration.create(config.get("server"));
// with ` ServerConfiguration serverConfig = buildServerConfig(config);`
ServerConfiguration serverConfig = buildServerConfig(config); // <2>
...

private static ServerConfiguration buildServerConfig(Config config) { // <3>
return ServerConfiguration.builder()
.config(config.get("server"))
.tracer(TracerBuilder.create(config.get("tracing")).buildAndRegister()) // <4>
.build();
}

WebServer server = WebServer.builder(createRouting(config))
.config(config.get("server"))
.tracer(TracerBuilder.create(config.get("tracing")).build()) // <2>
.addMediaSupport(JsonpSupport.create())
.build();
----
<1> Add a new import statement.
<2> Call the new `buildServerConfig` method to build a `ServerConfiguration` object.
<3> Build the `ServerConfiguration` object.
<4> Build and register a `Tracer` object using the tracing configuration.
<2> Build and register a `Tracer` object using the tracing configuration.

[source,java]
.Update the `GreetService` class; 1) Add a new import and 2) Replace the `getDefaultMessageHandler` method:
Expand All @@ -175,10 +165,10 @@ import io.opentracing.Span; // <1>
private void getDefaultMessageHandler(ServerRequest request,
ServerResponse response) {

Span span = request.tracer() // <2>
.buildSpan("getDefaultMessageHandler") // <3>
.asChildOf(request.spanContext()) // <4>
.start(); // <5>
var spanBuilder = request.tracer() // <2>
.buildSpan("getDefaultMessageHandler"); // <3>
request.spanContext().ifPresent(spanBuilder::asChildOf); // <4>
Span span = spanBuilder.start(); // <5>

try {
sendResponse(response, "World");
Expand All @@ -190,7 +180,7 @@ import io.opentracing.Span; // <1>
<1> Add new import statement.
<2> Get the `Tracer` object from the request.
<3> Build a new span named `getDefaultMessageHandler`.
<4> Make the a new span a child of the current span.
<4> Make the new span a child of the current span.
<5> Start the span. The current timestamp is used as the starting time for the span.
<6> Finish the span. The current timestamp is used as the ending time for the span.

Expand Down Expand Up @@ -378,19 +368,15 @@ server:
----

[source,java]
.Update the `Main` class; 1) Add a new import, 2) call the `buildServerConfig()` method, and 3) Add the `buildServerConfig` method:
.Update the `Main` class; Add Tracer to the WebServer builder
----
import io.helidon.tracing.TracerBuilder;
...
ServerConfiguration serverConfig = buildServerConfig(config);
...

private static ServerConfiguration buildServerConfig(Config config) {
return ServerConfiguration.builder()
.config(config.get("server"))
.tracer(TracerBuilder.create(config.get("tracing")).buildAndRegister())
.build();
}
WebServer server = WebServer.builder(createRouting(config))
.config(config.get("server"))
.tracer(TracerBuilder.create(config.get("tracing")).build())
.addMediaSupport(JsonpSupport.create())
.build();
----

[source,java]
Expand All @@ -401,10 +387,10 @@ import io.opentracing.Span;
private void getDefaultMessageHandler(ServerRequest request,
ServerResponse response) {

Span span = request.tracer()
.buildSpan("getDefaultMessageHandler")
.asChildOf(request.spanContext())
.start();
var spanBuilder = request.tracer()
.buildSpan("getDefaultMessageHandler");
request.spanContext().ifPresent(spanBuilder::asChildOf);
Span span = spanBuilder.start();

try {
sendResponse(response, "World");
Expand Down Expand Up @@ -505,12 +491,10 @@ public class GreetService implements Service {

private void getDefaultMessageHandler(ServerRequest request, ServerResponse response) {

Span span =
request
.tracer()
.buildSpan("getDefaultMessageHandler")
.asChildOf(request.spanContext())
.start();
var spanBuilder = request.tracer()
.buildSpan("getDefaultMessageHandler");
request.spanContext().ifPresent(spanBuilder::asChildOf);
Span span = spanBuilder.start();

try {
sendResponse(response, "World");
Expand Down Expand Up @@ -543,12 +527,10 @@ public class GreetService implements Service {
Invocation.Builder requestBuilder = webTarget.request();

// <2>
Span span =
request
.tracer()
.buildSpan("outboundMessageHandler")
.asChildOf(request.spanContext())
.start();
var spanBuilder = request.tracer()
.buildSpan("outboundMessageHandler");
request.spanContext().ifPresent(spanBuilder::asChildOf);
Span span = spanBuilder.start();

try {
requestBuilder.property(
Expand Down