forked from Azure/azure-sdk-for-net
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add EventSource for CertificateOperation
Added more logging to better diagnose how Azure#17718 is happening.
- Loading branch information
Showing
5 changed files
with
417 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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
37 changes: 37 additions & 0 deletions
37
sdk/keyvault/Azure.Security.KeyVault.Certificates/src/CertificatesEventSource.cs
This file contains 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,37 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System.Diagnostics.Tracing; | ||
using Azure.Core.Diagnostics; | ||
|
||
namespace Azure.Security.KeyVault.Certificates | ||
{ | ||
[EventSource(Name = EventSourceName)] | ||
internal sealed class CertificatesEventSource : EventSource | ||
{ | ||
internal const int BeginUpdateStatusEvent = 1; | ||
internal const int EndUpdateStatusEvent = 2; | ||
|
||
private const string EventSourceName = "Azure-Security-KeyVault-Certificates"; | ||
private const string Deleted = "(deleted)"; | ||
private const string NoError = "(none)"; | ||
|
||
private CertificatesEventSource() : base(EventSourceName, EventSourceSettings.Default, AzureEventSourceListener.TraitName, AzureEventSourceListener.TraitValue) { } | ||
|
||
public static CertificatesEventSource Singleton { get; } = new CertificatesEventSource(); | ||
|
||
[NonEvent] | ||
public void BeginUpdateStatus(CertificateOperationProperties properties) => | ||
BeginUpdateStatus(properties?.Id.ToString(), properties?.Status, properties?.Error?.Message); | ||
|
||
[Event(BeginUpdateStatusEvent, Level = EventLevel.Verbose, Message = "Updating certificate operation status: {0}, current status: {1}, error: {2}")] | ||
public void BeginUpdateStatus(string id, string status, string error) => WriteEvent(BeginUpdateStatusEvent, id ?? Deleted, status, error ?? NoError); | ||
|
||
[NonEvent] | ||
public void EndUpdateStatus(CertificateOperationProperties properties, double elapsed) => | ||
EndUpdateStatus(properties?.Id.ToString(), properties?.Status, properties?.Error?.Message, elapsed); | ||
|
||
[Event(EndUpdateStatusEvent, Level = EventLevel.Verbose, Message = "Updated certificate operation status: {0}, ending status: {1}, error: {2}, elapsed: {3:00.0}s")] | ||
public void EndUpdateStatus(string id, string status, string error, double elapsed) => WriteEvent(EndUpdateStatusEvent, id ?? Deleted, status, error ?? NoError, elapsed); | ||
} | ||
} |
This file contains 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.