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 ;
public ActivityContext Context { get; }
[System.Runtime.CompilerServices.Nullable(new byte[] {
2,
0,
1,
2
})]
public IEnumerable<KeyValuePair<string, object>> Tags {
[return: System.Runtime.CompilerServices.Nullable(new byte[] {
2,
0,
1,
2
})]
get {
return _tags;
}
}
[System.Runtime.CompilerServices.NullableContext(2)]
public ActivityLink(ActivityContext context, ActivityTagsCollection tags = null)
{
Context = context;
_tags = ((tags != null && tags.Count > 0) ? new Activity.TagsLinkedList(tags) : null);
}
[System.Runtime.CompilerServices.NullableContext(2)]
public override bool Equals([System.Diagnostics.CodeAnalysis.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: 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);
}
public override int GetHashCode()
{
if (this == default(ActivityLink))
return 0;
int num = 5381;
num = (num << 5) + num + Context.GetHashCode();
if (Tags != null) {
foreach (KeyValuePair<string, object> tag in Tags) {
num = (num << 5) + num + tag.Key.GetHashCode();
if (tag.Value != null)
num = (num << 5) + num + tag.Value.GetHashCode();
}
return num;
}
return num;
}
}
}