Introduction
Modern software architectures built on microservices and serverless introduce advantages to application development but there’s also the cost of reduced visibility.
Requests often span multiple services. Each service handles a request by performing one or more operations, for examaple - database queries, publish messages, etc.
How to understand the behavior of an application, monitor services, and troubleshoot problems?
Distributed tracing provides end-to-end visibility and reveals service dependencies – showing how the services respond to each other.
This article demonstrates how to set up the Jaeger all-in-one deployment on local testing with traces generated from two ASP.NET Core applications.
Setup Jaeger
Using docker to setup Jaeger is very easy, and jaegertracing provides an image named all-in-one which is designed for quick local testing, launches the Jaeger UI, collector, query, and an agent with an in-memory storage component.
- docker run -d --name jaeger \
- -e COLLECTOR_ZIPKIN_HTTP_PORT=9411 \
- -p 5775:5775/udp \
- -p 6831:6831/udp \
- -p 6832:6832/udp \
- -p 5778:5778 \
- -p 16686:16686 \
- -p 14268:14268 \
- -p 9411:9411 \
- jaegertracing/all-in-one:latest
After running up, we can navigate to http://localhost:16686 to access the Jaeger UI.

What we should do next is to integrate it with ASP.NET Core.
Integrate With ASP.NET Core
Here, we will create two ASP.NET Core Web API projects to show - one of them is named CustomerApi and the other one is named OrderApi.
We should add two NuGet packages in our projects.
- Install-Package Jaeger -Version 0.2.2
- Install-Package OpenTracing.Contrib.NetCore -Version 0.5.0
- services.AddSingleton<ITracer>(serviceProvider =>
- {
- string serviceName = Assembly.GetEntryAssembly().GetName().Name;
- ILoggerFactory loggerFactory = serviceProvider.GetRequiredService<ILoggerFactory>();
- ISampler sampler = new ConstSampler(sample: true);
- ITracer tracer = new Tracer.Builder(serviceName)
- .WithLoggerFactory(loggerFactory)
- .WithSampler(sampler)
- .Build();
- GlobalTracer.Register(tracer);
- return tracer;
- });
- services.AddOpenTracing();
- [Route("api/orders")]
- public class OrdersController : Controller
- {
- private readonly OrderDbContext _dbContext;
- public OrdersController(OrderDbContext dbContext)
- {
- this._dbContext = dbContext;
- }
- // GET: api/orders
- [HttpGet]
- public IEnumerable<string> Get()
- {
- // query data from SQLite
- var orders = _dbContext.Orders.ToList();
- return new string[] { "value1", "value2" };
- }
- // GET: api/orders/1
- [HttpGet("{id}")]
- public ActionResult<string> Get(int id)
- {
- throw new System.Exception("Error Test");
- return "value";
- }
- }







Azri ZakariaPosted Jun 25, 2019, 5:04 AM
I install the jaeger on different server. Any idea how to sent data on the different server?
Jeeva SubburajPosted Mar 19, 2019, 9:59 AM
Thanks for the article. Tracing is very important for microservices and this tool looks very promising (open source and part of CNCF (Cloud Native Computing Foundation))