From 534c56e0214dca20a0fa9cfba6863eb1defbaa31 Mon Sep 17 00:00:00 2001 From: Vaso Putica Date: Fri, 15 Mar 2024 16:50:36 +0100 Subject: [PATCH 1/2] Add Coherence tracing configuration --- carts/pom.xml | 5 +++++ carts/src/main/resources/application.yaml | 3 +++ catalog/pom.xml | 5 +++++ catalog/src/main/resources/application.yaml | 3 +++ k8s/coherence/carts/app.yaml | 4 ++++ k8s/coherence/catalog/app.yaml | 4 ++++ k8s/coherence/orders/app.yaml | 4 ++++ k8s/coherence/payment/app.yaml | 4 ++++ k8s/coherence/shipping/app.yaml | 4 ++++ k8s/coherence/users/app.yaml | 4 ++++ orders/pom.xml | 5 +++++ orders/src/main/resources/application.yaml | 5 ++++- payment/pom.xml | 5 +++++ payment/src/main/resources/application.yaml | 3 +++ pom.xml | 1 + shipping/pom.xml | 5 +++++ shipping/src/main/resources/application.yaml | 4 +++- users/pom.xml | 5 +++++ users/src/main/resources/application.yaml | 3 +++ 19 files changed, 74 insertions(+), 2 deletions(-) diff --git a/carts/pom.xml b/carts/pom.xml index 927e7b8..5b1a695 100644 --- a/carts/pom.xml +++ b/carts/pom.xml @@ -78,6 +78,11 @@ org.springframework.boot spring-boot-starter-aop + + io.opentracing.contrib + opentracing-spring-jaeger-cloud-starter + ${version.lib.opentracing-spring-jaeger} + diff --git a/carts/src/main/resources/application.yaml b/carts/src/main/resources/application.yaml index 2f75d90..1cbcce2 100644 --- a/carts/src/main/resources/application.yaml +++ b/carts/src/main/resources/application.yaml @@ -31,3 +31,6 @@ logging: "Coherence": info org.springframework.web: info com.oracle.coherence.spring: info +coherence: + tracing: + ratio: -1 diff --git a/catalog/pom.xml b/catalog/pom.xml index adaf46f..3d57afe 100644 --- a/catalog/pom.xml +++ b/catalog/pom.xml @@ -77,6 +77,11 @@ org.springframework.boot spring-boot-starter-aop + + io.opentracing.contrib + opentracing-spring-jaeger-cloud-starter + ${version.lib.opentracing-spring-jaeger} + diff --git a/catalog/src/main/resources/application.yaml b/catalog/src/main/resources/application.yaml index 1cb03d4..2ab2602 100644 --- a/catalog/src/main/resources/application.yaml +++ b/catalog/src/main/resources/application.yaml @@ -31,3 +31,6 @@ logging: "Coherence": info org.springframework.web: info com.oracle.coherence.spring: info +coherence: + tracing: + ratio: -1 diff --git a/k8s/coherence/carts/app.yaml b/k8s/coherence/carts/app.yaml index acbc753..a97c093 100644 --- a/k8s/coherence/carts/app.yaml +++ b/k8s/coherence/carts/app.yaml @@ -22,6 +22,10 @@ spec: value: "1" - name: COHERENCE_SERVICE_NAME value: "Carts" + - name: JAEGER_SERVICE_NAME + value: carts + - name: JAEGER_ENDPOINT + value: "http://jaeger-collector:14268/api/traces" application: main: com.oracle.coherence.examples.sockshop.spring.carts.CartsApp args: diff --git a/k8s/coherence/catalog/app.yaml b/k8s/coherence/catalog/app.yaml index bcbaa47..70f7c87 100644 --- a/k8s/coherence/catalog/app.yaml +++ b/k8s/coherence/catalog/app.yaml @@ -22,6 +22,10 @@ spec: value: "1" - name: COHERENCE_SERVICE_NAME value: "Catalog" + - name: JAEGER_SERVICE_NAME + value: catalog + - name: JAEGER_ENDPOINT + value: "http://jaeger-collector:14268/api/traces" application: main: com.oracle.coherence.examples.sockshop.spring.catalog.CatalogApp args: diff --git a/k8s/coherence/orders/app.yaml b/k8s/coherence/orders/app.yaml index f540891..e2938f1 100644 --- a/k8s/coherence/orders/app.yaml +++ b/k8s/coherence/orders/app.yaml @@ -22,6 +22,10 @@ spec: value: "1" - name: COHERENCE_SERVICE_NAME value: "Orders" + - name: JAEGER_SERVICE_NAME + value: orders + - name: JAEGER_ENDPOINT + value: "http://jaeger-collector:14268/api/traces" application: main: com.oracle.coherence.examples.sockshop.spring.orders.OrdersApp args: diff --git a/k8s/coherence/payment/app.yaml b/k8s/coherence/payment/app.yaml index 5fda946..7da027b 100644 --- a/k8s/coherence/payment/app.yaml +++ b/k8s/coherence/payment/app.yaml @@ -22,6 +22,10 @@ spec: value: "1" - name: COHERENCE_SERVICE_NAME value: "Payment" + - name: JAEGER_SERVICE_NAME + value: payment + - name: JAEGER_ENDPOINT + value: "http://jaeger-collector:14268/api/traces" application: main: com.oracle.coherence.examples.sockshop.spring.payment.PaymentApp args: diff --git a/k8s/coherence/shipping/app.yaml b/k8s/coherence/shipping/app.yaml index 4eaf119..3a9f4f0 100644 --- a/k8s/coherence/shipping/app.yaml +++ b/k8s/coherence/shipping/app.yaml @@ -22,6 +22,10 @@ spec: value: "1" - name: COHERENCE_SERVICE_NAME value: "Shipping" + - name: JAEGER_SERVICE_NAME + value: shipping + - name: JAEGER_ENDPOINT + value: "http://jaeger-collector:14268/api/traces" application: main: com.oracle.coherence.examples.sockshop.spring.shipping.ShippingApp args: diff --git a/k8s/coherence/users/app.yaml b/k8s/coherence/users/app.yaml index b042fd4..999affb 100644 --- a/k8s/coherence/users/app.yaml +++ b/k8s/coherence/users/app.yaml @@ -23,6 +23,10 @@ spec: value: "1" - name: COHERENCE_SERVICE_NAME value: "Users" + - name: JAEGER_SERVICE_NAME + value: users + - name: JAEGER_ENDPOINT + value: "http://jaeger-collector:14268/api/traces" application: main: com.oracle.coherence.examples.sockshop.spring.users.UsersApp args: diff --git a/orders/pom.xml b/orders/pom.xml index 3456ae2..d5b2609 100644 --- a/orders/pom.xml +++ b/orders/pom.xml @@ -86,6 +86,11 @@ org.springframework.boot spring-boot-starter-aop + + io.opentracing.contrib + opentracing-spring-jaeger-cloud-starter + ${version.lib.opentracing-spring-jaeger} + diff --git a/orders/src/main/resources/application.yaml b/orders/src/main/resources/application.yaml index 695ce01..9614138 100644 --- a/orders/src/main/resources/application.yaml +++ b/orders/src/main/resources/application.yaml @@ -36,4 +36,7 @@ logging: org.apache.http: debug feign: httpclient: - enabled: true \ No newline at end of file + enabled: true +coherence: + tracing: + ratio: -1 \ No newline at end of file diff --git a/payment/pom.xml b/payment/pom.xml index 0d32098..66dbe93 100644 --- a/payment/pom.xml +++ b/payment/pom.xml @@ -77,6 +77,11 @@ org.springframework.boot spring-boot-starter-aop + + io.opentracing.contrib + opentracing-spring-jaeger-cloud-starter + ${version.lib.opentracing-spring-jaeger} + org.apache.httpcomponents.client5 diff --git a/payment/src/main/resources/application.yaml b/payment/src/main/resources/application.yaml index ccde016..f438bf0 100644 --- a/payment/src/main/resources/application.yaml +++ b/payment/src/main/resources/application.yaml @@ -32,3 +32,6 @@ logging: org.springframework.web: info com.oracle.coherence.spring: info org.apache.http: debug +coherence: + tracing: + ratio: -1 diff --git a/pom.xml b/pom.xml index 05a1233..edc4e1a 100644 --- a/pom.xml +++ b/pom.xml @@ -40,6 +40,7 @@ 3.2.3 2023.0.0 2.3.0 + 3.3.1 9.0.9 3.4.1 diff --git a/shipping/pom.xml b/shipping/pom.xml index 02c017e..c4d47d1 100644 --- a/shipping/pom.xml +++ b/shipping/pom.xml @@ -77,6 +77,11 @@ org.springframework.boot spring-boot-starter-aop + + io.opentracing.contrib + opentracing-spring-jaeger-cloud-starter + ${version.lib.opentracing-spring-jaeger} + diff --git a/shipping/src/main/resources/application.yaml b/shipping/src/main/resources/application.yaml index d6ce595..f5be913 100644 --- a/shipping/src/main/resources/application.yaml +++ b/shipping/src/main/resources/application.yaml @@ -32,4 +32,6 @@ logging: org.springframework.web: info com.oracle.coherence.spring: info org.apache.http: info # set to debug to see logging of http payloads - +coherence: + tracing: + ratio: -1 \ No newline at end of file diff --git a/users/pom.xml b/users/pom.xml index cd391f1..320c537 100644 --- a/users/pom.xml +++ b/users/pom.xml @@ -99,6 +99,11 @@ org.springframework.boot spring-boot-starter-aop + + io.opentracing.contrib + opentracing-spring-jaeger-cloud-starter + ${version.lib.opentracing-spring-jaeger} + diff --git a/users/src/main/resources/application.yaml b/users/src/main/resources/application.yaml index 868c28a..5c86904 100644 --- a/users/src/main/resources/application.yaml +++ b/users/src/main/resources/application.yaml @@ -34,3 +34,6 @@ logging: org.springframework.security: info org.springframework.web: info com.oracle.coherence.spring: info +coherence: + tracing: + ratio: -1 From bb418f0f38ccbc84047bed5008bd19f17e7369af Mon Sep 17 00:00:00 2001 From: Vaso Putica Date: Fri, 15 Mar 2024 16:51:46 +0100 Subject: [PATCH 2/2] Update docs --- README.md | 4 +-- doc/complete-application-deployment.md | 36 +++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 356b1e0..bc34e50 100644 --- a/README.md +++ b/README.md @@ -163,14 +163,14 @@ If you wish to scale the back-end you can issue the following command Scale only the orders microservice: ```bash -$ kubectl --namespace sockshop scale coherence orders --replicas=3 +$ kubectl --namespace sockshop scale coherence/orders --replicas=3 ``` Or alternatively scale all the microservices: ```bash $ for name in carts catalog orders payment shipping users - do kubectl --namespace sockshop scale coherence $name --replicas=3 + do kubectl --namespace sockshop scale coherence/$name --replicas=3 done ``` diff --git a/doc/complete-application-deployment.md b/doc/complete-application-deployment.md index 2e93209..e30a858 100644 --- a/doc/complete-application-deployment.md +++ b/doc/complete-application-deployment.md @@ -34,6 +34,10 @@ Prometheus can then be accessed as documented in the If installing Prometheus into a RBAC enabled k8s cluster you may need to create the required RBAC resources as described in the [Prometheus RBAC](https://prometheus-operator.dev/docs/operator/rbac/) documentation. +In some environments, installation can fail with the error message "path /sys is not shared or slave mount". +For this demo, if necessary, it will be sufficient to comment out `mountPropagation: HostToContainer` in the +`manifests/nodeExporter-daemonset.yaml` file. + **IMPORTANT** If you installed the Sock Shop back-end into K8s before you installed Prometheus Operator, you must run the following to delete and re-add the deployments for Prometheus to pick up the Pods. This is because the Coherence Operator will not have been able to create Prometheus `ServiceMonitor` resources before Prometheus was installed. @@ -60,6 +64,16 @@ of the Grafana documentation. > Note: This is assuming you have deployed the back-ends via the instructions in > the previous section. +> Note: This step can be skipped if one wants to access application and Grafana/Prometheus/Jaeger services +> just by using `localhost`. +> In that case add port forwarding setup for each service: +>```bash +> $ kubectl --namespace sockshop port-forward svc/front-end 8079:80 +> $ kubectl --namespace monitoring port-forward svc/prometheus-k8s 9090 +> $ kubectl --namespace monitoring port-forward svc/alertmanager-main 9093 +> $ kubectl --namespace monitoring port-forward svc/grafana 3000 +>``` + 1. Create the Load Balancer ```bash @@ -139,12 +153,17 @@ of the Grafana documentation. 5. Access the application - Access the application via the endpoint http://coherence.sockshop.mycompany.com/ + Access the application via the endpoint http://coherence.sockshop.mycompany.com/ (or http://localhost:8079) ### Install the Jaeger Operator 1. Install the Jaeger Operator + The Jaeger Operator requires `cert-manager` to be installed. If it's missing, `cert-manager` + can be installed with the following command: + ```bash + kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.14.2/cert-manager.yaml + ``` If you have not done, yet, create the `monitoring` namespace: @@ -165,6 +184,21 @@ of the Grafana documentation. kubectl create -f k8s/optional/jaeger.yaml --namespace sockshop ``` + > Note: To access Jaeger UI over localhost add port forwarding setup: + > ```bash + > $ kubectl --namespace sockshop port-forward svc/jaeger-query 16686 + >``` + + > Note: to view not just Sockshop traces but also Coherence traces + > edit `application.yaml` and set `coherence.tracing.ratio` to 1. + >```yaml + > coherence: + > tracing: + > ratio: 1 + >``` + > Due to known issues between Coherence and Spring, Coherence traces will not + > be properly associated with the Spring traces. + 3. Enable Jaeger tracing in the `app.yaml` files and rebuild and redeploy services Set `management.tracing.enabled` to `true`, e.g.: