Skip to content

Commit e08e4d1

Browse files
committed
Fix race condition in FunctionUsageMetricsAreCapturedByTelemetryAsExpected
1 parent 655ad37 commit e08e4d1

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

dotnet/src/Connectors/Connectors.AzureOpenAI.UnitTests/KernelCore/KernelTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Microsoft. All rights reserved.
22

33
using System;
4+
using System.Collections.Concurrent;
45
using System.Collections.Generic;
56
using System.Diagnostics.Metrics;
67
using System.Net.Http;
@@ -63,7 +64,7 @@ public async Task FunctionUsageMetricsAreCapturedByTelemetryAsExpected()
6364
using MeterListener listener = new();
6465
var isPublished = false;
6566

66-
var measurements = new Dictionary<string, List<long>>
67+
var measurements = new Dictionary<string, ConcurrentBag<long>>
6768
{
6869
["semantic_kernel.function.invocation.token_usage.prompt"] = [],
6970
["semantic_kernel.function.invocation.token_usage.completion"] = [],

dotnet/src/Connectors/Connectors.OpenAI.UnitTests/KernelCore/KernelTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Microsoft. All rights reserved.
22

33
using System;
4+
using System.Collections.Concurrent;
45
using System.Collections.Generic;
56
using System.Diagnostics.Metrics;
67
using System.Net.Http;
@@ -64,7 +65,7 @@ public async Task FunctionUsageMetricsAreCapturedByTelemetryAsExpected()
6465
using MeterListener listener = new();
6566
var isPublished = false;
6667

67-
var measurements = new Dictionary<string, List<long>>
68+
var measurements = new Dictionary<string, ConcurrentBag<long>>
6869
{
6970
["semantic_kernel.function.invocation.token_usage.prompt"] = [],
7071
["semantic_kernel.function.invocation.token_usage.completion"] = [],

0 commit comments

Comments
 (0)