@@ -15,13 +15,13 @@ namespace LaunchDarkly.Sdk.Server.Telemetry
1515 public class TracingHookBuilder
1616 {
1717 private bool _createActivities ;
18- private bool _includeVariant ;
18+ private bool _includeValue ;
1919 private string _environmentId ;
2020
2121 internal TracingHookBuilder ( )
2222 {
2323 _createActivities = false ;
24- _includeVariant = false ;
24+ _includeValue = false ;
2525 _environmentId = null ;
2626 }
2727
@@ -41,15 +41,28 @@ public TracingHookBuilder CreateActivities(bool createActivities = true)
4141 return this ;
4242 }
4343
44+ /// <summary>
45+ /// The TracingHook will include the flag value in the current activity, if one exists.
46+ /// The value representation is a JSON string. Disabled by default.
47+ /// </summary>
48+ /// <param name="includeValue">true to include value, false otherwise</param>
49+ /// <returns>this builder</returns>
50+ public TracingHookBuilder IncludeValue ( bool includeValue = true )
51+ {
52+ _includeValue = includeValue ;
53+ return this ;
54+ }
55+
4456 /// <summary>
4557 /// The TracingHook will include the flag variant in the current activity, if one exists.
4658 /// The variant representation is a JSON string. Disabled by default.
4759 /// </summary>
4860 /// <param name="includeVariant">true to include variants, false otherwise</param>
4961 /// <returns>this builder</returns>
62+ [ System . Obsolete ( "IncludeVariant is deprecated. Use IncludeValue instead." ) ]
5063 public TracingHookBuilder IncludeVariant ( bool includeVariant = true )
5164 {
52- _includeVariant = includeVariant ;
65+ _includeValue = includeVariant ;
5366 return this ;
5467 }
5568
@@ -77,7 +90,7 @@ public TracingHookBuilder EnvironmentId(string environmentId)
7790 /// <returns>the new hook</returns>
7891 public TracingHook Build ( )
7992 {
80- return new TracingHook ( new TracingHook . Options ( _createActivities , _includeVariant , _environmentId ) ) ;
93+ return new TracingHook ( new TracingHook . Options ( _createActivities , _includeValue , _environmentId ) ) ;
8194 }
8295 }
8396
@@ -107,23 +120,25 @@ private static class SemanticAttributes
107120 {
108121 public const string EventName = "feature_flag" ;
109122 public const string FeatureFlagKey = "feature_flag.key" ;
110- public const string FeatureFlagProviderName = "feature_flag.provider_name" ;
111- public const string FeatureFlagVariant = "feature_flag.variant" ;
112- public const string FeatureFlagContextKeyAttributeName = "feature_flag.context.key" ;
123+ public const string FeatureFlagProviderName = "feature_flag.provider.name" ;
124+ public const string FeatureFlagValue = "feature_flag.result.value" ;
125+ public const string FeatureFlagVariationIndex = "feature_flag.result.variationIndex" ;
126+ public const string FeatureFlagInExperiment = "feature_flag.result.reason.inExperiment" ;
127+ public const string FeatureFlagContextKeyAttributeName = "feature_flag.context.id" ;
113128 public const string FeatureFlagSetId = "feature_flag.set.id" ;
114129 }
115130
116131 internal struct Options
117132 {
118133 public bool CreateActivities { get ; }
119- public bool IncludeVariant { get ; }
134+ public bool IncludeValue { get ; }
120135
121136 public string EnvironmentId { get ; }
122137
123- public Options ( bool createActivities , bool includeVariant , string environmentId = null )
138+ public Options ( bool createActivities , bool includeValue , string environmentId = null )
124139 {
125140 CreateActivities = createActivities ;
126- IncludeVariant = includeVariant ;
141+ IncludeValue = includeValue ;
127142 EnvironmentId = environmentId ;
128143 }
129144 }
@@ -179,7 +194,7 @@ public override SeriesData BeforeEvaluation(EvaluationSeriesContext context, Ser
179194
180195 /// <summary>
181196 /// Ends the activity created in BeforeEvaluation, if it exists. Adds the feature flag key, provider name, and context key
182- /// to the existing activity. If IncludeVariant is enabled, also adds the variant.
197+ /// to the existing activity. If includeValue is enabled, also adds the variant.
183198 /// </summary>
184199 /// <param name="context">the evaluation parameters</param>
185200 /// <param name="data">the series data</param>
@@ -216,9 +231,19 @@ public override SeriesData AfterEvaluation(EvaluationSeriesContext context, Seri
216231 attributes [ SemanticAttributes . FeatureFlagSetId ] = context . EnvironmentId ;
217232 }
218233
219- if ( _options . IncludeVariant )
234+ if ( _options . IncludeValue )
235+ {
236+ attributes . Add ( SemanticAttributes . FeatureFlagValue , detail . Value . ToJsonString ( ) ) ;
237+ }
238+
239+ if ( detail . Reason . InExperiment )
240+ {
241+ attributes . Add ( SemanticAttributes . FeatureFlagInExperiment , detail . Reason . InExperiment ) ;
242+ }
243+
244+ if ( detail . VariationIndex . HasValue )
220245 {
221- attributes . Add ( SemanticAttributes . FeatureFlagVariant , detail . Value . ToJsonString ( ) ) ;
246+ attributes . Add ( SemanticAttributes . FeatureFlagVariationIndex , detail . VariationIndex . Value ) ;
222247 }
223248
224249 Activity . Current ? . AddEvent ( new ActivityEvent ( name : SemanticAttributes . EventName , tags : attributes ) ) ;
0 commit comments