-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add telemetry for Svg preview handler (#1314)
* Added telemetry events for Svg Preview Handler * Added unit test in case preview handler throws * Updated the Error event name * Remove the not required return statement
- Loading branch information
Showing
6 changed files
with
140 additions
and
18 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
src/modules/previewpane/SvgPreviewHandler/Resource.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
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,70 @@ | ||
// 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 SvgPreviewHandler | ||
{ | ||
/// <summary> | ||
/// Telemetry helper class for Svg renderer. | ||
/// </summary> | ||
public class SvgTelemetry : TelemetryBase | ||
{ | ||
/// <summary> | ||
/// Name for ETW event. | ||
/// </summary> | ||
private const string EventSourceName = "Microsoft.PowerToys"; | ||
|
||
/// <summary> | ||
/// ETW event name when Svg is previewed. | ||
/// </summary> | ||
private const string SvgFilePreviewedEventName = "PowerPreview_SVGRenderer_Previewed"; | ||
|
||
/// <summary> | ||
/// ETW event name when error is thrown during Svg preview. | ||
/// </summary> | ||
private const string SvgFilePreviewErrorEventName = "PowerPreview_SVGRenderer_Error"; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="SvgTelemetry"/> class. | ||
/// </summary> | ||
public SvgTelemetry() | ||
: base(EventSourceName) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Gets an instance of the <see cref="SvgTelemetry"/> class. | ||
/// </summary> | ||
public static SvgTelemetry Log { get; } = new SvgTelemetry(); | ||
|
||
/// <summary> | ||
/// Publishes ETW event when svg is previewed successfully. | ||
/// </summary> | ||
public void SvgFilePreviewed() | ||
{ | ||
this.Write(SvgFilePreviewedEventName, new EventSourceOptions() | ||
{ | ||
Keywords = ProjectKeywordMeasure, | ||
Tags = ProjectTelemetryTagProductAndServicePerformance, | ||
}); | ||
} | ||
|
||
/// <summary> | ||
/// Publishes ETW event when svg could not be previewed. | ||
/// </summary> | ||
public void SvgFilePreviewError(string message) | ||
{ | ||
this.Write( | ||
SvgFilePreviewErrorEventName, | ||
new EventSourceOptions() | ||
{ | ||
Keywords = ProjectKeywordMeasure, | ||
Tags = ProjectTelemetryTagProductAndServicePerformance, | ||
}, | ||
new { Message = message, }); | ||
} | ||
} | ||
} |
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