ActivityLink
Activity may be linked to zero or more other ActivityContext that are causally related.
Links can point to ActivityContexts inside a single Trace or across different Traces.
Links can be used to represent batched operations where a 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>
{
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;
}
[System.Runtime.CompilerServices.NullableContext(2)]
public ActivityLink(ActivityContext context, ActivityTagsCollection tags = null)
{
Context = context;
Tags = tags;
}
[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);
}
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;
}
}
}