From 2cdbc06e72670f01345d0beea134959fa535b76a Mon Sep 17 00:00:00 2001 From: tvallin Date: Thu, 29 Sep 2022 17:22:17 +0200 Subject: [PATCH 1/2] tracing configuration update Signed-off-by: tvallin --- .../main/archetype/common/observability.xml | 70 ----------------- .../microprofile-config.properties.mustache | 4 +- .../main/archetype/mp/custom/custom-mp.xml | 5 +- .../archetype/mp/custom/observability.xml | 50 ++++++++++++ .../main/resources/application.yaml.mustache | 4 +- .../main/archetype/se/custom/custom-se.xml | 5 +- .../src/main/archetype/se/custom/database.xml | 8 +- .../archetype/se/custom/observability.xml | 76 +++++++++++++++++++ 8 files changed, 140 insertions(+), 82 deletions(-) create mode 100644 archetypes/helidon/src/main/archetype/mp/custom/observability.xml create mode 100644 archetypes/helidon/src/main/archetype/se/custom/observability.xml diff --git a/archetypes/helidon/src/main/archetype/common/observability.xml b/archetypes/helidon/src/main/archetype/common/observability.xml index 894e58d41bc..17fe9827b94 100644 --- a/archetypes/helidon/src/main/archetype/common/observability.xml +++ b/archetypes/helidon/src/main/archetype/common/observability.xml @@ -484,55 +484,6 @@ curl -s -X GET http://localhost:8080/health helidon-tracing-jaeger - - - - - - - @@ -547,27 +498,6 @@ tracing: helidon-tracing-zipkin - - - diff --git a/archetypes/helidon/src/main/archetype/mp/common/files/src/main/resources/META-INF/microprofile-config.properties.mustache b/archetypes/helidon/src/main/archetype/mp/common/files/src/main/resources/META-INF/microprofile-config.properties.mustache index a9abb5ceba8..0fd8455a02a 100644 --- a/archetypes/helidon/src/main/archetype/mp/common/files/src/main/resources/META-INF/microprofile-config.properties.mustache +++ b/archetypes/helidon/src/main/archetype/mp/common/files/src/main/resources/META-INF/microprofile-config.properties.mustache @@ -5,9 +5,9 @@ server.host=0.0.0.0 # Change the following to true to enable the optional MicroProfile Metrics REST.request metrics metrics.rest-request.enabled=false -{{#config-entries}} +{{#microprofile-config-entries}} {{.}} -{{/config-entries}} +{{/microprofile-config-entries}} {{#database-hikari}} # Datasource properties diff --git a/archetypes/helidon/src/main/archetype/mp/custom/custom-mp.xml b/archetypes/helidon/src/main/archetype/mp/custom/custom-mp.xml index c8ec4650d04..d80a7bb0b4c 100644 --- a/archetypes/helidon/src/main/archetype/mp/custom/custom-mp.xml +++ b/archetypes/helidon/src/main/archetype/mp/custom/custom-mp.xml @@ -23,12 +23,13 @@ - + + files @@ -47,7 +48,7 @@ if="${docker.native-image} && !(${db})" template="mustache"/> - + diff --git a/archetypes/helidon/src/main/archetype/mp/custom/observability.xml b/archetypes/helidon/src/main/archetype/mp/custom/observability.xml new file mode 100644 index 00000000000..f5ebaa28b5d --- /dev/null +++ b/archetypes/helidon/src/main/archetype/mp/custom/observability.xml @@ -0,0 +1,50 @@ + + + + + + + + io.helidon.microprofile.tracing + helidon-microprofile-tracing + + + + tracing.service=helidon-service + tracing.protocol=https + tracing.components.web-server.spans.0.name="HTTP Request" + + + tracing.host=192.168.1.3 + tracing.port=14240 + tracing.path=/api/traces/mine + tracing.token=token + tracing.propagation=jaeger + + + tracing.host=192.168.1.1 + tracing.port=9987 + tracing.path=/api/v2/spans + tracing.api-version=1 + + + + diff --git a/archetypes/helidon/src/main/archetype/se/common/files/src/main/resources/application.yaml.mustache b/archetypes/helidon/src/main/archetype/se/common/files/src/main/resources/application.yaml.mustache index ce88438f213..a405eec903d 100644 --- a/archetypes/helidon/src/main/archetype/se/common/files/src/main/resources/application.yaml.mustache +++ b/archetypes/helidon/src/main/archetype/se/common/files/src/main/resources/application.yaml.mustache @@ -2,9 +2,9 @@ server: port: 8080 host: 0.0.0.0 -{{#config-entries}} +{{#application-yaml-entries}} {{.}} -{{/config-entries}} +{{/application-yaml-entries}} {{#security}} security: diff --git a/archetypes/helidon/src/main/archetype/se/custom/custom-se.xml b/archetypes/helidon/src/main/archetype/se/custom/custom-se.xml index 02ba5e240ba..211a2bb3ee3 100644 --- a/archetypes/helidon/src/main/archetype/se/custom/custom-se.xml +++ b/archetypes/helidon/src/main/archetype/se/custom/custom-se.xml @@ -22,12 +22,13 @@ - + + @@ -47,7 +48,7 @@ System.out.println("WEB server is up! http://localhost:" + ws.port() + "/simple-greet"); - + diff --git a/archetypes/helidon/src/main/archetype/se/custom/database.xml b/archetypes/helidon/src/main/archetype/se/custom/database.xml index 548ae352f14..0a92c19ee08 100644 --- a/archetypes/helidon/src/main/archetype/se/custom/database.xml +++ b/archetypes/helidon/src/main/archetype/se/custom/database.xml @@ -43,7 +43,7 @@ This example requires a database. Instructions for H2 can be found here: https://www.h2database.com/html/cheatSheet.html ]]> - + @@ -171,7 +171,7 @@ docker run --rm --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root -e MYSQL_D ``` ]]> - + @@ -214,7 +214,7 @@ docker run --rm --name xe -p 1521:1521 -p 8888:8080 -e ORACLE_PWD=oracle wnamele ``` ]]> - + @@ -255,7 +255,7 @@ docker run --rm --name mongo -p 27017:27017 mongo ``` ]]> - + diff --git a/archetypes/helidon/src/main/archetype/se/custom/observability.xml b/archetypes/helidon/src/main/archetype/se/custom/observability.xml new file mode 100644 index 00000000000..c2ff92f3a90 --- /dev/null +++ b/archetypes/helidon/src/main/archetype/se/custom/observability.xml @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + From 2266b5838a31b54ffb26801de86890397175e0be Mon Sep 17 00:00:00 2001 From: tvallin Date: Thu, 6 Oct 2022 11:07:55 +0200 Subject: [PATCH 2/2] Add documentation Signed-off-by: tvallin --- .../archetype/common/files/README.jaeger.md | 28 +++++++++++ .../archetype/common/files/README.zipkin.md | 47 +++++++++++++++++++ .../main/archetype/common/observability.xml | 6 +++ .../archetype/mp/custom/observability.xml | 31 ++++++------ .../archetype/se/custom/observability.xml | 6 +-- 5 files changed, 99 insertions(+), 19 deletions(-) create mode 100644 archetypes/helidon/src/main/archetype/common/files/README.jaeger.md create mode 100644 archetypes/helidon/src/main/archetype/common/files/README.zipkin.md diff --git a/archetypes/helidon/src/main/archetype/common/files/README.jaeger.md b/archetypes/helidon/src/main/archetype/common/files/README.jaeger.md new file mode 100644 index 00000000000..241f0593419 --- /dev/null +++ b/archetypes/helidon/src/main/archetype/common/files/README.jaeger.md @@ -0,0 +1,28 @@ +## Tracing + +### Set up Jaeger + +First, you need to run the Jaeger tracer. Helidon will communicate with this tracer at runtime. + +Run Jaeger within a docker container: +``` +docker run -d --name jaeger\ + -e COLLECTOR_ZIPKIN_HOST_PORT=:9411\ + -e COLLECTOR_OTLP_ENABLED=true\ + -p 6831:6831/udp\ + -p 6832:6832/udp\ + -p 5778:5778\ + -p 16686:16686\ + -p 4317:4317\ + -p 4318:4318\ + -p 14250:14250\ + -p 14268:14268\ + -p 14269:14269\ + -p 9411:9411\ + jaegertracing/all-in-one:1.38 +``` + +### View Tracing Using Jaeger UI + +Jaeger provides a web-based UI at http://localhost:16686, where you can see a visual representation of +the same data and the relationship between spans within a trace. diff --git a/archetypes/helidon/src/main/archetype/common/files/README.zipkin.md b/archetypes/helidon/src/main/archetype/common/files/README.zipkin.md new file mode 100644 index 00000000000..d1ae33b0aea --- /dev/null +++ b/archetypes/helidon/src/main/archetype/common/files/README.zipkin.md @@ -0,0 +1,47 @@ +## Tracing + +### Set up Zipkin + +First, you need to run the Zipkin tracer. Helidon will communicate with this tracer at runtime. + +Run Zipkin within a docker container, then check the Zipkin server health: +``` +docker run -d --name zipkin -p 9411:9411 openzipkin/zipkin +``` +Run the Zipkin docker image named openzipkin/zipkin. +Check the Zipkin server health: +``` +curl http://localhost:9411/health +``` +Invoke the Zipkin REST API to check the Zipkin server health. +``` +Response body +{ + "status": "UP", + "zipkin": { + "status": "UP", + "details": { + "InMemoryStorage{}": { + "status": "UP" + } + } + } +} +``` +All status fields should be UP. + +### View Tracing Using Zipkin REST API + +Run the curl command and check the response: +``` +curl http://localhost:9411/api/v2/services +``` +Response body +``` +["helidon-mp-1"] +``` + +### View Tracing Using Zipkin UI + +Zipkin provides a web-based UI at http://localhost:9411/zipkin, where you can see a visual representation of +the same data and the relationship between spans within a trace. diff --git a/archetypes/helidon/src/main/archetype/common/observability.xml b/archetypes/helidon/src/main/archetype/common/observability.xml index 17fe9827b94..0139b94a644 100644 --- a/archetypes/helidon/src/main/archetype/common/observability.xml +++ b/archetypes/helidon/src/main/archetype/common/observability.xml @@ -484,6 +484,9 @@ curl -s -X GET http://localhost:8080/health helidon-tracing-jaeger + + + @@ -498,6 +501,9 @@ curl -s -X GET http://localhost:8080/health helidon-tracing-zipkin + + + diff --git a/archetypes/helidon/src/main/archetype/mp/custom/observability.xml b/archetypes/helidon/src/main/archetype/mp/custom/observability.xml index f5ebaa28b5d..963b063870d 100644 --- a/archetypes/helidon/src/main/archetype/mp/custom/observability.xml +++ b/archetypes/helidon/src/main/archetype/mp/custom/observability.xml @@ -20,30 +20,31 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://helidon.io/archetype/2.0 https://helidon.io/xsd/archetype-2.0.xsd"> - - + + io.helidon.microprofile.tracing helidon-microprofile-tracing - + tracing.service=helidon-service - tracing.protocol=https tracing.components.web-server.spans.0.name="HTTP Request" - - tracing.host=192.168.1.3 - tracing.port=14240 - tracing.path=/api/traces/mine - tracing.token=token - tracing.propagation=jaeger + + tracing.protocol=http + tracing.host=localhost + tracing.port=14250 + tracing.path=/api/traces/mine + tracing.token=token + tracing.propagation=jaeger - - tracing.host=192.168.1.1 - tracing.port=9987 - tracing.path=/api/v2/spans - tracing.api-version=1 + + tracing.protocol=https + tracing.host=192.168.1.1 + tracing.port=9987 + tracing.path=/api/v2/spans + tracing.api-version=1 diff --git a/archetypes/helidon/src/main/archetype/se/custom/observability.xml b/archetypes/helidon/src/main/archetype/se/custom/observability.xml index c2ff92f3a90..62b88e68c9a 100644 --- a/archetypes/helidon/src/main/archetype/se/custom/observability.xml +++ b/archetypes/helidon/src/main/archetype/se/custom/observability.xml @@ -20,8 +20,8 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://helidon.io/archetype/2.0 https://helidon.io/xsd/archetype-2.0.xsd"> - - + + - -