From 33ca3b63d82698035ffc1230dcb650885a005197 Mon Sep 17 00:00:00 2001 From: rghetia Date: Wed, 9 Jan 2019 05:42:54 -0800 Subject: [PATCH] Unify jaeger enabling method for adservice. (#115) --- kubernetes-manifests/adservice.yaml | 8 ++++---- src/adservice/src/main/java/hipstershop/AdService.java | 7 ++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/kubernetes-manifests/adservice.yaml b/kubernetes-manifests/adservice.yaml index 0329a72..76f35ae 100644 --- a/kubernetes-manifests/adservice.yaml +++ b/kubernetes-manifests/adservice.yaml @@ -31,8 +31,8 @@ spec: env: - name: PORT value: "9555" - - name: JAEGER_ENABLED - value: "false" + #- name: JAEGER_SERVICE_ADDR + # value: "jaeger-collector:14268" resources: requests: cpu: 200m @@ -42,12 +42,12 @@ spec: memory: 300Mi readinessProbe: initialDelaySeconds: 20 - periodSeconds: 5 + periodSeconds: 15 exec: command: ["/bin/grpc_health_probe", "-addr=:9555"] livenessProbe: initialDelaySeconds: 20 - periodSeconds: 5 + periodSeconds: 15 exec: command: ["/bin/grpc_health_probe", "-addr=:9555"] --- diff --git a/src/adservice/src/main/java/hipstershop/AdService.java b/src/adservice/src/main/java/hipstershop/AdService.java index b5d21a6..7320764 100644 --- a/src/adservice/src/main/java/hipstershop/AdService.java +++ b/src/adservice/src/main/java/hipstershop/AdService.java @@ -238,10 +238,11 @@ public class AdService { } static void initJaeger() { - boolean enabled = Boolean.parseBoolean(System.getenv("JAEGER_ENABLED")); - if (enabled) { + String jaegerAddr = System.getenv("JAEGER_SERVICE_ADDR"); + if (jaegerAddr != null && !jaegerAddr.isEmpty()) { + String jaegerUrl = String.format("http://%s/api/traces", jaegerAddr); // Register Jaeger Tracing. - JaegerTraceExporter.createAndRegister("http://jaeger-collector:14268/api/traces", "adservice"); + JaegerTraceExporter.createAndRegister(jaegerUrl, "adservice"); logger.info("Jaeger initialization complete."); } else { logger.info("Jaeger initialization disabled.");