SpanContext
class SpanContext
SpanContext encapsulates your current context within your request's trace. It includes
3 fields: the traceId
, the current spanId
, and an enabled
flag which indicates whether
or not the request is being traced.
Example:
use OpenCensus\Trace\Tracer;
$context = Tracer::spanContext();
echo $context; // output the header format for using the current context in a remote call
Traits
Methods
Creates a new SpanContext instance
Fetch the current traceId.
Fetch the current spanId.
Set the current spanId.
Whether or not the request is being traced.
Set whether or not the request is being traced.
Whether or not this context was detected from a request header.
Details
at line 66
__construct(string $traceId = null, string|null $spanId = null, bool|null $enabled = null, bool $fromHeader = false)
Creates a new SpanContext instance
at line 79
string
traceId()
Fetch the current traceId.
at line 89
string
spanId()
Fetch the current spanId.
at line 99
setSpanId(string|null $spanId)
Set the current spanId.
at line 109
bool
enabled()
Whether or not the request is being traced.
at line 119
setEnabled(bool|null $enabled)
Set whether or not the request is being traced.
at line 129
bool
fromHeader()
Whether or not this context was detected from a request header.