Skip to content

Merge main to preview #578

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ internal class AzureAppConfigurationProvider : ConfigurationProvider, IConfigura
{
private bool _optional;
private bool _isInitialLoadComplete = false;
private bool _isFeatureManagementVersionInspected;
private bool _isAssemblyInspected;
private readonly bool _requestTracingEnabled;
private readonly IConfigurationClientManager _configClientManager;
private Uri _lastSuccessfulEndpoint;
Expand Down Expand Up @@ -190,7 +190,7 @@ public async Task RefreshAsync(CancellationToken cancellationToken)
try
{
// FeatureManagement assemblies may not be loaded on provider startup, so version information is gathered upon first refresh for tracing
EnsureFeatureManagementVersionInspected();
EnsureAssemblyInspected();

var utcNow = DateTimeOffset.UtcNow;
IEnumerable<KeyValueWatcher> refreshableWatchers = _options.ChangeWatchers.Where(changeWatcher => utcNow >= changeWatcher.NextRefreshTime);
Expand Down Expand Up @@ -1214,17 +1214,22 @@ private IEnumerable<ConfigurationSetting> GetCurrentKeyValueCollection(string ke
return currentKeyValues;
}

private void EnsureFeatureManagementVersionInspected()
private void EnsureAssemblyInspected()
{
if (!_isFeatureManagementVersionInspected)
if (!_isAssemblyInspected)
{
_isFeatureManagementVersionInspected = true;
_isAssemblyInspected = true;

if (_requestTracingEnabled && _requestTracingOptions != null)
{
_requestTracingOptions.FeatureManagementVersion = TracingUtils.GetAssemblyVersion(RequestTracingConstants.FeatureManagementAssemblyName);

_requestTracingOptions.FeatureManagementAspNetCoreVersion = TracingUtils.GetAssemblyVersion(RequestTracingConstants.FeatureManagementAspNetCoreAssemblyName);

if (TracingUtils.GetAssemblyVersion(RequestTracingConstants.SignalRAssemblyName) != null)
{
_requestTracingOptions.IsSignalRUsed = true;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ internal class RequestTracingConstants
public const string FeatureFlagMaxVariantsKey = "MaxVariants";
public const string FeatureFlagUsesVariantConfigurationReferenceTag = "ConfigRef";
public const string FeatureFlagFeaturesKey = "FFFeatures";
public const string SignalRUsedTag = "UsesSignalR";

public const string DiagnosticHeaderActivityName = "Azure.CustomDiagnosticHeaders";
public const string CorrelationContextHeader = "Correlation-Context";
public const string UserAgentHeader = "User-Agent";

public const string FeatureManagementAssemblyName = "Microsoft.FeatureManagement";
public const string FeatureManagementAspNetCoreAssemblyName = "Microsoft.FeatureManagement.AspNetCore";
public const string SignalRAssemblyName = "Microsoft.AspNetCore.SignalR";

public const string Delimiter = "+";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<ItemGroup>
<PackageReference Include="Azure.Data.AppConfiguration" Version="1.4.1" />
<PackageReference Include="Azure.Messaging.EventGrid" Version="4.7.0" />
<PackageReference Include="Azure.Security.KeyVault.Secrets" Version="4.3.0" />
<PackageReference Include="Azure.Security.KeyVault.Secrets" Version="4.6.0" />
<PackageReference Include="DnsClient" Version="1.7.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,10 @@ internal class RequestTracingOptions
/// Version of the Microsoft.FeatureManagement.AspNetCore assembly, if present in the application.
/// </summary>
public string FeatureManagementAspNetCoreVersion { get; set; }

/// <summary>
/// Flag to indicate whether Microsoft.AspNetCore.SignalR assembly is present in the application.
/// </summary>
public bool IsSignalRUsed { get; set; } = false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@ private static string CreateCorrelationContextHeader(RequestType requestType, Re
correlationContextTags.Add(RequestTracingConstants.KeyVaultRefreshConfiguredTag);
}

if (requestTracingOptions.IsSignalRUsed)
{
correlationContextTags.Add(RequestTracingConstants.SignalRUsedTag);
}

var sb = new StringBuilder();

foreach (KeyValuePair<string,string> kvp in correlationContextKeyValues)
Expand Down