-
Notifications
You must be signed in to change notification settings - Fork 339
Add possibility to send telemetry events by data collectors #4622
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f14cd20
Edge1
096a7f1
Edge2 risky way
169c936
Send back events
fe8c2b3
Fixes
9080351
More
5472fa9
More
d648577
More
69285ed
Fix all tests
9fd6109
More tests
ecc0471
More
b9b1d48
More tests
bd2b7ca
Extend more
e59ed11
Extend more
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a bit generic but underneath we don't have more than that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is API used by VS telemetry |
||
| { | ||
| 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should have an option object for future extensibility but maybe we can add to the
ITelemetryReporterself if neededThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think extending API for extensions is not issue anymore.