Skip to content

Enables propagation of ISTIO tracing headers in ASP.Net Core.

License

Notifications You must be signed in to change notification settings

nosinovacao/istio-tracing-aspnetcore

Repository files navigation

Istio.Tracing.Progagation

Travis Build Status Coverage Status

This package turns an Asp.Net Core service into a istio-enabled application by propagating the ISTIO tracing headers from the incoming Asp.Net Core requests to the HttpClient outgoing requests using the HttpClient factory.

At @nosinovacao we believe that developers shouldn't have to worry about cross-concerns, that's why this package only needs 2 lines of code to enable.

Installing on ASP.NET Core

  1. Install the NuGet package
    dotnet add package Istio.Tracing.Propagation.AspNetCore
  1. Add all the services and middlewares to the IWebHostBuilder in Program.cs:
WebHost.CreateDefaultBuilder(args)
    .UseStartup<Startup>()
    // The following line enables Istio.Tracing.Propagation
    .PropagateIstioHeaders();

Usage with HttpClientFactory

If you are using the HttpClientFactory extensions to create your HttpClient's you are ready to go and you can see your applications tracing and telemetry on ISTIO jaeger! 😊

Usage without HttpClientFactory

If you are not using the HttpClientFactory integration you need to explicitely add the CorrelationIdHeaderDelegatingHandler to your HttpClients:

public class SomeClass 
{
    public SomeClass(string connectionString, HeadersPropagationDelegatingHandler propagationDelegatingHandler) {
        // We need to set the InnerHandler to the default HttpClient one.
        propagationDelegatingHandler.InnerHandler = new HttpClientHandler();
        // This ensures all outgoing requests will contain the Correlation Id header
        var client = new HttpClient(propagationDelegatingHandler);
    }
}

Building and testing

To build and run unit tests execute the commands in the root of repository:

dotnet build -c Release
dotnet test -c Release

Contributing

We really appreciate your interest in contributing for this project. 👍

All we ask is that you follow some simple guidelines, so please read the CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests.

Thank you, contributors!

License

Copyright © NOS Inovação.

This project is licensed under the BSD 3-Clause License - see the LICENSE file for details