Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sourabh1007 committed Mar 28, 2023
1 parent a013818 commit ac83b98
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@ internal static class OpenTelemetryRecorderFactory
/// <summary>
/// Singleton to make sure we only have one instance of the DiagnosticScopeFactory and pattern matching of listener happens only once
/// </summary>
private static Lazy<DiagnosticScopeFactory> ScopeFactory = new Lazy<DiagnosticScopeFactory>(() => new DiagnosticScopeFactory(clientNamespace: OpenTelemetryAttributeKeys.DiagnosticNamespace,
resourceProviderNamespace: OpenTelemetryAttributeKeys.ResourceProviderNamespace,
isActivityEnabled: true),
isThreadSafe: true);

private static DiagnosticScopeFactory ScopeFactory { get; set; }

public static OpenTelemetryCoreRecorder CreateRecorder(string operationName,
string containerName,
string databaseName,
Expand All @@ -29,11 +26,13 @@ public static OpenTelemetryCoreRecorder CreateRecorder(string operationName,
{
if (clientContext is { ClientOptions.IsDistributedTracingEnabled: true })
{
ActivityExtensions.ResetFeatureSwitch();
OpenTelemetryRecorderFactory.ScopeFactory ??= new DiagnosticScopeFactory(clientNamespace: OpenTelemetryAttributeKeys.DiagnosticNamespace,
resourceProviderNamespace: OpenTelemetryAttributeKeys.ResourceProviderNamespace,
isActivityEnabled: true);

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

Expand Down
Loading

0 comments on commit ac83b98

Please sign in to comment.