<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="10.0.0-preview.6.25358.103" />

ActivityLink

Activities may be linked to zero or more activity context instances that are causally related. Activity links can point to activity contexts inside a single trace or across different traces. Activity links can be used to represent batched operations where an activity was initiated by multiple initiating activities, each representing a single incoming item being processed in the batch.
using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; namespace System.Diagnostics { public readonly struct ActivityLink : IEquatable<ActivityLink> { private readonly Activity.TagsLinkedList _tags; public ActivityContext Context { get; } [Nullable(new byte[] { 2, 0, 1, 2 })] public IEnumerable<KeyValuePair<string, object>> Tags { [return: Nullable(new byte[] { 2, 0, 1, 2 })] get { return _tags; } } [NullableContext(2)] public ActivityLink(ActivityContext context, ActivityTagsCollection tags = null) { Context = context; _tags = ((tags != null && tags.Count > 0) ? new Activity.TagsLinkedList(tags) : null); } [NullableContext(2)] public override bool Equals([NotNullWhen(true)] object obj) { if (obj is ActivityLink) { ActivityLink value = (ActivityLink)obj; return Equals(value); } return false; } public bool Equals(ActivityLink value) { if (Context == value.Context) return value.Tags == Tags; return false; } public static bool operator ==(ActivityLink left, ActivityLink right) { return left.Equals(right); } public static bool operator !=(ActivityLink left, ActivityLink right) { return !left.Equals(right); } [return: Nullable(new byte[] { 0, 0, 1, 2 })] public Activity.Enumerator<KeyValuePair<string, object>> EnumerateTagObjects() { return new Activity.Enumerator<KeyValuePair<string, object>>(_tags?.First); } public override int GetHashCode() { HashCode hashCode = default(HashCode); hashCode.Add(Context); if (Tags != null) { foreach (KeyValuePair<string, object> tag in Tags) { hashCode.Add(tag.Key); hashCode.Add(tag.Value); } } return hashCode.ToHashCode(); } } }