Open sandboxFocus

Interface ICorrelationProtocol

Defines the semantics of the request correlation protocol in distributed logging. The protocol adds headers to outgoing requests and interprets headers in incoming requests.

Namespace: PostSharp.Patterns.Diagnostics.Correlation
Assembly: PostSharp.Patterns.Diagnostics.dll
Syntax
public interface ICorrelationProtocol
Remarks

The only available implementation is LegacyHttpCorrelationProtocol. You can also implement the interface, either from scratch or by calling an existing implementation in a chain of responsibility.

Pass an implementation to the instrumentation of ASP.NET, ASP.NET Core or HttpClient to correlate the log records of the client and of the server of a request. Use the same protocol on both sides.

The headers of an incoming request cannot be trusted before the request is authenticated. On a public service, filter the requests whose headers are processed, for instance by wrapping an existing implementation with your own security checks.

Methods

Name Description
GetIncomingRequestOptions(in CorrelationRequest)

Gets the IncomingRequestOptions for an incoming request.

ProcessIncomingRequest(in CorrelationRequest, ref OpenActivityOptions)

Processes an incoming request. The implementation must read the request headers and alter the OpenActivityOptions accordingly. This method is invoked only if the incoming request will be logged.

ProcessOutgoingRequest(LoggingContext, in CorrelationRequest, ref OpenActivityOptions)

Processes an outgoing request. The implementation must add the correlation headers to the request and can alter the OpenActivityOptions of the activity that represents the request.

See Also