mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 03:07:04 +02:00
Merge branch 'dev/build-features' into merge/build-features-to-master-05062020
This commit is contained in:
47
src/common/ManagedTelemetry/Telemetry/PowerToysTelemetry.cs
Normal file
47
src/common/ManagedTelemetry/Telemetry/PowerToysTelemetry.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
// 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)
|
||||
{
|
||||
this.Write<T>(null, new EventSourceOptions()
|
||||
{
|
||||
Keywords = ProjectKeywordMeasure,
|
||||
Tags = ProjectTelemetryTagProductAndServicePerformance,
|
||||
},
|
||||
telemetryEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
src/common/ManagedTelemetry/Telemetry/Telemetry.csproj
Normal file
11
src/common/ManagedTelemetry/Telemetry/Telemetry.csproj
Normal file
@@ -0,0 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\..\Telemetry\TelemetryBase.cs" Link="TelemetryBase.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
43
src/common/Telemetry/TelemetryBase.cs
Normal file
43
src/common/Telemetry/TelemetryBase.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
// 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;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user