Skip to content

Commit ac83b98

Browse files
committed
fix tests
1 parent a013818 commit ac83b98

File tree

3 files changed

+84
-63
lines changed

3 files changed

+84
-63
lines changed

Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/OpenTelemetryRecorderFactory.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,8 @@ internal static class OpenTelemetryRecorderFactory
1515
/// <summary>
1616
/// Singleton to make sure we only have one instance of the DiagnosticScopeFactory and pattern matching of listener happens only once
1717
/// </summary>
18-
private static Lazy<DiagnosticScopeFactory> ScopeFactory = new Lazy<DiagnosticScopeFactory>(() => new DiagnosticScopeFactory(clientNamespace: OpenTelemetryAttributeKeys.DiagnosticNamespace,
19-
resourceProviderNamespace: OpenTelemetryAttributeKeys.ResourceProviderNamespace,
20-
isActivityEnabled: true),
21-
isThreadSafe: true);
22-
18+
private static DiagnosticScopeFactory ScopeFactory { get; set; }
19+
2320
public static OpenTelemetryCoreRecorder CreateRecorder(string operationName,
2421
string containerName,
2522
string databaseName,
@@ -29,11 +26,13 @@ public static OpenTelemetryCoreRecorder CreateRecorder(string operationName,
2926
{
3027
if (clientContext is { ClientOptions.IsDistributedTracingEnabled: true })
3128
{
32-
ActivityExtensions.ResetFeatureSwitch();
29+
OpenTelemetryRecorderFactory.ScopeFactory ??= new DiagnosticScopeFactory(clientNamespace: OpenTelemetryAttributeKeys.DiagnosticNamespace,
30+
resourceProviderNamespace: OpenTelemetryAttributeKeys.ResourceProviderNamespace,
31+
isActivityEnabled: true);
3332

3433
// If there is no source then it will return default otherwise a valid diagnostic scope
3534
DiagnosticScope scope = OpenTelemetryRecorderFactory
36-
.ScopeFactory.Value
35+
.ScopeFactory
3736
.CreateScope(name: $"{OpenTelemetryAttributeKeys.OperationPrefix}.{operationName}",
3837
kind: clientContext.ClientOptions.ConnectionMode == ConnectionMode.Gateway ? DiagnosticScope.ActivityKind.Internal : DiagnosticScope.ActivityKind.Client);
3938

0 commit comments

Comments
 (0)