-
Notifications
You must be signed in to change notification settings - Fork 127
Adds telemetry pipeline #259
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 19 commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
1f0644d
Adds telemetry pipeline. Adds evaluationevent, publisher interface, a…
rossgrambo 614e9af
Use await insead of .result
rossgrambo 4db49a3
Reverting unused dependency removal
rossgrambo 75cab57
Update src/Microsoft.FeatureManagement/FeatureDefinition.cs
rossgrambo f8e4f7b
Update src/Microsoft.FeatureManagement/FeatureDefinition.cs
rossgrambo 7c77718
Update src/Microsoft.FeatureManagement.AppInsightsTelemetryPublisher/…
rossgrambo 52930c0
Removed factory pattern for publisher DI
rossgrambo cb18586
Update src/Microsoft.FeatureManagement/FeatureManager.cs
rossgrambo 121ca35
Resolve misc. comments
rossgrambo 20b5f82
Merge branch 'rossgrambo/telemetry' of https://github.com/microsoft/F…
rossgrambo e025642
Adjusts descriptions for FeatureDefinition properties
rossgrambo 8ad67b7
Rename AppInsights to ApplicationInsights
rossgrambo fce7274
Resolves project reference in sln
rossgrambo d23357c
Adjusts ServiceCollectionExtensions to use TryAddSingleton
rossgrambo e43e114
Removes langversion from .csproj
rossgrambo 93a88a3
Temp
rossgrambo ba22ed1
Adds explicit null checkts before publishing fields to app insights
rossgrambo 0b5bea4
Addressing misc. comments
rossgrambo 2bfcbc8
Removing project reference for example project
rossgrambo 6cf2ee6
Merge with preview
rossgrambo 5b1842f
Syncing telemetry and variants
rossgrambo ecc898d
Adds null check for feature definitions
rossgrambo 39dd606
Adjusted TelemetryPublishers to no longer be inserted into DI
rossgrambo 9cf586a
Resolving comments
rossgrambo 78d3ba2
Removing Application Insights project
rossgrambo ac3630c
Converts some variables to inline
rossgrambo 0388134
Resolving misc. comments
rossgrambo 2ff83ac
Moves AddTelemetryPublisher to be an extension method
rossgrambo 4a5b135
Removing IVariantFeatureManager GetFeatureNamesAsync definition, as i…
rossgrambo b6e8df0
Remove unused dependency
rossgrambo f70513f
Resolving comments
rossgrambo bf151ac
Remove invisible character changes
rossgrambo edbb8d5
Remove Dependency Injection package
rossgrambo e94ad7f
Update src/Microsoft.FeatureManagement/FeatureManagerSnapshot.cs
rossgrambo 8b0f3ba
Update src/Microsoft.FeatureManagement/IVariantFeatureManager.cs
rossgrambo 5df39c8
Persists cancellation token to PublishEvent and adds null check for n…
rossgrambo 982f313
Adds TargetingContext to the EvaluationResult
rossgrambo 505d834
Resolving comments
rossgrambo fb055fc
Removes TargetingContext from EvaluationEvent for now
rossgrambo 6c3a3ea
Merge branch 'preview' into rossgrambo/telemetry
rossgrambo 7d00c6d
Moves tags, etag, and label under 'TelemetryMetadata'
rossgrambo 9386f6a
Adjusts telemetry metadata to already be a flattened dictionary
rossgrambo 8b8cb74
Removes bind in favor of ToDictionary. Removes unused using
rossgrambo 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
18 changes: 18 additions & 0 deletions
18
examples/AppInsightsWithEvaluationData/AppInsightsWithEvaluationData.csproj
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,18 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net6.0</TargetFramework> | ||
| <Nullable>enable</Nullable> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.21.0" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\..\src\Microsoft.FeatureManagement.AspNetCore\Microsoft.FeatureManagement.AspNetCore.csproj" /> | ||
| <ProjectReference Include="..\..\src\Microsoft.FeatureManagement.Telemetry.ApplicationInsights\Microsoft.FeatureManagement.Telemetry.ApplicationInsights.csproj" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
18 changes: 18 additions & 0 deletions
18
...etry.ApplicationInsights/Microsoft.FeatureManagement.Telemetry.ApplicationInsights.csproj
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,18 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFrameworks>netstandard2.0;netcoreapp3.1;net5.0;net6.0</TargetFrameworks> | ||
| <SignAssembly>true</SignAssembly> | ||
| <DelaySign>false</DelaySign> | ||
| <AssemblyOriginatorKeyFile>..\..\build\Microsoft.FeatureManagement.snk</AssemblyOriginatorKeyFile> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="Microsoft.ApplicationInsights" Version="2.21.0" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\Microsoft.FeatureManagement\Microsoft.FeatureManagement.csproj" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
28 changes: 28 additions & 0 deletions
28
src/Microsoft.FeatureManagement.Telemetry.ApplicationInsights/ServiceCollectionExtensions.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,28 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT license. | ||
| // | ||
| using Microsoft.Extensions.DependencyInjection; | ||
| using Microsoft.Extensions.DependencyInjection.Extensions; | ||
|
|
||
| namespace Microsoft.FeatureManagement.Telemetry.ApplicationInsights | ||
| { | ||
| /// <summary> | ||
| /// Extensions used to add feature management publisher functionality. | ||
| /// </summary> | ||
| public static class ServiceCollectionExtensions | ||
| { | ||
| /// <summary> | ||
| /// Adds an event publisher that publishes feature evaluation events to Application Insights. | ||
| /// </summary> | ||
| /// <param name="services">The service collection that feature management services are added to.</param> | ||
| /// <returns>The <see cref="IServiceCollection"/> that was given as a parameter, with the publisher added.</returns> | ||
| public static IServiceCollection AddFeatureManagementTelemetryPublisherApplicationInsights(this IServiceCollection services) | ||
|
rossgrambo marked this conversation as resolved.
Outdated
|
||
| { | ||
| // | ||
| // Add required services | ||
| services.TryAddSingleton<ITelemetryPublisher, TelemetryPublisherApplicationInsights>(); | ||
|
|
||
| return services; | ||
| } | ||
| } | ||
| } | ||
64 changes: 64 additions & 0 deletions
64
....FeatureManagement.Telemetry.ApplicationInsights/TelemetryPublisherApplicationInsights.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,64 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT license. | ||
| // | ||
| using Microsoft.ApplicationInsights; | ||
| using System.Collections.Generic; | ||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
|
|
||
| namespace Microsoft.FeatureManagement.Telemetry.ApplicationInsights | ||
| { | ||
| /// <summary> | ||
| /// Used to publish data from evaluation events to Application Insights | ||
| /// </summary> | ||
| public class TelemetryPublisherApplicationInsights : ITelemetryPublisher | ||
|
rossgrambo marked this conversation as resolved.
Outdated
rossgrambo marked this conversation as resolved.
Outdated
|
||
| { | ||
| private readonly string _eventName = "FeatureEvaluation"; | ||
| private readonly TelemetryClient _telemetryClient; | ||
|
|
||
| public TelemetryPublisherApplicationInsights(TelemetryClient telemetryClient) | ||
| { | ||
| _telemetryClient = telemetryClient; | ||
|
rossgrambo marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| /// <summary> | ||
| /// Publishes a custom event to Application Insights using data from the given evaluation event. | ||
| /// </summary> | ||
| /// <param name="evaluationEvent"> The event to publish.</param> | ||
| /// <param name="cancellationToken"> A cancellation token.</param> | ||
| /// <returns>Returns a ValueTask that represents the asynchronous operation</returns> | ||
| public ValueTask PublishEvent(EvaluationEvent evaluationEvent, CancellationToken cancellationToken) | ||
| { | ||
| FeatureDefinition featureDefinition = evaluationEvent.FeatureDefinition; | ||
|
rossgrambo marked this conversation as resolved.
Outdated
|
||
|
|
||
| Dictionary<string, string> properties = new Dictionary<string, string>() | ||
| { | ||
| { "FeatureName", featureDefinition.Name }, | ||
| { "IsEnabled", evaluationEvent.IsEnabled.ToString() } | ||
| }; | ||
|
|
||
| if (featureDefinition.ETag != null) | ||
| { | ||
| properties.Add("ETag", featureDefinition.ETag); | ||
| } | ||
|
|
||
| if (featureDefinition.Label != null) | ||
| { | ||
| properties.Add("Label", featureDefinition.Label); | ||
| } | ||
|
|
||
| if (featureDefinition.Tags != null) | ||
| { | ||
| foreach (KeyValuePair<string, string> kvp in featureDefinition.Tags) | ||
| { | ||
| properties["Tags." + kvp.Key] = kvp.Value; | ||
| } | ||
| } | ||
|
|
||
| _telemetryClient.TrackEvent(_eventName, properties); | ||
|
|
||
|
|
||
| return new ValueTask(); | ||
| } | ||
| } | ||
| } | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT license. | ||
| // | ||
|
|
||
| // The init accessor for properties is supported in C# 9.0 and later. | ||
| // This class is used to compile .NET frameworks that don't support C# 9.0 or later while still using the init accessor for a property. | ||
| // The code referenced for this file can be found here: https://github.com/dotnet/roslyn/issues/45510#issuecomment-725091019 | ||
|
|
||
| #if NETSTANDARD2_0 || NETCOREAPP2_1 || NETCOREAPP3_1 | ||
|
rossgrambo marked this conversation as resolved.
Outdated
|
||
|
|
||
| using System.ComponentModel; | ||
|
|
||
| namespace System.Runtime.CompilerServices | ||
| { | ||
| [EditorBrowsable(EditorBrowsableState.Never)] | ||
| internal static class IsExternalInit | ||
| { | ||
| } | ||
| } | ||
|
|
||
| #endif | ||
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
21 changes: 21 additions & 0 deletions
21
src/Microsoft.FeatureManagement/Telemetry/EvaluationEvent.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,21 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT license. | ||
| // | ||
| namespace Microsoft.FeatureManagement.Telemetry | ||
| { | ||
| /// <summary> | ||
| /// An event representing the evaluation of a feature. | ||
| /// </summary> | ||
| public class EvaluationEvent | ||
| { | ||
| /// <summary> | ||
| /// The definition of the feature that was evaluated. | ||
| /// </summary> | ||
| public FeatureDefinition FeatureDefinition { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// The enabled state of the feature after evaluation. | ||
| /// </summary> | ||
| public bool IsEnabled { get; set; } | ||
| } | ||
| } |
23 changes: 23 additions & 0 deletions
23
src/Microsoft.FeatureManagement/Telemetry/ITelemetryPublisher.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,23 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT license. | ||
| // | ||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
|
|
||
| namespace Microsoft.FeatureManagement.Telemetry | ||
| { | ||
| /// <summary> | ||
| /// A publisher of telemetry events. | ||
| /// </summary> | ||
| public interface ITelemetryPublisher | ||
| { | ||
| /// <summary> | ||
| /// Handles an EvaluationEvent and publishes it to the configured telemetry channel. | ||
| /// </summary> | ||
| /// <param name="evaluationEvent"> The event to publish.</param> | ||
| /// <param name="cancellationToken"> A cancellation token.</param> | ||
| /// <returns>ValueTask</returns> | ||
| public ValueTask PublishEvent(EvaluationEvent evaluationEvent, CancellationToken cancellationToken); | ||
| } | ||
|
|
||
|
rossgrambo marked this conversation as resolved.
Outdated
|
||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.