Enable Zipkin Tracing for .Net Core Apps in PCF(i.e. TAS)
Zipkin is a distributed tracing system. Zipkin help us to troubleshoot the failures & latency issues of applications. Zipkin provides the ability to trace requests and responses across distributed systems.
Zipkin will support different databases like Cassandra, Elastic search, My SQL.. It will provide us web interface to filter the requests & dependency diagram of each request flow within applications.
Use case: 1
If you have a large enterprise application with different microservices will communicate within a single request. We need to find out the latency issues of request which microservices is taking more time to get the response. In this case Zipkin is very useful to achieve latency issues. We can use other tools also.
Here I’m going to focus on how to deploy the Zipkin App in PCF & Integrating DOT NET CORE Apps with help of Steeltoe lib’s.
How to deploy Zipkin server on PCF:
Here I’m not integrating any databases Just I’m using deployed server storage for time being.
1. Download the zipkin .jar file from Zipkin.io (i.e. https://zipkin.io/pages/quickstart.html ) & click on latest release it will download the .jar file.
2. Login to CF CLI & copy the downloaded .Jar file path push into PCF platform. best way to push by using manifest file like below with efficient configuration information.
OR
cf push zipkinserver -p C:\Users\RamanaReddy\Desktop\PCF\zipkin\zipkin-server-2.23.2-exec.jar
3. Navigate to deployed application you’re able to see home page like below without any authentication.
Integrate Zipkin into .net core applications with help of steeltoe:
Prerequisites:
1. PCF account (i.e. PCF part of VMware Tanzu https://login.run.pivotal.io/login It may differ )
2. CF CLI Installation (i.e. https://docs.run.pivotal.io/cf-cli/install-go-cli.html ) — Windows Platform choice.
3. .Net 5 with Blazor Framework (i.e. we can choose lower versions also)
4. steeltoe Packages from NuGet.
5. Create a .net core supported version of build packs with PCF.
Note : Here I’m using BlazorApp like previous examples.. for more details visit below articles.
Download the below NuGet package into project
update the Startup.cs file like below
Update the appsettings.json configuration like below according to your env.
egressIgnorePattern : We need to ignore the outgoing request export into Zipkin server with help of regex pattern.
Similarly, we can update the Micro_Service_1 & Micro_Service_2 services. Deploy the BlazorApp, Micro_Service_1 & Micro_Service_2 into PCF. Please refer previous articles.
Go to deployed BlazorApp & perform some activities on links . It’ll hit the Micro_Service_1 & Micro_Service_2.
Go to Deployed Zipkin URL we’ll get the top 10 requests by default like below .
Just open the high request duration issue we’ll get how much time consumed each microservice look like below.
Based on trace Id we can go to directly logs to identify the issue quickly . For example Micro_Service_1 & Micro_Service_2 App logs like below.
If you go to logs files Micro_Service_1 & Micro_Service_2 you’ll get the logs with a trace id ab13dafe99f2a061 like below.
Zipkin tracing is enabled by default PCF of VMware Tanzu Applications. The Gorouter will take care of RTR logs whenever http requests hits apps. If we enabled zipkin tracing logging in CF then RTR logs looks like above. That request information exported to Zipkin server with a trace id, span id etc…
References :
- https://zipkin.io/
- https://steeltoe.io
- https://docs.cloudfoundry.org/devguide/deploy-apps/streaming-logs.html#rtr
- https://docs.pivotal.io/application-service/2-10/adminguide/zipkin_tracing.html
Note:
I’m sharing this as per my knowledge. Anywhere, I did wrong. please let me know. I want to update myself.
=============== Happy Coding ===============