
Security News
Open Source CAI Framework Handles Pen Testing Tasks up to 3,600× Faster Than Humans
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
TraceLink.AspNetCore
Advanced tools
Install Nuget Package TraceLink.AspNetCore
The Correlation ID will remaing static for the lifetime of a process. This enables correlation of a process over multiple services.
Example: New ID -> ServiceA -> Same ID -> ServiceB -> Same ID -> ServiceC
public void ConfigureServices(IServiceCollection services)
{
// Adds Required Sercies and Configuration
services.AddCorrelation();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
// Enables Correlation Middleware
app.UseCorrelation();
}
services.AddCorrelation(o =>
{
// The default value is x-correlation-id
o.Key = "my-custom-key";
o.AttachToResponse = true;
o.IsRequired = true;
o.AttachToLoggingScope = false;
// The default value is correlation-id
o.LoggingScopeKey = "my-custom-scope"
o.UseIdProvider<MyCustomIdProvider>();
o.UseIdForwarder<MyCustomIdForwarder>();
});
public class MyClass
{
private readonly IContextAccessor<CorrelationContext> _contextAccessor;
public MyClass(IContextAccessor<CorrelationContext> contextAccessor)
{
_contextAccessor = contextAccessor
}
public void MyMethod()
{
string correlationId = _contextAccessor.Context.CorrelationId;
}
}
A unique Trace ID is generated every time a message transits from service to another, unlike the Correlation ID which remains static for the lifetime of the process. This is helpful for tracing how the current process moves between services.
Example: ServiceA -> New ID -> ServiceB -> New ID -> ServiceC
public void ConfigureServices(IServiceCollection services)
{
// Adds Required Sercies and Configuration
services.AddTracing();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
// Enables Correlation Middleware
app.UseTracing();
}
services.AddTracing(o =>
{
// The default value is x-tracing-id
o.Key = "my-custom-key";
o.AttachToResponse = true;
o.IsRequired = true;
o.AttachToLoggingScope = false;
// The default value is tracing-id
o.LoggingScopeKey = "my-custom-scope"
o.UseIdProvider<MyCustomIdProvider>();
o.UseIdForwarder<MyCustomIdForwarder>();
});
public class MyClass
{
private readonly IContextAccessor<TraceContext> _contextAccessor;
public MyClass(IContextAccessor<TraceContext> contextAccessor)
{
_contextAccessor = contextAccessor
}
public void MyMethod()
{
string traceId = _contextAccessor.Context.TraceId;
}
}
It is also possible to change how a Controller or Method will handle an incoming request by using the following Attributes
When these attributes are present the Correlation or Trace ID will be attached to the response headers.
When these attributes are present if an incoming request does not contain the Correlation or Trace ID headers it will respond with 400 (BadRequest). This can be enabled API wide by settings the IsRequired
property to true when adding Correlation or Trace ID.
When these attributes are present the IsRequiredAttribute
or IsRequired
option are no longer enforced.
Below is an example of using the IsRequied and IsNotRequired attributes for the Correlation ID.
// All calls to this controller must have the Correlation ID header present in the incoming request.
[ApiController]
[CorrelationIdHeaderRequired]
public FooController: ControllerBase
{
// When this endpoint is called, the Correlation ID does not need to be present in the headers of the incoming request as we've used the Not Required attribute.
[HttpGet("{fooId}")]
[CorrelationIdHeaderNotRequired]
public IActionResult Get(string fooId)
{
}
// When this endpoint is called, the Correlation ID must be present in the headers of the incoming request as the controller has the Is Required attribute.
// It will also attach the Correlation ID to the headers of the Http Response.
[HttpPost]
[AttachCorrelationIdToResponseHeader]
public IActionResult Get(FooDto newFoo)
{
}
}
NOTE: This can also be done with the Trace ID.
Package | Downloads | NuGet |
---|---|---|
TraceLink.Abstractions | ||
TraceLink.AspNetCore | ||
TraceLink.NServiceBus |
Nuget Icon by Bernd Lakenbrink from Noun Project
FAQs
Package Description
We found that tracelink.aspnetcore demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.