-
Notifications
You must be signed in to change notification settings - Fork 21
Description
Currently in the TraceEnricherHook, we're adding tags/events to the current activity,
dotnet-sdk/src/OpenFeature/Hooks/TraceEnricherHook.cs
Lines 39 to 48 in 417f3fe
| var tags = new ActivityTagsCollection(); | |
| foreach (var kvp in evaluationEvent.Attributes) | |
| { | |
| tags[kvp.Key] = kvp.Value; | |
| } | |
| this.AddCustomTags(tags); | |
| this.AddFlagMetadataTags(details.FlagMetadata, tags); | |
| Activity.Current?.AddEvent(new ActivityEvent(evaluationEvent.Name, tags: tags)); |
In this way, it's hard to listen to the event specifically, since the event is not determined, and sometimes there's no activity.
From the practice on docs, we should create an individual ActivitySource like the Meter, so that we could listen to the ActivitySource when we want to focus on the feature flag activity
Another thought on the activity, we should try to avoid unnecessary operations to improve performance, for example, we could skip creating and adding tags/events when there's no activity or the Activity.IsAllDataRequested property is false
https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.activity.isalldatarequested
Finally, since we're creating a separate ActivitySource, think it could be built-in the main logic other than a hook, the users would need to listen to the ActivitySource explicitly to get related activities, so that no need to register additional trace hook.