There will be two projects. One is built and started ahead of time and has a very simple API:
- a GET that accepts a String and returns it upper-cased after waiting an amount of time (initialed to a delay of 0),
- a PUT that accepts a new delay time in ms.
Note that this app is unrealistically simple but illustrates service-calling-service and health in the main app.
The other project is the normal greeting one from helidon init
with:
- an added liveness check that pings the other project’s up-case endpoint and reports “not ready” if it takes more than 200 ms to respond, and
- the two greet methods updated to invoke the up-case endpoint in the other app.
- Download and set up the Helidon CLI.
- Create, build, and run the upcase app.
- Prepare a Prometheus config file to work with the main app.
scrape_configs:
- job_name: 'helidon'
scrape_interval: 5s
metrics_path: '/metrics'
static_configs:
- targets: ['docker.for.mac.host.internal:8080']
-
Show one slide with a schematic of the moving parts:
- main greeting app
- up-case app
- Prometheus
-
Set up Prometheus.
-
Show the Prometheus config file, then start Prometheus:
docker run \ -p 9090:9090 \ -v ~/prometheus.yml:/etc/prometheus/prometheus.yml \ --name prom \ --rm \ prom/prometheus
-
-
Use the Helidon CLI. (https://helidon.io/docs/v2/#/mp/cli/01_cli)
-
Show the Helidon CLI download and set-up commands:
curl -O https://helidon.io/cli/latest/darwin/helidon chmod +x ./helidon sudo mv ./helidon /usr/local/bin/
-
Generate the project:
helidon init
-
Open the IDE and take a quick look at the generated endpoints.
-
Start dev loop:
cd myproject helidon dev
-
-
Show the app before any changes:
- Access the app briefly to see it working.
- Show metrics and health replies.
- Show OpenAPI document briefly.
-
Use the IDE to add an app metric to the two GET methods reusing the same counter.
- Show the dev loop’s response to the changes.
- Access the greeting endpoint using curl.
- Access Prometheus to see the new metric.
-
Use the IDE to add access to the up-case service.
- Add a private method that accepts a String and uses the REST client to contact the up-case service and returns the String in the reply.
- Revise the two greeting methods to invoke that new private method.
- Add a liveness check that invokes the up-case endpoint and times the delay, reporting UP if < 200 ms and DOWN otherwise.
-
Show the updated app’s behavior:
- Access the greeting endpoint using curl. Note the up-cased response.
- Access
/health/live
. Note theUP
result.
-
Change the delay in the up-case app using curl PUT:
curl -i -X PUT -H "Content-Type: application/json" -d '{ "delay" : 500}' http://localhost:8084/upcase
-
Show the app’s health:
- Access
/health/live
. Note theDOWN
result.
- Access