Struct SpanContext
- Namespace
- OpenTelemetry.Trace
- Assembly
- OpenTelemetry.Api.dll
A struct that represents a span context. A span context contains the portion of a span that must propagate to child TelemetrySpan and across process boundaries. It contains the identifiers System.Diagnostics.ActivityTraceIdand System.Diagnostics.ActivitySpanId associated with the TelemetrySpan along with a set of common TraceFlags and system-specific TraceState values>.
public readonly struct SpanContext : IEquatable<SpanContext>
- Implements
- Inherited Members
Remarks
SpanContext is a wrapper around ActivityContext.
Constructors
SpanContext(in ActivityContext)
Initializes a new instance of the SpanContext struct with the given identifiers and options.
public SpanContext(in ActivityContext activityContext)
Parameters
activityContext
ActivityContextThe activity context.
SpanContext(in ActivityTraceId, in ActivitySpanId, ActivityTraceFlags, bool, IEnumerable<KeyValuePair<string, string>>)
Initializes a new instance of the SpanContext struct with the given identifiers and options.
public SpanContext(in ActivityTraceId traceId, in ActivitySpanId spanId, ActivityTraceFlags traceFlags, bool isRemote = false, IEnumerable<KeyValuePair<string, string>> traceState = null)
Parameters
traceId
ActivityTraceIdThe System.Diagnostics.ActivityTraceId to associate with the SpanContext.
spanId
ActivitySpanIdThe System.Diagnostics.ActivitySpanId to associate with the SpanContext.
traceFlags
ActivityTraceFlagsThe TraceFlags to associate with the SpanContext.
isRemote
boolThe value indicating whether this SpanContext was propagated from the remote parent.
traceState
IEnumerable<KeyValuePair<string, string>>The traceState to associate with the SpanContext.
Properties
IsRemote
Gets a value indicating whether this SpanContext was propagated from a remote parent.
public bool IsRemote { get; }
Property Value
IsValid
Gets a value indicating whether this SpanContext is valid.
public bool IsValid { get; }
Property Value
SpanId
Gets the System.Diagnostics.ActivitySpanId associated with this SpanContext.
public ActivitySpanId SpanId { get; }
Property Value
- ActivitySpanId
TraceFlags
Gets the System.Diagnostics.ActivityTraceFlags associated with this SpanContext.
public ActivityTraceFlags TraceFlags { get; }
Property Value
- ActivityTraceFlags
TraceId
Gets the System.Diagnostics.ActivityTraceId associated with this SpanContext.
public ActivityTraceId TraceId { get; }
Property Value
- ActivityTraceId
TraceState
Gets the TraceState associated with this SpanContext.
public IEnumerable<KeyValuePair<string, string>> TraceState { get; }
Property Value
Methods
Equals(SpanContext)
public bool Equals(SpanContext other)
Parameters
other
SpanContext
Returns
Equals(object)
public override bool Equals(object obj)
Parameters
obj
object
Returns
GetHashCode()
public override int GetHashCode()
Returns
Operators
operator ==(SpanContext, SpanContext)
Compare two SpanContext for equality.
public static bool operator ==(SpanContext spanContext1, SpanContext spanContext2)
Parameters
spanContext1
SpanContextFirst SpanContext to compare.
spanContext2
SpanContextSecond SpanContext to compare.
Returns
implicit operator ActivityContext(SpanContext)
Converts a SpanContext into an ActivityContext.
public static implicit operator ActivityContext(SpanContext spanContext)
Parameters
spanContext
SpanContextSpanContext source.
Returns
- ActivityContext
operator !=(SpanContext, SpanContext)
Compare two SpanContext for not equality.
public static bool operator !=(SpanContext spanContext1, SpanContext spanContext2)
Parameters
spanContext1
SpanContextFirst SpanContext to compare.
spanContext2
SpanContextSecond SpanContext to compare.