-
Notifications
You must be signed in to change notification settings - Fork 319
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add possibility to send telemetry events by data collectors (#4622)
* Edge1 * Edge2 risky way * Send back events * Fixes * More * More * More * Fix all tests * More tests * More * More tests * Extend more * Extend more --------- Co-authored-by: Jakub Chocholowicz <jachocho@microsoft.com>
- Loading branch information
Showing
36 changed files
with
1,738 additions
and
123 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
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
1 change: 1 addition & 0 deletions
1
src/Microsoft.TestPlatform.CommunicationUtilities/PublicAPI/PublicAPI.Unshipped.txt
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
#nullable enable | ||
const Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel.MessageType.TelemetryEventMessage = "TestPlatform.TelemetryEvent" -> string! |
32 changes: 32 additions & 0 deletions
32
src/Microsoft.TestPlatform.CommunicationUtilities/TelemetryReporter.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,32 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; | ||
using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; | ||
using Microsoft.VisualStudio.TestPlatform.ObjectModel; | ||
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; | ||
|
||
namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; | ||
|
||
internal class TelemetryReporter : ITelemetryReporter | ||
{ | ||
private readonly IRequestData _requestData; | ||
private readonly ICommunicationManager _communicationManager; | ||
private readonly IDataSerializer _dataSerializer; | ||
|
||
public TelemetryReporter(IRequestData requestData, ICommunicationManager communicationManager, IDataSerializer dataSerializer) | ||
{ | ||
_requestData = requestData; | ||
_communicationManager = communicationManager; | ||
_dataSerializer = dataSerializer; | ||
} | ||
|
||
public void Report(TelemetryEvent telemetryEvent) | ||
{ | ||
if (_requestData.IsTelemetryOptedIn) | ||
{ | ||
string message = _dataSerializer.SerializePayload(MessageType.TelemetryEventMessage, telemetryEvent); | ||
_communicationManager.SendRawMessage(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
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
9 changes: 9 additions & 0 deletions
9
src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITelemetryEventsHandler.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,9 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; | ||
|
||
public interface ITelemetryEventsHandler | ||
{ | ||
void HandleTelemetryEvent(TelemetryEvent telemetryEvent); | ||
} |
15 changes: 15 additions & 0 deletions
15
src/Microsoft.TestPlatform.ObjectModel/ITelemetryInitializer.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,15 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; | ||
|
||
/// <summary> | ||
/// Interface for extensions that choose to send telemetry events | ||
/// </summary> | ||
public interface ITelemetryInitializer | ||
{ | ||
/// <summary> | ||
/// Initializes telemetry reporter | ||
/// </summary> | ||
void Initialize(ITelemetryReporter telemetryReporter); | ||
} |
15 changes: 15 additions & 0 deletions
15
src/Microsoft.TestPlatform.ObjectModel/ITelemetryReporter.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,15 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; | ||
|
||
/// <summary> | ||
/// Interface for extensions that choose to send telemetry events | ||
/// </summary> | ||
public interface ITelemetryReporter | ||
{ | ||
/// <summary> | ||
/// Pushes telemetry event into TP | ||
/// </summary> | ||
void Report(TelemetryEvent telemetryEvent); | ||
} |
10 changes: 10 additions & 0 deletions
10
src/Microsoft.TestPlatform.ObjectModel/PublicAPI/PublicAPI.Unshipped.txt
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 |
---|---|---|
@@ -1 +1,11 @@ | ||
#nullable enable | ||
Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.ITelemetryEventsHandler | ||
Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.ITelemetryEventsHandler.HandleTelemetryEvent(Microsoft.VisualStudio.TestPlatform.ObjectModel.TelemetryEvent! telemetryEvent) -> void | ||
Microsoft.VisualStudio.TestPlatform.ObjectModel.ITelemetryInitializer | ||
Microsoft.VisualStudio.TestPlatform.ObjectModel.ITelemetryInitializer.Initialize(Microsoft.VisualStudio.TestPlatform.ObjectModel.ITelemetryReporter! telemetryReporter) -> void | ||
Microsoft.VisualStudio.TestPlatform.ObjectModel.ITelemetryReporter | ||
Microsoft.VisualStudio.TestPlatform.ObjectModel.ITelemetryReporter.Report(Microsoft.VisualStudio.TestPlatform.ObjectModel.TelemetryEvent! telemetryEvent) -> void | ||
Microsoft.VisualStudio.TestPlatform.ObjectModel.TelemetryEvent | ||
Microsoft.VisualStudio.TestPlatform.ObjectModel.TelemetryEvent.Name.get -> string! | ||
Microsoft.VisualStudio.TestPlatform.ObjectModel.TelemetryEvent.Properties.get -> System.Collections.Generic.IDictionary<string!, object!>! | ||
Microsoft.VisualStudio.TestPlatform.ObjectModel.TelemetryEvent.TelemetryEvent(string! name, System.Collections.Generic.IDictionary<string!, object!>! properties) -> void |
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,33 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System.Collections.Generic; | ||
using System.Runtime.Serialization; | ||
|
||
namespace Microsoft.VisualStudio.TestPlatform.ObjectModel; | ||
|
||
public sealed class TelemetryEvent | ||
{ | ||
/// <summary> | ||
/// Initialize an TelemetryEvent | ||
/// </summary> | ||
/// <param name="name">Telemetry event name</param> | ||
/// <param name="properties">Telemetry event properties</param> | ||
public TelemetryEvent(string name, IDictionary<string, object> properties) | ||
{ | ||
Name = name; | ||
Properties = properties; | ||
} | ||
|
||
/// <summary> | ||
/// Telemetry event name. | ||
/// </summary> | ||
[DataMember] | ||
public string Name { get; private set; } | ||
|
||
/// <summary> | ||
/// Telemetry event properties. | ||
/// </summary> | ||
[DataMember] | ||
public IDictionary<string, object> Properties { get; private set; } | ||
} |
Oops, something went wrong.