File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed
Microsoft.FeatureManagement.Telemetry.ApplicationInsights
Microsoft.FeatureManagement Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -51,7 +51,41 @@ private void HandleFeatureFlagEvent(ActivityEvent activityEvent)
5151
5252 foreach ( var tag in activityEvent . Tags )
5353 {
54- properties [ tag . Key ] = tag . Value ? . ToString ( ) ;
54+ // FeatureEvaluation event schema: https://github.com/microsoft/FeatureManagement/blob/main/Schema/FeatureEvaluationEvent/FeatureEvaluationEvent.v1.0.0.schema.json
55+ if ( tag . Value is VariantAssignmentReason reason )
56+ {
57+ switch ( reason )
58+ {
59+ case VariantAssignmentReason . None :
60+ properties [ tag . Key ] = "None" ;
61+ break ;
62+ case VariantAssignmentReason . DefaultWhenDisabled :
63+ properties [ tag . Key ] = "DefaultWhenDisabled" ;
64+ break ;
65+ case VariantAssignmentReason . DefaultWhenEnabled :
66+ properties [ tag . Key ] = "DefaultWhenEnabled" ;
67+ break ;
68+ case VariantAssignmentReason . User :
69+ properties [ tag . Key ] = "User" ;
70+ break ;
71+ case VariantAssignmentReason . Group :
72+ properties [ tag . Key ] = "Group" ;
73+ break ;
74+ case VariantAssignmentReason . Percentile :
75+ properties [ tag . Key ] = "Percentile" ;
76+ break ;
77+ default :
78+ throw new ArgumentOutOfRangeException ( nameof ( activityEvent ) , "The variant assignment reason is unrecognizable." ) ;
79+ }
80+ }
81+ else if ( tag . Value is bool val )
82+ {
83+ properties [ tag . Key ] = val ? "True" : "False" ;
84+ }
85+ else
86+ {
87+ properties [ tag . Key ] = tag . Value ? . ToString ( ) ;
88+ }
5589 }
5690
5791 _telemetryClient . TrackEvent ( "FeatureEvaluation" , properties ) ;
Original file line number Diff line number Diff line change @@ -380,6 +380,7 @@ private void AddEvaluationActivityEvent(EvaluationEvent evaluationEvent)
380380 Debug . Assert ( evaluationEvent != null ) ;
381381 Debug . Assert ( evaluationEvent . FeatureDefinition != null ) ;
382382
383+ // FeatureEvaluation event schema: https://github.com/microsoft/FeatureManagement/blob/main/Schema/FeatureEvaluationEvent/FeatureEvaluationEvent.v1.0.0.schema.json
383384 var tags = new ActivityTagsCollection ( )
384385 {
385386 { "FeatureName" , evaluationEvent . FeatureDefinition . Name } ,
You can’t perform that action at this time.
0 commit comments