| | | 1 | | using System; |
| | | 2 | | using System.Diagnostics; |
| | | 3 | | using Serilog.Core; |
| | | 4 | | using Serilog.Events; |
| | | 5 | | |
| | | 6 | | namespace Serilog.Enrichers.ActivityTags |
| | | 7 | | { |
| | | 8 | | public class ActivityTagsEnricher : ILogEventEnricher |
| | | 9 | | { |
| | | 10 | | public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) |
| | 1 | 11 | | { |
| | 1 | 12 | | var activity = Activity.Current; |
| | | 13 | | |
| | 1 | 14 | | if (activity is null) return; |
| | | 15 | | |
| | 7 | 16 | | foreach (var item in activity.Tags) |
| | 2 | 17 | | { |
| | 2 | 18 | | logEvent.AddOrUpdateProperty(new LogEventProperty(item.Key, new ScalarValue(item.Value))); |
| | 2 | 19 | | } |
| | 1 | 20 | | } |
| | | 21 | | } |
| | | 22 | | } |