Skip to content

Commit

Permalink
Added second constructor to InsightsMessageHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
dhindrik committed Oct 3, 2024
1 parent bfa039f commit e01db9d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions TinyInsights/InsightsMessageHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ public InsightsMessageHandler(IInsights insights)
InnerHandler = new HttpClientHandler();
}

public InsightsMessageHandler(IInsights insights, DelegatingHandler? innerHandler)
{
this.insights = insights;

if (innerHandler is not null)
{
InnerHandler = innerHandler;
}
}

protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
var startTime = DateTime.Now;
Expand All @@ -27,7 +37,7 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
{
response.EnsureSuccessStatusCode();
}
catch(Exception e)
catch (Exception e)
{
exception = e;
}
Expand All @@ -45,7 +55,7 @@ await insights.TrackDependencyAsync(

return response;
}
catch(Exception ex)
catch (Exception ex)
{
var endTime = DateTime.Now;
await insights.TrackDependencyAsync(
Expand Down

0 comments on commit e01db9d

Please sign in to comment.