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.
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:
Click the external address of the tracing
service. A Jaeger UI is displayed, as shown below:
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.
In addition to the default sequence rendering methods, you can use other view rendering methods to display the DAG or critical path diagram.
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.
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:
Intelligent Routing with Istio on Alibaba Cloud Container Service for Kubernetes
56 posts | 8 followers
FollowXi Ning Wang - August 23, 2018
Xi Ning Wang - August 23, 2018
Xi Ning Wang - August 21, 2018
Xi Ning Wang - August 17, 2018
Xi Ning Wang - August 30, 2018
Xi Ning Wang - August 17, 2018
56 posts | 8 followers
FollowAlibaba Cloud Container Service for Kubernetes is a fully managed cloud container management service that supports native Kubernetes and integrates with other Alibaba Cloud products.
Learn MoreProvides a control plane to allow users to manage Kubernetes clusters that run based on different infrastructure resources
Learn MoreAccelerate and secure the development, deployment, and management of containerized applications cost-effectively.
Learn MoreA secure image hosting platform providing containerized image lifecycle management
Learn MoreMore Posts by Xi Ning Wang(王夕宁)