-
Notifications
You must be signed in to change notification settings - Fork 457
Logging improvements to DiagnosticEventTableStorageRepository #10996
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
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5891f6c
Moving logging to defined methods in DiagnosticEventsTableStorageRepo…
cjaliaga 0070a74
Disable service when we fail to write events due to permissions.
cjaliaga da29f9b
Added test for permissions via using AzuriteFixture
cjaliaga 830ab0a
Improved messages and disabled the service in more cases
cjaliaga f4aebe6
Cleanup comments
cjaliaga 34ed87e
Deleting test table to verify delete tables permission.
cjaliaga 8705f52
PR feedback
cjaliaga e3bb451
Add release notes
cjaliaga 56f9fe7
Merge branch 'dev' into cjaliaga/diagnotic-events-10757
cjaliaga File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
src/WebJobs.Script.WebHost/Diagnostics/DiagnosticEventTableStorageRepository.Log.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics | ||
{ | ||
public partial class DiagnosticEventTableStorageRepository | ||
{ | ||
private static class Logger | ||
{ | ||
private static readonly Action<ILogger, Exception> _serviceDisabledFailedToCreateClient = | ||
LoggerMessage.Define( | ||
LogLevel.Warning, | ||
new EventId(1, nameof(ServiceDisabledFailedToCreateClient)), | ||
"We couldn’t initialize the Table Storage Client using the 'AzureWebJobsStorage' connection string. We are unable to record diagnostic events, so the diagnostic logging service is being stopped. Please check the 'AzureWebJobsStorage' connection string in Application Settings."); | ||
|
||
private static readonly Action<ILogger, Exception> _serviceDisabledUnauthorizedClient = | ||
LoggerMessage.Define( | ||
LogLevel.Warning, | ||
new EventId(2, nameof(ServiceDisabledUnauthorizedClient)), | ||
"We couldn’t access the Table service in the Azure Storage account defined by the 'AzureWebJobsStorage' setting. We are unable to record diagnostic events, so the diagnostic logging service is being stopped. Please ensure the connection string or managed identity has permissions to access the Table service and that any network rules allow connectivity. If you're using an identity-based connection, make sure it has been assigned the 'Storage Table Data Contributor' role."); | ||
|
||
private static readonly Action<ILogger, Exception> _serviceDisabledUnableToConnectToStorage = | ||
LoggerMessage.Define( | ||
LogLevel.Warning, | ||
new EventId(3, nameof(ServiceDisabledUnableToConnectToStorage)), | ||
"We couldn’t reach the Table service endpoint specified in the 'AzureWebJobsStorage' setting. We are unable to record diagnostic events, so the diagnostic logging service is being stopped. Please confirm network connectivity and endpoint accessibility."); | ||
|
||
private static readonly Action<ILogger, string, Exception> _purgingDiagnosticEvents = | ||
LoggerMessage.Define<string>(LogLevel.Debug, new EventId(4, nameof(PurgingDiagnosticEvents)), "Purging diagnostic events with versions older than '{currentEventVersion}'."); | ||
|
||
private static readonly Action<ILogger, string, Exception> _deletingTableWithoutEventVersion = | ||
LoggerMessage.Define<string>(LogLevel.Debug, new EventId(5, nameof(DeletingTableWithoutEventVersion)), "Deleting table '{tableName}' as it contains records without an EventVersion."); | ||
|
||
private static readonly Action<ILogger, string, Exception> _deletingTableWithOutdatedEventVersion = | ||
LoggerMessage.Define<string>(LogLevel.Debug, new EventId(6, nameof(DeletingTableWithOutdatedEventVersion)), "Deleting table '{tableName}' as it contains records with an outdated EventVersion."); | ||
|
||
private static readonly Action<ILogger, Exception> _errorPurgingDiagnosticEventVersions = | ||
LoggerMessage.Define(LogLevel.Error, new EventId(7, nameof(ErrorPurgingDiagnosticEventVersions)), "Error occurred when attempting to purge previous diagnostic event versions."); | ||
|
||
private static readonly Action<ILogger, Exception> _unableToGetTableReference = | ||
LoggerMessage.Define(LogLevel.Error, new EventId(8, nameof(UnableToGetTableReference)), "Unable to get table reference. Aborting write operation."); | ||
|
||
private static readonly Action<ILogger, Exception> _unableToGetTableReferenceOrCreateTable = | ||
LoggerMessage.Define(LogLevel.Error, new EventId(9, nameof(UnableToGetTableReferenceOrCreateTable)), "Unable to get table reference or create table. Aborting write operation."); | ||
|
||
private static readonly Action<ILogger, Exception> _unableToWriteDiagnosticEvents = | ||
LoggerMessage.Define(LogLevel.Error, new EventId(10, nameof(UnableToWriteDiagnosticEvents)), "Unable to write diagnostic events to table storage."); | ||
|
||
private static readonly Action<ILogger, Exception> _primaryHostStateProviderNotAvailable = | ||
LoggerMessage.Define(LogLevel.Debug, new EventId(11, nameof(PrimaryHostStateProviderNotAvailable)), "PrimaryHostStateProvider is not available. Skipping the check for primary host."); | ||
|
||
private static readonly Action<ILogger, Exception> _stoppingFlushLogsTimer = | ||
LoggerMessage.Define(LogLevel.Information, new EventId(12, nameof(StoppingFlushLogsTimer)), "Stopping the flush logs timer."); | ||
|
||
private static readonly Action<ILogger, Exception> _queueingBackgroundTablePurge = | ||
LoggerMessage.Define(LogLevel.Debug, new EventId(13, nameof(QueueingBackgroundTablePurge)), "Queueing background table purge."); | ||
|
||
public static void ServiceDisabledFailedToCreateClient(ILogger logger) => _serviceDisabledFailedToCreateClient(logger, null); | ||
|
||
public static void ServiceDisabledUnauthorizedClient(ILogger logger, Exception exception) => _serviceDisabledUnauthorizedClient(logger, exception); | ||
|
||
public static void ServiceDisabledUnableToConnectToStorage(ILogger logger, Exception exception) => _serviceDisabledUnableToConnectToStorage(logger, exception); | ||
|
||
public static void PurgingDiagnosticEvents(ILogger logger, string currentEventVersion) => _purgingDiagnosticEvents(logger, currentEventVersion, null); | ||
|
||
public static void DeletingTableWithoutEventVersion(ILogger logger, string tableName) => _deletingTableWithoutEventVersion(logger, tableName, null); | ||
|
||
public static void DeletingTableWithOutdatedEventVersion(ILogger logger, string tableName) => _deletingTableWithOutdatedEventVersion(logger, tableName, null); | ||
|
||
public static void ErrorPurgingDiagnosticEventVersions(ILogger<DiagnosticEventTableStorageRepository> logger, Exception exception) => _errorPurgingDiagnosticEventVersions(logger, exception); | ||
|
||
public static void UnableToGetTableReference(ILogger logger) => _unableToGetTableReference(logger, null); | ||
|
||
public static void UnableToGetTableReferenceOrCreateTable(ILogger logger, Exception exception) => _unableToGetTableReferenceOrCreateTable(logger, exception); | ||
|
||
public static void UnableToWriteDiagnosticEvents(ILogger logger, Exception exception) => _unableToWriteDiagnosticEvents(logger, exception); | ||
|
||
public static void PrimaryHostStateProviderNotAvailable(ILogger logger) => _primaryHostStateProviderNotAvailable(logger, null); | ||
|
||
public static void StoppingFlushLogsTimer(ILogger logger) => _stoppingFlushLogsTimer(logger, null); | ||
|
||
public static void QueueingBackgroundTablePurge(ILogger logger) => _queueingBackgroundTablePurge(logger, null); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.