Small refactor to use common powertoys telemetry event source accross modules.

This commit is contained in:
ryanbodrug-microsoft
2020-05-05 09:23:31 -07:00
parent a9cc4dabb7
commit def0d7a519
15 changed files with 55 additions and 15 deletions

View File

@@ -0,0 +1,48 @@
// 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 Microsoft.PowerToys.Telemetry
{
/// <summary>
/// Telemetry helper class for PowerToys.
/// </summary>
public class PowerToysTelemetry : TelemetryBase
{
/// <summary>
/// Name for ETW event.
/// </summary>
private const string EventSourceName = "Microsoft.PowerToys";
/// <summary>
/// Initializes a new instance of the <see cref="PowerToysTelemetry"/> class.
/// </summary>
public PowerToysTelemetry()
: base(EventSourceName)
{
}
/// <summary>
/// Gets an instance of the <see cref="PowerLauncherTelemetry"/> class.
/// </summary>
public static PowerToysTelemetry Log = new PowerToysTelemetry();
/// <summary>
/// Publishes ETW event when an action is triggered on
/// </summary>
public void WriteEvent<T>(T telemetryEvent)
where T : IEvent
{
this.Write<T>(telemetryEvent.EventName, new EventSourceOptions()
{
Keywords = ProjectKeywordMeasure,
Tags = ProjectTelemetryTagProductAndServicePerformance,
},
telemetryEvent);
}
}
}