Skip to content

Commit

Permalink
Update Azure Function context
Browse files Browse the repository at this point in the history
  • Loading branch information
rfavreau committed Apr 1, 2024
1 parent 1c29919 commit bde44c9
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal AzureFunctionsContext(string loggerScopeName)
{
Logger = Agent.Instance.Logger.Scoped(loggerScopeName);
MetaData = AzureFunctionsMetadataProvider.GetAzureFunctionsMetaData(Logger);
UpdateServiceInformation(Agent.Instance.Service);
UpdateServiceInformation(Agent.Instance.Service, Agent.Instance.Configuration.OverwriteDiscoverDefaultServiceName);
FaasIdPrefix =
$"/subscriptions/{MetaData.SubscriptionId}/resourceGroups/{MetaData.WebsiteResourceGroup}/providers/Microsoft.Web/sites/{MetaData.WebsiteSiteName}/functions/";
Logger.Trace()?.Log("FaasIdPrefix: {FaasIdPrefix}", FaasIdPrefix);
Expand All @@ -32,15 +32,15 @@ internal AzureFunctionsContext(string loggerScopeName)

internal static bool IsColdStart() => Interlocked.Exchange(ref ColdStart, 0) == 1;

private void UpdateServiceInformation(Service? service)
private void UpdateServiceInformation(Service? service, bool overwriteDiscoverDefaultServiceName)
{
if (service == null)
{
Logger.Warning()?.Log($"{nameof(UpdateServiceInformation)}: service is null");
return;
}

if (service.Name == AbstractConfigurationReader.AdaptServiceName(AbstractConfigurationReader.DiscoverDefaultServiceName()))
if (overwriteDiscoverDefaultServiceName && service.Name == AbstractConfigurationReader.AdaptServiceName(AbstractConfigurationReader.DiscoverDefaultServiceName()))
{
// Only override the service name if it was set to default.
service.Name = MetaData.WebsiteSiteName;
Expand Down

0 comments on commit bde44c9

Please sign in to comment.