Skip to content

Commit

Permalink
SendAsync override for ConsulMetricsHttpClientWrapper.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
muphblu committed Nov 15, 2023
1 parent 6cf118d commit ada23f8
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions ATI.Services.Consul/ConsulMetricsHttpClientWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,37 @@ public Task<OperationResult<string>> PatchAsync(

#endregion

#region Send

public async Task<OperationResult<HttpResponseMessage<TResponse>>> SendAsync<TBody, TResponse>(
HttpMethod methodName,
string url,
TBody body,
string metricName,
Dictionary<string, string> headers = null,
string urlTemplate = null,
string[] additionalLabels = null)
{
using var _ =
_metricsTracingFactory.CreateLoggingMetricsTimer(metricName,
$"{methodName}:{urlTemplate ?? url}",
additionalLabels);
{
try
{
var serviceAddress = await _serviceAddress.ToHttpAsync();
return await _clientWrapper.SendAsync<TBody, TResponse>(new Uri(new Uri(serviceAddress),url), metricName, body, headers, methodName);
}
catch (Exception e)
{
_logger.LogWithObject(_serviceOptions.LogLevelOverride(LogLevel.Error), e);
return new(ActionStatus.InternalServerError);
}
}
}

#endregion

private async Task<OperationResult<T>> SendAsync<T>(string url,
string urlTemplate,
string metricName,
Expand Down

0 comments on commit ada23f8

Please sign in to comment.