Skip to content

Commit

Permalink
Tracing config updates in archetype (#5137)
Browse files Browse the repository at this point in the history
Signed-off-by: tvallin <thibault.vallin@oracle.com>

Signed-off-by: tvallin <thibault.vallin@oracle.com>
  • Loading branch information
tvallin committed Oct 10, 2022
1 parent 5f4202e commit 62115c7
Show file tree
Hide file tree
Showing 10 changed files with 218 additions and 80 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
@@ -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.
72 changes: 4 additions & 68 deletions archetypes/helidon/src/main/archetype/common/observability.xml
Original file line number Diff line number Diff line change
Expand Up @@ -484,54 +484,8 @@ curl -s -X GET http://localhost:8080/health
<value key="artifactId">helidon-tracing-jaeger</value>
</map>
</list>
<list key="app-yaml-content">
<value><![CDATA[
tracing:
service: "helidon-full-http"
protocol: "https" # JAEGER_ENDPOINT (if not udp, http is expected and endpoint is filled)
host: "192.168.1.3" # JAEGER_ENDPOINT
port: 14240 # JAEGER_ENDPOINT
path: "/api/traces/mine" # JAEGER_ENDPOINT
token: "token" # JAEGER_AUTH_TOKEN
# Either token or username/password
#username: "user" # JAEGER_USER
#password: "pass" # JAEGER_PASSWORD
propagation: "jaeger" # JAEGER_PROPAGATION either "jaeger" or "b3"
log-spans: false # JAEGER_REPORTER_LOG_SPANS
max-queue-size: 42 # JAEGER_REPORTER_MAX_QUEUE_SIZE
flush-interval-ms: 10001 # JAEGER_REPORTER_FLUSH_INTERVAL
sampler-type: "remote"# JAEGER_SAMPLER_TYPE (https://www.jaegertracing.io/docs/latest/sampling/#client-sampling-configuration)
sampler-param: 0.5 # JAEGER_SAMPLER_PARAM (number)
sampler-manager: "localhost:47877" # JAEGER_SAMPLER_MANAGER_HOST_PORT
tags:
tag1: "tag1-value" # JAEGER_TAGS
tag2: "tag2-value" # JAEGER_TAGS
boolean-tags:
tag3: true # JAEGER_TAGS
tag4: false # JAEGER_TAGS
int-tags:
tag5: 145 # JAEGER_TAGS
tag6: 741 # JAEGER_TAGS]]></value>
</list>
<list key="MainTest-methods">
<value if="${flavor} == 'mp'"><![CDATA[
@Test
void testMetricJaeger() {
Response response = target
.path("metrics/vendor")
.request()
.get();
assertThat(response.getStatus(), is(200));
}]]></value>
<value if="${flavor} == 'se'"><![CDATA[
@Test
void testMetricJaeger() {
WebClientResponse response = webClient.get()
.path("metrics/vendor")
.request()
.await();
assertThat(response.status().code(), is(200));
}]]></value>
<list key="readme-sections">
<value file="/common/files/README.jaeger.md"/>
</list>
</model>
</output>
Expand All @@ -547,26 +501,8 @@ tracing:
<value key="artifactId">helidon-tracing-zipkin</value>
</map>
</list>
<list key="app-yaml-content">
<value><![CDATA[
tracing:
zipkin:
service: "helidon-service"
protocol: "https"
host: "192.168.1.1"
port: 9987
api-version: 1
# this is the default path for API version 2
path: "/api/v2/spans"
tags:
tag1: "tag1-value"
tag2: "tag2-value"
boolean-tags:
tag3: true
tag4: false
int-tags:
tag5: 145
tag6: 741]]></value>
<list key="readme-sections">
<value file="/common/files/README.zipkin.md"/>
</list>
</model>
</output>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions archetypes/helidon/src/main/archetype/mp/custom/custom-mp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@

<exec src="/common/media.xml"/>
<source src="/common/media-sources.xml"/>
<source src="/common/observability.xml"/>
<exec src="/common/security.xml"/>
<source src="/common/extra.xml"/>
<exec src="/common/packaging.xml"/>
<source src="/common/observability.xml"/>
<exec src="/mp/custom/database.xml"/>
<exec src="/mp/common/common-mp.xml"/>
<source src="/mp/custom/observability.xml"/>
<output>
<model>
<value key="helidon-test">true</value>
Expand All @@ -41,7 +42,7 @@
if="${docker.native-image} &amp;&amp; !(${db})"
template="mustache"/>
</list>
<list key="config-entries">
<list key="microprofile-config-entries">
<value file="files/microprofile-config.properties"/>
</list>
<list key="MainTest-java-imports" if="${media.json-lib} == 'jsonp'">
Expand Down
51 changes: 51 additions & 0 deletions archetypes/helidon/src/main/archetype/mp/custom/observability.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2022 Oracle and/or its affiliates.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<archetype-script xmlns="https://helidon.io/archetype/2.0"
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">
<output>
<model if="${tracing}">
<list key="dependencies">
<map order="800">
<value key="groupId">io.helidon.microprofile.tracing</value>
<value key="artifactId">helidon-microprofile-tracing</value>
</map>
</list>
<list key="microprofile-config-entries">
<value>tracing.service=helidon-service</value>
<value>tracing.components.web-server.spans.0.name="HTTP Request"</value>
</list>
<list if="${tracing.provider} == 'jaeger'" key="microprofile-config-entries">
<value>tracing.protocol=http</value>
<value>tracing.host=localhost</value>
<value>tracing.port=14250</value>
<value>tracing.path=/api/traces/mine</value>
<value>tracing.token=token</value>
<value>tracing.propagation=jaeger</value>
</list>
<list if="${tracing.provider} == 'zipkin'" key="microprofile-config-entries">
<value>tracing.protocol=https</value>
<value>tracing.host=192.168.1.1</value>
<value>tracing.port=9987</value>
<value>tracing.path=/api/v2/spans</value>
<value>tracing.api-version=1</value>
</list>
</model>
</output>
</archetype-script>
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ server:
port: 8080
host: 0.0.0.0

{{#config-entries}}
{{#application-yaml-entries}}
{{.}}
{{/config-entries}}
{{/application-yaml-entries}}

{{#security}}
security:
Expand Down
5 changes: 3 additions & 2 deletions archetypes/helidon/src/main/archetype/se/custom/custom-se.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@

<source src="/common/media.xml"/>
<source src="/common/media-sources.xml"/>
<exec src="/common/observability.xml"/>
<exec src="/common/security.xml"/>
<source src="/common/extra.xml"/>
<exec src="/common/packaging.xml"/>
<exec src="/common/observability.xml"/>
<exec src="/se/custom/database.xml"/>
<exec src="/se/custom/custom-tests.xml"/>
<source src="/se/custom/observability.xml"/>
<exec src="/se/common/common-se.xml"/>
<output>
<model>
Expand All @@ -47,7 +48,7 @@
<value><![CDATA[ .register("/simple-greet", simpleGreetService)]]></value>
</list>
<value key="Main-readyMessage" if="${app-type} != 'quickstart'">System.out.println("WEB server is up! http://localhost:" + ws.port() + "/simple-greet");</value>
<list key="config-entries">
<list key="application-yaml-entries">
<value file="files/src/main/resources/application.config.yaml"/>
</list>
</model>
Expand Down
8 changes: 4 additions & 4 deletions archetypes/helidon/src/main/archetype/se/custom/database.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ This example requires a database.
Instructions for H2 can be found here: https://www.h2database.com/html/cheatSheet.html
]]></value>
</list>
<list key="config-entries">
<list key="application-yaml-entries">
<value file="files/application.h2.yaml"/>
</list>
<list key="config-test">
Expand Down Expand Up @@ -171,7 +171,7 @@ docker run --rm --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root -e MYSQL_D
```
]]></value>
</list>
<list key="config-entries">
<list key="application-yaml-entries">
<value file="files/application.mysql.yaml"/>
</list>
<list key="config-test">
Expand Down Expand Up @@ -214,7 +214,7 @@ docker run --rm --name xe -p 1521:1521 -p 8888:8080 -e ORACLE_PWD=oracle wnamele
```
]]></value>
</list>
<list key="config-entries">
<list key="application-yaml-entries">
<value file="files/application.oracledb.yaml"/>
</list>
<list key="config-test">
Expand Down Expand Up @@ -255,7 +255,7 @@ docker run --rm --name mongo -p 27017:27017 mongo
```
]]></value>
</list>
<list key="config-entries">
<list key="application-yaml-entries">
<value file="files/application.mongo.yaml"/>
</list>
<list key="config-test">
Expand Down
74 changes: 74 additions & 0 deletions archetypes/helidon/src/main/archetype/se/custom/observability.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2022 Oracle and/or its affiliates.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<archetype-script xmlns="https://helidon.io/archetype/2.0"
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">
<output>
<model if="${tracing}">
<list key="application-yaml-entries">
<value if="${tracing.provider} == 'jaeger'"><![CDATA[
tracing:
service: "helidon-full-http"
protocol: "https" # JAEGER_ENDPOINT (if not udp, http is expected and endpoint is filled)
host: "192.168.1.3" # JAEGER_ENDPOINT
port: 14240 # JAEGER_ENDPOINT
path: "/api/traces/mine" # JAEGER_ENDPOINT
token: "token" # JAEGER_AUTH_TOKEN
# Either token or username/password
#username: "user" # JAEGER_USER
#password: "pass" # JAEGER_PASSWORD
propagation: "jaeger" # JAEGER_PROPAGATION either "jaeger" or "b3"
log-spans: false # JAEGER_REPORTER_LOG_SPANS
max-queue-size: 42 # JAEGER_REPORTER_MAX_QUEUE_SIZE
flush-interval-ms: 10001 # JAEGER_REPORTER_FLUSH_INTERVAL
sampler-type: "remote"# JAEGER_SAMPLER_TYPE (https://www.jaegertracing.io/docs/latest/sampling/#client-sampling-configuration)
sampler-param: 0.5 # JAEGER_SAMPLER_PARAM (number)
sampler-manager: "localhost:47877" # JAEGER_SAMPLER_MANAGER_HOST_PORT
tags:
tag1: "tag1-value" # JAEGER_TAGS
tag2: "tag2-value" # JAEGER_TAGS
boolean-tags:
tag3: true # JAEGER_TAGS
tag4: false # JAEGER_TAGS
int-tags:
tag5: 145 # JAEGER_TAGS
tag6: 741 # JAEGER_TAGS]]></value>
<value if="${tracing.provider} == 'zipkin'"><![CDATA[
tracing:
zipkin:
service: "helidon-service"
protocol: "https"
host: "192.168.1.1"
port: 9987
api-version: 1
# this is the default path for API version 2
path: "/api/v2/spans"
tags:
tag1: "tag1-value"
tag2: "tag2-value"
boolean-tags:
tag3: true
tag4: false
int-tags:
tag5: 145
tag6: 741]]></value>
</list>
</model>
</output>
</archetype-script>

0 comments on commit 62115c7

Please sign in to comment.