Skip to content

Commit fa86f23

Browse files
committed
ci tests log issue
1 parent a7a4c4f commit fa86f23

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

src/KeeperData.Infrastructure/Telemetry/EmfExporter.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ static void OnMeasurementRecorded<T>(
6363
ReadOnlySpan<KeyValuePair<string, object?>> tags,
6464
object? state)
6565
{
66+
var currentLog = log;
67+
6668
try
6769
{
6870
var value = Convert.ToDouble(measurement);
@@ -86,12 +88,12 @@ static void OnMeasurementRecorded<T>(
8688
if (currentClient != null)
8789
{
8890
var standardUnit = instrument.Unit == "ea" ? StandardUnit.Count : StandardUnit.Milliseconds;
89-
PushLocalStackMetric(currentClient, name, value, standardUnit, safeTags);
91+
PushLocalStackMetric(currentClient, currentLog, name, value, standardUnit, safeTags);
9092
}
9193
}
9294
catch (Exception e)
9395
{
94-
log.LogError(e, "Failed to process metric measurement");
96+
currentLog?.LogError(e, "Failed to process metric measurement");
9597
}
9698
}
9799

@@ -117,7 +119,7 @@ private static void PushEmfMetric(string name, double value, Unit unit, Dictiona
117119
}
118120

119121
// Pass the specific client explicitly
120-
private static void PushLocalStackMetric(IAmazonCloudWatch cloudWatchClient, string name, double value, StandardUnit unit, Dictionary<string, string> safeTags)
122+
private static void PushLocalStackMetric(IAmazonCloudWatch cloudWatchClient, ILogger currentLog, string name, double value, StandardUnit unit, Dictionary<string, string> safeTags)
121123
{
122124
var dimensions = safeTags.Select(t => new Dimension { Name = t.Key, Value = t.Value }).ToList();
123125

@@ -144,12 +146,12 @@ private static void PushLocalStackMetric(IAmazonCloudWatch cloudWatchClient, str
144146
var response = await cloudWatchClient.PutMetricDataAsync(request);
145147
if ((int)response.HttpStatusCode >= 400)
146148
{
147-
log?.LogWarning("LocalStack CloudWatch rejected metric. Status: {Status}", response.HttpStatusCode);
149+
currentLog?.LogWarning("LocalStack CloudWatch rejected metric. Status: {Status}", response.HttpStatusCode);
148150
}
149151
}
150152
catch (Exception ex)
151153
{
152-
log?.LogError(ex, "Failed to push metric to LocalStack CloudWatch");
154+
currentLog?.LogError(ex, "Failed to push metric to LocalStack CloudWatch");
153155
}
154156
});
155157
}

0 commit comments

Comments
 (0)