mirror of
				https://github.com/nsnail/Ocelot.git
				synced 2025-11-04 19:10:51 +08:00 
			
		
		
		
	@@ -1,41 +1,8 @@
 | 
			
		||||
Tracing
 | 
			
		||||
=======
 | 
			
		||||
 | 
			
		||||
This page details how to perform distributed tracing with Ocelot. 
 | 
			
		||||
 | 
			
		||||
OpenTracing
 | 
			
		||||
^^^^^^^^^^^
 | 
			
		||||
 | 
			
		||||
Ocelot providers tracing functionality from the excellent `OpenTracing C# <https://github.com/opentracing/opentracing-csharp>`_ project. The code for the Ocelot integration
 | 
			
		||||
can be found `here <https://github.com/ThreeMammals/Ocelot.Tracing.OpenTracing>`_.
 | 
			
		||||
 | 
			
		||||
The example below uses `Jaeger C# <https://github.com/jaegertracing/jaeger-client-csharp>`_ client to provide the tracer used in Ocelot.
 | 
			
		||||
 | 
			
		||||
.. code-block:: csharp
 | 
			
		||||
 | 
			
		||||
    services.AddSingleton<ITracer>(sp =>
 | 
			
		||||
    {
 | 
			
		||||
        var loggerFactory = sp.GetService<ILoggerFactory>();
 | 
			
		||||
        Configuration config = new Configuration(context.HostingEnvironment.ApplicationName, loggerFactory);
 | 
			
		||||
 | 
			
		||||
        var tracer = config.GetTracer();
 | 
			
		||||
        GlobalTracer.Register(tracer);
 | 
			
		||||
        return tracer;
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    services
 | 
			
		||||
        .AddOcelot()
 | 
			
		||||
        .AddOpenTracing();
 | 
			
		||||
 | 
			
		||||
Then in your ocelot.json add the following to the Route you want to trace..
 | 
			
		||||
 | 
			
		||||
.. code-block:: json
 | 
			
		||||
 | 
			
		||||
      "HttpHandlerOptions": {
 | 
			
		||||
            "UseTracing": true
 | 
			
		||||
        },
 | 
			
		||||
 | 
			
		||||
Ocelot will now send tracing information to Jaeger when this Route is called.
 | 
			
		||||
This page details how to perform distributed tracing with Ocelot. At the moment we only support Butterfly but other tracers might just work without
 | 
			
		||||
anything Ocelot specific.
 | 
			
		||||
 | 
			
		||||
Butterfly
 | 
			
		||||
^^^^^^^^^
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user