Skip to content
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

Adds telemetry pipeline #259

Merged
merged 43 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from 40 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 Sep 11, 2023
614e9af
Use await insead of .result
rossgrambo Sep 12, 2023
4db49a3
Reverting unused dependency removal
rossgrambo Sep 12, 2023
75cab57
Update src/Microsoft.FeatureManagement/FeatureDefinition.cs
rossgrambo Sep 12, 2023
f8e4f7b
Update src/Microsoft.FeatureManagement/FeatureDefinition.cs
rossgrambo Sep 12, 2023
7c77718
Update src/Microsoft.FeatureManagement.AppInsightsTelemetryPublisher/…
rossgrambo Sep 12, 2023
52930c0
Removed factory pattern for publisher DI
rossgrambo Sep 12, 2023
cb18586
Update src/Microsoft.FeatureManagement/FeatureManager.cs
rossgrambo Sep 13, 2023
121ca35
Resolve misc. comments
rossgrambo Sep 13, 2023
20b5f82
Merge branch 'rossgrambo/telemetry' of https://github.com/microsoft/F…
rossgrambo Sep 13, 2023
e025642
Adjusts descriptions for FeatureDefinition properties
rossgrambo Sep 13, 2023
8ad67b7
Rename AppInsights to ApplicationInsights
rossgrambo Sep 15, 2023
fce7274
Resolves project reference in sln
rossgrambo Sep 15, 2023
d23357c
Adjusts ServiceCollectionExtensions to use TryAddSingleton
rossgrambo Sep 15, 2023
e43e114
Removes langversion from .csproj
rossgrambo Sep 15, 2023
93a88a3
Temp
rossgrambo Sep 15, 2023
ba22ed1
Adds explicit null checkts before publishing fields to app insights
rossgrambo Sep 18, 2023
0b5bea4
Addressing misc. comments
rossgrambo Sep 18, 2023
2bfcbc8
Removing project reference for example project
rossgrambo Sep 18, 2023
6cf2ee6
Merge with preview
rossgrambo Sep 20, 2023
5b1842f
Syncing telemetry and variants
rossgrambo Sep 20, 2023
ecc898d
Adds null check for feature definitions
rossgrambo Sep 21, 2023
39dd606
Adjusted TelemetryPublishers to no longer be inserted into DI
rossgrambo Sep 29, 2023
9cf586a
Resolving comments
rossgrambo Sep 29, 2023
78d3ba2
Removing Application Insights project
rossgrambo Sep 29, 2023
ac3630c
Converts some variables to inline
rossgrambo Sep 30, 2023
0388134
Resolving misc. comments
rossgrambo Oct 2, 2023
2ff83ac
Moves AddTelemetryPublisher to be an extension method
rossgrambo Oct 2, 2023
4a5b135
Removing IVariantFeatureManager GetFeatureNamesAsync definition, as i…
rossgrambo Oct 3, 2023
b6e8df0
Remove unused dependency
rossgrambo Oct 3, 2023
f70513f
Resolving comments
rossgrambo Oct 3, 2023
bf151ac
Remove invisible character changes
rossgrambo Oct 4, 2023
edbb8d5
Remove Dependency Injection package
rossgrambo Oct 4, 2023
e94ad7f
Update src/Microsoft.FeatureManagement/FeatureManagerSnapshot.cs
rossgrambo Oct 4, 2023
8b0f3ba
Update src/Microsoft.FeatureManagement/IVariantFeatureManager.cs
rossgrambo Oct 4, 2023
5df39c8
Persists cancellation token to PublishEvent and adds null check for n…
rossgrambo Oct 4, 2023
982f313
Adds TargetingContext to the EvaluationResult
rossgrambo Oct 4, 2023
505d834
Resolving comments
rossgrambo Oct 5, 2023
fb055fc
Removes TargetingContext from EvaluationEvent for now
rossgrambo Oct 5, 2023
6c3a3ea
Merge branch 'preview' into rossgrambo/telemetry
rossgrambo Oct 5, 2023
7d00c6d
Moves tags, etag, and label under 'TelemetryMetadata'
rossgrambo Oct 6, 2023
9386f6a
Adjusts telemetry metadata to already be a flattened dictionary
rossgrambo Oct 6, 2023
8b8cb74
Removes bind in favor of ToDictionary. Removes unused using
rossgrambo Oct 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Microsoft.FeatureManagement.sln
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleApp", "examples\Cons
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TargetingConsoleApp", "examples\TargetingConsoleApp\TargetingConsoleApp.csproj", "{6558C21E-CF20-4278-AA08-EB9D1DF29D66}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RazorPages", "examples\RazorPages\RazorPages.csproj", "{BA29A1BB-81D5-4EB1-AF37-6ECF64AF27E2}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RazorPages", "examples\RazorPages\RazorPages.csproj", "{BA29A1BB-81D5-4EB1-AF37-6ECF64AF27E2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests.FeatureManagement.AspNetCore", "tests\Tests.FeatureManagement.AspNetCore\Tests.FeatureManagement.AspNetCore.csproj", "{FC0DC3E2-5646-4AEC-A7DB-2D6167BC3BB4}"
EndProject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ We support
*/

RequirementType requirementType = RequirementType.Any;
string label = null;
string eTag = null;
bool telemetryEnabled = false;
Dictionary<string, string> tags = new Dictionary<string, string>();

FeatureStatus featureStatus = FeatureStatus.Conditional;

Expand Down Expand Up @@ -283,6 +287,19 @@ We support
variants.Add(variant);
}
}

