All Projects → stevejgordon → Correlationid

stevejgordon / Correlationid

Licence: mit
An ASP.NET Core middleware component which synchronises a correlation ID for cross API request logging.

Projects that are alternatives of or similar to Correlationid

Awesome Microservices Netcore
💎 A collection of awesome training series, articles, videos, books, courses, sample projects, and tools for Microservices in .NET Core
Stars: ✭ 865 (+107.43%)
Mutual labels:  microservices, asp-net-core
Nameko
Python framework for building microservices
Stars: ✭ 4,182 (+902.88%)
Mutual labels:  microservices
Laravel
[DEPRECATED] See https://github.com/lucidarch/lucid
Stars: ✭ 373 (-10.55%)
Mutual labels:  microservices
Micronaut Microservices Poc
Very simplified insurance sales system made in a microservices architecture using Micronaut
Stars: ✭ 394 (-5.52%)
Mutual labels:  microservices
Kit
A standard library for microservices.
Stars: ✭ 21,925 (+5157.79%)
Mutual labels:  microservices
Thorntail
Source code for the Thorntail project
Stars: ✭ 397 (-4.8%)
Mutual labels:  microservices
Micro Open Graph
A tiny Node.js microservice to scrape open graph data with joy.
Stars: ✭ 371 (-11.03%)
Mutual labels:  microservices
Panda.dynamicwebapi
ASP.NET Core Dynamic Restful WebApi. Generating WebApi from Classes. Such as: Direct Generation of WebApi Based on Business Logic Layer.
Stars: ✭ 410 (-1.68%)
Mutual labels:  asp-net-core
Framework
.NET Core Extensions and Helper NuGet packages.
Stars: ✭ 399 (-4.32%)
Mutual labels:  asp-net-core
Seneca
A microservices toolkit for Node.js.
Stars: ✭ 3,834 (+819.42%)
Mutual labels:  microservices
Reference Architecture
The Reference Architecture for Agility is a technology-neutral logical architecture based on a disaggregated cloud-based model.
Stars: ✭ 384 (-7.91%)
Mutual labels:  microservices
Microservices Spring Boot
The source code for series of articles on Medium about Microservices with Spring Boot
Stars: ✭ 382 (-8.39%)
Mutual labels:  microservices
Awesome System Design
A curated list of awesome System Design (A.K.A. Distributed Systems) resources.
Stars: ✭ 4,999 (+1098.8%)
Mutual labels:  microservices
Comcms core
COMCMS_Core 版本
Stars: ✭ 377 (-9.59%)
Mutual labels:  asp-net-core
Professionalcsharp7
Code samples for the book Professional C# 7 and .NET Core 2.0 (with updates for 2.1), Wrox Press
Stars: ✭ 403 (-3.36%)
Mutual labels:  asp-net-core
Go Api Boilerplate
Go Server/API boilerplate using best practices DDD CQRS ES gRPC
Stars: ✭ 373 (-10.55%)
Mutual labels:  microservices
Ganesha
🐘 A Circuit Breaker pattern implementation for PHP applications.
Stars: ✭ 384 (-7.91%)
Mutual labels:  microservices
Istio Workshop
Istio Workshop
Stars: ✭ 395 (-5.28%)
Mutual labels:  microservices
Akkatecture
a cqrs and event sourcing framework for dotnet core using akka.net
Stars: ✭ 414 (-0.72%)
Mutual labels:  microservices
Netcoremicroservicessample
Sample using micro services in .NET Core 3.1 Focusing on clean code
Stars: ✭ 403 (-3.36%)
Mutual labels:  microservices

Correlation ID

Correlations IDs are used in distributed applications to trace requests across multiple services. This library and package provides a lightweight correlation ID approach. When enabled, request headers are checked for a correlation ID from the consumer. If found, this correlation ID is attached to the Correlation Context which can be used to access the current correlation ID where it is required for logging etc.

Optionally, this correlation ID can be attached to downstream HTTP calls made via a HttpClient instance created by the IHttpClientFactory.

NOTE: While I plan to add a few more features to this library, I believe it is close to feature complete for the scenario it was designed for. I recommend looking at built-in tracing for .NET apps for more complete and automated application tracing.

Release Notes

Change history and release notes.

Supported Runtimes

  • .NET Standard 2.0+
Package NuGet Stable NuGet Pre-release Downloads Travis CI Azure Pipelines
CorrelationId NuGet NuGet Nuget Build Status Build Status

Installation

You should install CorrelationId from NuGet:

Install-Package CorrelationId

This command from Package Manager Console will download and install CorrelationId and all required dependencies.

All stable and some pre-release packages are available on NuGet.

Quick Start

Register with DI

Inside ConfigureServices add the required correlation ID services, with common defaults.

services.AddDefaultCorrelationId

This registers a correlation ID provider which generates new IDs based on a random GUID.

Add the middleware

Register the middleware into the pipeline. This should occur before any downstream middleware which requires the correlation ID. Normally this will be registered very early in the middleware pipeline.

app.UseCorrelationId();

Where you need to access the correlation ID, you may request the ICorrelationContextAccessor from DI.

public class TransientClass
{
   private readonly ICorrelationContextAccessor _correlationContext;

   public TransientClass(ICorrelationContextAccessor correlationContext)
   {
	  _correlationContext = correlationContext;
   }

   ...
}

See the sample app for example usage.

Full documentation can be found in the wiki.

Known Issue with ASP.NET Core 2.2.0

It appears that a regression in the code for ASP.NET Core 2.2.0 means that setting the TraceIdentifier on the context via middleware results in the context becoming null when accessed further down in the pipeline. A fix is was released in 2.2.2.

A workaround at this time is to disable the behaviour of updating the TraceIdentifier using the options when adding the middleware.

Support

If this library has helped you, feel free to buy me a coffee or see the "Sponsor" link at the top of the GitHub page.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].