mayuki / Rin

Request/response Inspector middleware for ASP.NET Core
MIT License
650 stars 24 forks source link

Add support for HttpClient #20

Open Nikey646 opened 5 years ago

Nikey646 commented 5 years ago

It would be nice to be able to track requests made by a HttpClient as well.

This could be implemented via an DelegatingHandler.

s-tarasov commented 1 year ago

Handlers could be globally configured via IHttpMessageHandlerBuilderFilter

JanEggers commented 10 months ago

for anyone searching until its in the box you can use this

public class RinHttpHandler : DelegatingHandler
{
    protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
    {
        using var scope = TimelineScope.Create("Http", TimelineEventCategory.Data, request.RequestUri?.AbsoluteUri);
        try
        {
            return await base.SendAsync(request, cancellationToken);
        }
        finally
        {
            scope.Complete();
        }
    }
}