Package org.microproxy.otel
Record Class SpanContext
java.lang.Object
java.lang.Record
org.microproxy.otel.SpanContext
- Record Components:
traceIdHigh- the trace id's first 8 bytestraceIdLow- the trace id's last 8 bytesspanId- the span idflags- the trace flags, of which bit 0 says whether the trace is sampledtraceState- thetracestatelist, normalized, or an empty stringremote- whether the context came from another process
public record SpanContext(long traceIdHigh, long traceIdLow, long spanId, int flags, String traceState, boolean remote)
extends Record
What a propagator carries between processes: a 128-bit trace id, a 64-bit span id, the trace
flags (bit 0: sampled) and the W3C
tracestate, as OpenTelemetry's SpanContext.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSpanContext(long traceIdHigh, long traceIdLow, long spanId, int flags, String traceState, boolean remote) Checks the parts. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.intflags()Returns the value of theflagsrecord component.final inthashCode()Returns a hash code value for this object.booleanReturns whether the trace is sampled.booleanisValid()Returns whether the ids are valid: neither is all zeros.booleanremote()Returns the value of theremoterecord component.longspanId()Returns the value of thespanIdrecord component.Returns the span id as 16 lower-case hex digits.toString()Returns a string representation of this record class.Returns the trace id as 32 lower-case hex digits.longReturns the value of thetraceIdHighrecord component.longReturns the value of thetraceIdLowrecord component.Returns the value of thetraceStaterecord component.withSpan(long spanId, boolean sampled) Returns this context with another span id and sampled flag, as the proxy's own span.
-
Field Details
-
SAMPLED
public static final int SAMPLEDThesampledtrace flag.- See Also:
-
-
Constructor Details
-
SpanContext
public SpanContext(long traceIdHigh, long traceIdLow, long spanId, int flags, String traceState, boolean remote) Checks the parts.- Parameters:
traceIdHigh- the trace id's first 8 bytestraceIdLow- the trace id's last 8 bytesspanId- the span idflags- the trace flagstraceState- thetracestatelist, ornullfor noneremote- whether the context came from another process
-
-
Method Details
-
isValid
public boolean isValid()Returns whether the ids are valid: neither is all zeros.- Returns:
- whether the ids are valid: neither is all zeros
-
isSampled
public boolean isSampled()Returns whether the trace is sampled.- Returns:
- whether the trace is sampled
-
traceIdHex
Returns the trace id as 32 lower-case hex digits.- Returns:
- the trace id as 32 lower-case hex digits
-
spanIdHex
Returns the span id as 16 lower-case hex digits.- Returns:
- the span id as 16 lower-case hex digits
-
withSpan
Returns this context with another span id and sampled flag, as the proxy's own span.- Parameters:
spanId- the span's idsampled- whether the trace is sampled- Returns:
- this context with another span id and sampled flag, as the proxy's own span
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
traceIdHigh
public long traceIdHigh()Returns the value of thetraceIdHighrecord component.- Returns:
- the value of the
traceIdHighrecord component
-
traceIdLow
public long traceIdLow()Returns the value of thetraceIdLowrecord component.- Returns:
- the value of the
traceIdLowrecord component
-
spanId
public long spanId()Returns the value of thespanIdrecord component.- Returns:
- the value of the
spanIdrecord component
-
flags
public int flags()Returns the value of theflagsrecord component.- Returns:
- the value of the
flagsrecord component
-
traceState
Returns the value of thetraceStaterecord component.- Returns:
- the value of the
traceStaterecord component
-
remote
public boolean remote()Returns the value of theremoterecord component.- Returns:
- the value of the
remoterecord component
-