IConfigurationSection tagsSection = configurationSection.GetSection("Tags");
if (tagsSection.Exists())
{
foreach (IConfigurationSection tag in tagsSection.GetChildren())
{
tags.Add(tag.Key, tag.Value);
}
}

label = configurationSection["Label"];
eTag = configurationSection["ETag"];
telemetryEnabled = configurationSection.GetValue<bool>("TelemetryEnabled");
}

return new FeatureDefinition()
Expand All @@ -292,7 +309,11 @@ We support
RequirementType = requirementType,
Status = featureStatus,
Allocation = allocation,
Variants = variants
Variants = variants,
Label = label,
ETag = eTag,
TelemetryEnabled = telemetryEnabled,
Tags = tags
rossgrambo marked this conversation as resolved.
Show resolved Hide resolved
};
}

Expand Down
20 changes: 20 additions & 0 deletions src/Microsoft.FeatureManagement/FeatureDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,25 @@ public class FeatureDefinition
/// A list of variant definitions that specify a configuration to return when assigned.
/// </summary>
public IEnumerable<VariantDefinition> Variants { get; set; } = Enumerable.Empty<VariantDefinition>();

/// <summary>
/// Metadata that can be used to group feature flags.
/// </summary>
public string Label { get; set; }
rossgrambo marked this conversation as resolved.
Show resolved Hide resolved

/// <summary>
/// An ETag that is used to track when the feature definiton has changed.
/// </summary>
public string ETag { get; set; }

/// <summary>
/// A dictionary of tags used to assign additional metadata to a feature.
/// </summary>
public IReadOnlyDictionary<string, string> Tags { get; set; }

/// <summary>
/// A flag to enable or disable sending telemetry events to the registered <see cref="ITelemetryPublisher">.
/// </summary>
public bool TelemetryEnabled { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.FeatureManagement.Telemetry;
using System;
using System.Collections.Generic;

namespace Microsoft.FeatureManagement
{
/// <summary>
/// Extensions used to add feature management functionality.
/// </summary>
public static class FeatureManagementBuilderExtensions
{
/// <summary>
/// Adds a telemetry publisher to the feature management system.
/// </summary>
/// <param name="builder">The <see cref="IFeatureManagementBuilder"/> used to customize feature management functionality.</param>
/// <returns>A <see cref="IFeatureManagementBuilder"/> that can be used to customize feature management functionality.</returns>
public static IFeatureManagementBuilder AddTelemetryPublisher<T>(this IFeatureManagementBuilder builder) where T : ITelemetryPublisher
rossgrambo marked this conversation as resolved.
Show resolved Hide resolved
{
builder.AddTelemetryPublisher(sp => ActivatorUtilities.CreateInstance(sp, typeof(T)) as ITelemetryPublisher);

return builder;
}

private static IFeatureManagementBuilder AddTelemetryPublisher(this IFeatureManagementBuilder builder, Func<IServiceProvider, ITelemetryPublisher> factory)
{
builder.Services.Configure<FeatureManagementOptions>(options =>
{
if (options.TelemetryPublisherFactories == null)
{
options.TelemetryPublisherFactories = new List<Func<IServiceProvider, ITelemetryPublisher>>();
}

options.TelemetryPublisherFactories.Add(factory);
});

return builder;
}
}
}
10 changes: 10 additions & 0 deletions src/Microsoft.FeatureManagement/FeatureManagementOptions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
//
using Microsoft.FeatureManagement.Telemetry;
using System;
using System.Collections.Generic;

namespace Microsoft.FeatureManagement
{
/// <summary>
Expand All @@ -22,5 +26,11 @@ public class FeatureManagementOptions
/// The default value is true.
/// </summary>
public bool IgnoreMissingFeatures { get; set; } = true;

/// <summary>
/// Holds a collection of factories that can be used to create <see cref="ITelemetryPublisher"/> instances.
/// This avoids the need to add the publishers to the service collection.
/// </summary>
internal ICollection<Func<IServiceProvider, ITelemetryPublisher>> TelemetryPublisherFactories { get; set; }
}
}
Loading