spring-boot-istio-jaeger-demo

Spring Boot项目利用Istio的Jaeger做分布式Tracing的例子

Stars
15
Committers
1

spring-boot-istio-jaeger-demo

Spring BootJaegerTracing

3servicefoo-svc``bar-svc``loo-svc

  1. foo-svc bar-svc
    1. bar-svc redis
    2. bar-svc h2
    3. bar-svc loo-svc
      1. loo-svc redis
      2. loo-svc h2

  1. cddocker-compose up
  2. foo-svccurl http://localhost:8080
  3. Jaegerhttp://localhost:16686/

RedisTracing

opentracing java-spring-jaegerspring-data-redisAuto Configurationopentracing java-redis-client

BeanPostProcessorinstrumentRedisConnectionFactoryBeanPostProcessor.java

@Component
public class RedisConnectionFactoryBeanPostProcessor implements BeanPostProcessor {

  private Tracer tracer;

  public RedisConnectionFactoryBeanPostProcessor(Tracer tracer) {
    this.tracer = tracer;
  }

  @Override
  public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
    if (bean instanceof RedisConnectionFactory) {
      return new TracingRedisConnectionFactory((RedisConnectionFactory) bean, false, tracer);
    }
    return bean;
  }

}

opentracing java-redis-clientRedisConnection``ReactiveRedisConnectiontracing ReactiveRedisConnectiontracingopentracing java-redis-client0.0.8


docker-compose down

IstioK8S


  1. K8S
  2. Istio
  3. IstioJaeger
  4. istio-system``jaeger-query Service

  1. cdk8s
  2. 06-foo-ingress.yaml``<hostname>
  3. k8s``kubectl apply -f .
  4. foo-svc
    1. nginx ingresscurl http://ingress-test.<hostname>/sb-jaeger-tracing-demo/
    2. Istio Gatewaycurl http://istio-test.<hostname>/sb-jaeger-tracing-demo/
  5. jaeger-query

nginx ingresstracingIssue #7963Istio Gatewaytracing

tracingistiocomponenttracingtracing istioenvoy sidecar

01-namespace.yaml``JAEGER_UDP_SENDER_HOST: jaeger-agent.istio-system.svc.cluster.localistiojaeger-agentcluster DNS name


k8s``kubectl delete -f .

Environment Variable Default Value Belong Service Description
BAR_SVC_URL http://bar-svc:8080 foo-svc
LOO_SVC_URL http://loo-svc:8080 bar-svc
SERVER_PORT 8080 all
REDIS_HOST redis bar-svc loo-svc
REDIS_PORT 6379 bar-svc loo-svc
JAEGER_UDP_SENDER_HOST localhost all
OPENTRACING_SPRING_WEB_ENABLED true all spring webopentracing

Jaegertracing

Related Projects