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 046efc5 commit de4cd7b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
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
1 change: 0 additions & 1 deletion ATI.Services.Consul/ConsulServiceAddress.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using ATI.Services.Common.Behaviors;
using ATI.Services.Common.Extensions;
using Consul;
using NLog;
Expand Down

0 comments on commit de4cd7b

Please sign in to comment.