Skip to content
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

Addional logs in case of failure. #10726

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
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 @@ -207,6 +207,12 @@ public async Task<IEnumerable<Type>> GetExtensionsStartupTypesAsync()
if (extensionType == null)
{
_logger.ScriptStartUpUnableToLoadExtension(startupExtensionName, extensionItem.TypeName);

// Log an error if the extension is not loaded and the extension is not a built-in extension, not modifying the existing log.
_logger.ScriptStartUpUnableToLoadExtensionError(startupExtensionName, extensionItem.TypeName);

string message = $"The extension '{startupExtensionName}' (Type: '{extensionItem.TypeName}') failed to load. Triggers associated with this extension will not function, though other triggers may still work. This issue suggests that your deployment package was built incorrectly.";
DiagnosticEventLoggerExtensions.LogDiagnosticEventError(_logger, DiagnosticEventConstants.ExtensionsStartupTypesErrorCode, message, DiagnosticEventConstants.ExtensionsStartupTypesHelpLink, new Exception(message));
continue;
}

Expand Down
3 changes: 3 additions & 0 deletions src/WebJobs.Script/Diagnostics/DiagnosticEventConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,8 @@ internal static class DiagnosticEventConstants

public const string WorkerRuntimeDoesNotMatchWithFunctionMetadataErrorCode = "AZFD0013";
public const string WorkerRuntimeDoesNotMatchWithFunctionMetadataHelpLink = "https://aka.ms/functions-invalid-worker-runtime";

public const string ExtensionsStartupTypesErrorCode = "AZFD0014";
public const string ExtensionsStartupTypesHelpLink = "https://aka.ms/functions-deployment-technologies";
}
}
12 changes: 11 additions & 1 deletion src/WebJobs.Script/Diagnostics/Extensions/LoggerExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ internal static class LoggerExtension
LoggerMessage.Define<string, string>(LogLevel.Warning,
new EventId(306, nameof(ScriptStartUpUnableToLoadExtension)),
"Unable to load startup extension '{startupExtensionName}' (Type: '{typeName}'). The type does not exist. Please validate the type and assembly names.");

private static readonly Action<ILogger, string, string, string, Exception> _scriptStartUpTypeIsNotValid =
LoggerMessage.Define<string, string, string>(LogLevel.Warning,
new EventId(307, nameof(ScriptStartUpTypeIsNotValid)),
Expand Down Expand Up @@ -193,6 +193,11 @@ internal static class LoggerExtension
new EventId(339, nameof(NoHostJsonFile)),
"No functions were found. This can occur before you deploy code to your function app or when the host.json file is missing from the most recent deployment. Make sure that your deployment package includes the host.json file in the root of the package. For deployment package requirements, see https://aka.ms/functions-deployment-technologies.");

private static readonly Action<ILogger, string, string, Exception> _scriptStartUpUnableToLoadExtensionError =
LoggerMessage.Define<string, string>(LogLevel.Error,
new EventId(340, nameof(ScriptStartUpUnableToLoadExtensionError)),
"The extension '{startupExtensionName}' (Type: '{typeName}') failed to load. Triggers associated with this extension will not function, though other triggers may still work. This issue suggests that your deployment package was built incorrectly. For deployment package requirements, see https://aka.ms/functions-deployment-technologies.");

private static readonly Action<ILogger, string, Exception> _publishingMetrics =
LoggerMessage.Define<string>(LogLevel.Debug, new EventId(338, nameof(PublishingMetrics)), "{metrics}");

Expand Down Expand Up @@ -251,6 +256,11 @@ public static void ScriptStartUpUnableToLoadExtension(this ILogger logger, strin
_scriptStartUpUnableToLoadExtension(logger, startupExtensionName, typeName, null);
}

public static void ScriptStartUpUnableToLoadExtensionError(this ILogger logger, string startupExtensionName, string typeName)
{
_scriptStartUpUnableToLoadExtensionError(logger, startupExtensionName, typeName, null);
}

public static void ScriptStartUpTypeIsNotValid(this ILogger logger, string typeName, string startupClassName, string startupConfigurationClassName)
{
_scriptStartUpTypeIsNotValid(logger, typeName, startupClassName, startupConfigurationClassName, null);
Expand Down
Loading