<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="8.0.0-preview.5.23280.8" />

ActivityEvent

public struct ActivityEvent
Represents an event containing a name and a timestamp, as well as an optional list of tags.
using System.Collections.Generic; using System.Runtime.CompilerServices; namespace System.Diagnostics { [System.Runtime.CompilerServices.NullableContext(1)] [System.Runtime.CompilerServices.Nullable(0)] public readonly struct ActivityEvent { private static readonly IEnumerable<KeyValuePair<string, object>> s_emptyTags = Array.Empty<KeyValuePair<string, object>>(); private readonly Activity.TagsLinkedList _tags; public string Name { get; } public DateTimeOffset Timestamp { get; } [System.Runtime.CompilerServices.Nullable(new byte[] { 1, 0, 1, 2 })] public IEnumerable<KeyValuePair<string, object>> Tags { [return: System.Runtime.CompilerServices.Nullable(new byte[] { 1, 0, 1, 2 })] get { IEnumerable<KeyValuePair<string, object>> tags = _tags; return tags ?? s_emptyTags; } } public ActivityEvent(string name) { this = new ActivityEvent(name, DateTimeOffset.UtcNow, null); } public ActivityEvent(string name, DateTimeOffset timestamp = default(DateTimeOffset), [System.Runtime.CompilerServices.Nullable(2)] ActivityTagsCollection tags = null) { Name = (name ?? string.Empty); Timestamp = ((timestamp != default(DateTimeOffset)) ? timestamp : DateTimeOffset.UtcNow); _tags = ((tags != null && tags.Count > 0) ? new Activity.TagsLinkedList(tags) : null); } [return: System.Runtime.CompilerServices.Nullable(new byte[] { 0, 0, 1, 2 })] public Activity.Enumerator<KeyValuePair<string, object>> EnumerateTagObjects() { return new Activity.Enumerator<KeyValuePair<string, object>>(_tags?.First); } } }