forked from microsoft/PowerToys
-
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.
Preview pane telemetry (microsoft#1299)
* Added telemetry base class and markdown telemetry class * Updated docstring for telemetry event. * Added telemetry to markdown for error * Added try catch for markdown preview handler and display error bar * Updated markdown telemetry to make event names global variable * Updated parameter name to camel casing and telemetry event name naming. * Corrected assembbly version for svg renderer
- Loading branch information
1 parent
0360411
commit 7701c9e
Showing
8 changed files
with
193 additions
and
38 deletions.
There are no files selected for viewing
Binary file not shown.
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
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
71 changes: 71 additions & 0 deletions
71
src/modules/previewpane/MarkdownPreviewHandler/MarkdownTelemetry.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,71 @@ | ||
// Copyright (c) Microsoft Corporation | ||
// The Microsoft Corporation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.Diagnostics.Tracing; | ||
using PreviewHandlerCommon.Telemetry; | ||
|
||
namespace MarkdownPreviewHandler | ||
{ | ||
/// <summary> | ||
/// Telemetry helper class for markdown renderer. | ||
/// </summary> | ||
public class MarkdownTelemetry : TelemetryBase | ||
{ | ||
/// <summary> | ||
/// Name for ETW event. | ||
/// </summary> | ||
private const string EventSourceName = "Microsoft.PowerToys"; | ||
|
||
/// <summary> | ||
/// ETW event name when markdown is previewed. | ||
/// </summary> | ||
private const string MarkdownFilePreviewedEventName = "PowerPreview_MDRenderer_Previewed"; | ||
|
||
/// <summary> | ||
/// ETW event name when error is thrown during markdown preview. | ||
/// </summary> | ||
private const string MarkdownFilePreviewErrorEventName = "PowerPreview_MDRenderer_Error"; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="MarkdownTelemetry"/> class. | ||
/// </summary> | ||
public MarkdownTelemetry() | ||
: base(EventSourceName) | ||
{ | ||
return; | ||
} | ||
|
||
/// <summary> | ||
/// Gets an instance of the <see cref="MarkdownTelemetry"/> class. | ||
/// </summary> | ||
public static MarkdownTelemetry Log { get; } = new MarkdownTelemetry(); | ||
|
||
/// <summary> | ||
/// Publishes ETW event when markdown is previewed successfully. | ||
/// </summary> | ||
public void MarkdownFilePreviewed() | ||
{ | ||
this.Write(MarkdownFilePreviewedEventName, new EventSourceOptions() | ||
{ | ||
Keywords = ProjectKeywordMeasure, | ||
Tags = ProjectTelemetryTagProductAndServicePerformance, | ||
}); | ||
} | ||
|
||
/// <summary> | ||
/// Publishes ETW event when markdown could not be previewed. | ||
/// </summary> | ||
public void MarkdownFilePreviewError(string message) | ||
{ | ||
this.Write( | ||
MarkdownFilePreviewErrorEventName, | ||
new EventSourceOptions() | ||
{ | ||
Keywords = ProjectKeywordMeasure, | ||
Tags = ProjectTelemetryTagProductAndServicePerformance, | ||
}, | ||
new { Message = message, }); | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/modules/previewpane/MarkdownPreviewHandler/Properties/Resources.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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,44 @@ | ||
// Copyright (c) Microsoft Corporation | ||
// The Microsoft Corporation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.Diagnostics.Eventing.Reader; | ||
using System.Diagnostics.Tracing; | ||
|
||
namespace PreviewHandlerCommon.Telemetry | ||
{ | ||
/// <summary> | ||
/// Base class for telemetry events. | ||
/// </summary> | ||
public class TelemetryBase : EventSource | ||
{ | ||
/// <summary> | ||
/// The event tag for this event source. | ||
/// </summary> | ||
public const EventTags ProjectTelemetryTagProductAndServicePerformance = (EventTags)0x0u; | ||
|
||
/// <summary> | ||
/// The event keyword for this event source. | ||
/// </summary> | ||
public const EventKeywords ProjectKeywordMeasure = (EventKeywords)0x0; | ||
|
||
/// <summary> | ||
/// Group ID for Powertoys project. | ||
/// </summary> | ||
private static readonly string[] PowerToysTelemetryTraits = { "ETW_GROUP", "{42749043-438c-46a2-82be-c6cbeb192ff2}" }; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="TelemetryBase"/> class. | ||
/// </summary> | ||
/// <param name="eventSourceName">.</param> | ||
public TelemetryBase( | ||
string eventSourceName) | ||
: base( | ||
eventSourceName, | ||
EventSourceSettings.EtwSelfDescribingEventFormat, | ||
PowerToysTelemetryTraits) | ||
{ | ||
return; | ||
} | ||
} | ||
} |