×
Community Blog Distributed Tracking with Istio on Alibaba Cloud Container Service for Kubernetes

Distributed Tracking with Istio on Alibaba Cloud Container Service for Kubernetes

This article uses an example to demonstrate how to use the distributed tracing system Jaeger in an Istio-enabled application.

The previous article has described how to use Alibaba Cloud Container Service for Kubernetes to quickly build an Istio open platform for connecting, managing, and securing microservices, and to introduce and configure multiple relevant services for applications.

This article uses an example to demonstrate how to use the distributed tracing system Jaeger in an Istio-enabled application.

When the applications are transformed from the monolithic architecture to the microservices architecture, traditional monitoring tools cannot provide visibility across different services.Therefore, it is necessary to introduce a tool for distributed tracing.

The OpenTracing specification emerged to address the problem of API incompatibility between different distributed tracing systems.OpenTracing is a lightweight standardization layer. It is located between applications/class libraries and tracing or log analysis programs.OpenTracing already entered CNCF and is providing unified conceptual and data standards for global distributed tracing systems.It provides platform-independent and vendor-independent APIs, which enable developers to conveniently add (or change) tracing systems.

Jaeger is an open source distributed tracing system released by CNCF. It is compatible with OpenTracing APIs.

1

Istio Distributed Tracing

Jaeger collects the trace information of an Istio-enabled application. You can click Services on the left-side navigation bar of the Alibaba Cloud Container Service page to locate the tracing service, as shown below:

2

Click the external address of the tracing service. A Jaeger UI is displayed, as shown below:

3

The Jaeger UI displays the distributed service tracing results. The time and duration scatter plots are displayed in the upper right corner to visualize the results and provide the downward mining capability.

You can select different views to visualize the tracing results, for example, a histogram within a tracing time segment or the accumulated time of a service in the tracing process.

4

In addition to the default sequence rendering methods, you can use other view rendering methods to display the DAG or critical path diagram.

5

Implementation Principles

Although the Istio proxy can automatically send spans, they need some identities to associate the entire trace relationship.The application needs to pass in the appropriate HTTP header information. In this way, when the proxy sends the span information to Jaeger, spans can accurately associate each call.

Therefore, the application must collect the following header information from the incoming requests and add it to every outgoing request.

x-request-id
x-b3-traceid
x-b3-spanid
x-b3-parentspanid
x-b3-sampled
x-b3-flags
x-ot-span-context

In the example service, the productpage application (Python application) extracts the needed header information from the HTTP request.

def getForwardHeaders(request):
    headers = {}

    user_cookie = request.cookies.get("user")
    if user_cookie:
        headers['Cookie'] = 'user=' + user_cookie

    incoming_headers = [ 'x-request-id',
                         'x-b3-traceid',
                         'x-b3-spanid',
                         'x-b3-parentspanid',
                         'x-b3-sampled',
                         'x-b3-flags',
                         'x-ot-span-context'
    ]

    for ihdr in incoming_headers:
        val = request.headers.get(ihdr)
        if val is not None:
            headers[ihdr] = val
            #print "incoming: "+ihdr+":"+val

    return headers

When the application calls other services, such header information is propagated to form a trace.

Summary

We can use Alibaba Cloud Container Service for Kubernetes to quickly build an Istio open platform for connecting, managing, and securing microservices, and to introduce and configure multiple relevant services for applications.This article uses an example to demonstrate how to use the distributed tracing system Jaeger in an Istio-enabled application.You are welcome to use Alibaba Cloud Container Service for Kubernetes to quickly build an Istio open platform and integrate Istio to microservice development in your project.

This article series introduces Istio and its core components, as well as describes how to quickly build an Istio open platform for connecting, managing, and securing microservices on the basis of Alibaba Cloud Container Service for Kubernetes. These articles also use an official example to demonstrate how to deploy an application in the Istio environment; how to configure intelligent routing and distributed tracing; and how to configure Istio functions of collecting, querying, and visualizing the telemetry data.

To review these articles, see:

  1. Using Istio on Alibaba Cloud Container Service for Kubernetes
  2. Go through Istio Features with Samples on Alibaba Cloud Container Service for Kubernetes
  3. Intelligent Routing with Istio on Alibaba Cloud Container Service for Kubernetes
  4. Distributed Tracking with Istio on Alibaba Cloud Container Service for Kubernetes
  5. Telemetry Data Collection, Query, and Visualization with Istio on Alibaba Cloud Container Service for Kubernetes
  6. Fault Diagnosis and Detection using Istio within Alibaba Cloud Container Service for Kubernetes
  7. Observability Analysis using Istio and Kiali within Alibaba Cloud Container Service for Kubernetes
0 0 0
Share on

Xi Ning Wang(王夕宁)

56 posts | 8 followers

You may also like

Comments

Xi Ning Wang(王夕宁)

56 posts | 8 followers

Related Products