Span
extends Span
in package
implements
ReadWriteSpanInterface
uses
LogsMessagesTrait
Table of Contents
Interfaces
- ReadWriteSpanInterface
- Represents a value that can be stored within {@see ContextInterface}.
Properties
- $attributesBuilder : AttributesBuilderInterface
- $context : SpanContextInterface
- $endEpochNanos : int
- $events : array<int, EventInterface>
- $hasEnded : bool
- $instrumentationScope : InstrumentationScopeInterface
- $invalidSpan : self|null
- $kind : int
- $links : array<string|int, mixed>
- $name : string
- $parentSpanContext : SpanContextInterface
- $resource : ResourceInfo
- $spanLimits : SpanLimits
- $spanProcessor : SpanProcessorInterface
- $startEpochNanos : int
- $status : StatusDataInterface
- $totalRecordedEvents : int
- $totalRecordedLinks : int
Methods
- activate() : ScopeInterface
- Adds `$this` to the {@see Context::getCurrent() current context} and makes the new {@see Context} the current context.
- addEvent() : self
- addLink() : SpanInterface
- Records a link to another `SpanContext`.
- end() : void
- formatStackTrace() : string
- Backward compatibility methods
- fromContext() : SpanInterface
- Returns the {@see SpanInterface} from the provided *$context*, falling back on {@see SpanInterface::getInvalid()} if there is no span in the provided context.
- getAttribute() : mixed
- Returns the value of the attribute with the provided *key*.
- getContext() : SpanContextInterface
- getCurrent() : SpanInterface
- Returns the current {@see SpanInterface} from the current {@see ContextInterface}, falling back on {@see SpanInterface::getEmpty()} if there is no span in the current context.
- getDuration() : int
- Returns the duration of the {@see API\SpanInterface} in nanoseconds.
- getInstrumentationScope() : InstrumentationScopeInterface
- getInvalid() : SpanInterface
- Returns an invalid {@see SpanInterface} that is used when tracing is disabled, such s when there is no available SDK.
- getKind() : int
- getName() : string
- getParentContext() : SpanContextInterface
- getResource() : ResourceInfo
- getStartEpochNanos() : int
- getTotalRecordedEvents() : int
- getTotalRecordedLinks() : int
- hasEnded() : bool
- isRecording() : bool
- recordException() : self
- setAttribute() : self
- setAttributes() : self
- setStatus() : self
- storeInContext() : ContextInterface
- Returns a new {@see ContextInterface} created by setting `$this` into the provided [@see ContextInterface}.
- toSpanData() : SpanDataInterface
- Returns an immutable representation of this instance.
- updateName() : self
- wrap() : SpanInterface
- Returns a non-recording {@see SpanInterface} that hold the provided *$spanContext* but has no functionality.
- logDebug() : void
- logError() : void
- logInfo() : void
- logNotice() : void
- logWarning() : void
- __construct() : mixed
- checkForDroppedElements() : void
- doLog() : void
- shouldLog() : bool
Properties
$attributesBuilder
private
AttributesBuilderInterface
$attributesBuilder
$context read-only
private
SpanContextInterface
$context
$endEpochNanos
private
int
$endEpochNanos
= 0
$events
private
array<int, EventInterface>
$events
= []
$hasEnded
private
bool
$hasEnded
= false
$instrumentationScope read-only
private
InstrumentationScopeInterface
$instrumentationScope
$invalidSpan
private
static self|null
$invalidSpan
= null
$kind read-only
private
int
$kind
$links
private
array<string|int, mixed>
$links
$name
private
string
$name
$parentSpanContext read-only
private
SpanContextInterface
$parentSpanContext
$resource read-only
private
ResourceInfo
$resource
$spanLimits read-only
private
SpanLimits
$spanLimits
$spanProcessor read-only
private
SpanProcessorInterface
$spanProcessor
$startEpochNanos read-only
private
int
$startEpochNanos
$status
private
StatusDataInterface
$status
$totalRecordedEvents
private
int
$totalRecordedEvents
= 0
$totalRecordedLinks
private
int
$totalRecordedLinks
Methods
activate()
Adds `$this` to the {@see Context::getCurrent() current context} and makes the new {@see Context} the current context.
public
final activate() : ScopeInterface
Tags
Return values
ScopeInterfaceaddEvent()
public
addEvent(string $name[, iterable<string|int, mixed> $attributes = [] ][, int|null $timestamp = null ]) : self
Parameters
- $name : string
- $attributes : iterable<string|int, mixed> = []
- $timestamp : int|null = null
Tags
Return values
selfaddLink()
Records a link to another `SpanContext`.
public
addLink(SpanContextInterface $context[, iterable<string|int, mixed> $attributes = [] ]) : SpanInterface
Adding links at span creation via is preferred to calling later, for contexts that are available during span creation, because head sampling decisions can only consider information present during span creation.
Parameters
- $context : SpanContextInterface
-
span context to link
- $attributes : iterable<string|int, mixed> = []
-
attributes to associate with the link
Return values
SpanInterface —this span
end()
public
end([int|null $endEpochNanos = null ]) : void
Parameters
- $endEpochNanos : int|null = null
Tags
formatStackTrace()
Backward compatibility methods
public
static formatStackTrace(Throwable $e[, array<string|int, mixed>|null &$seen = null ]) : string
Parameters
- $e : Throwable
- $seen : array<string|int, mixed>|null = null
Tags
Return values
stringfromContext()
Returns the {@see SpanInterface} from the provided *$context*, falling back on {@see SpanInterface::getInvalid()} if there is no span in the provided context.
public
final static fromContext(ContextInterface $context) : SpanInterface
Parameters
- $context : ContextInterface
Tags
Return values
SpanInterfacegetAttribute()
Returns the value of the attribute with the provided *key*.
public
getAttribute(string $key) : mixed
Parameters
- $key : string
Tags
getContext()
public
getContext() : SpanContextInterface
Tags
Return values
SpanContextInterfacegetCurrent()
Returns the current {@see SpanInterface} from the current {@see ContextInterface}, falling back on {@see SpanInterface::getEmpty()} if there is no span in the current context.
public
final static getCurrent() : SpanInterface
Tags
Return values
SpanInterfacegetDuration()
Returns the duration of the {@see API\SpanInterface} in nanoseconds.
public
getDuration() : int
Tags
Return values
intgetInstrumentationScope()
public
getInstrumentationScope() : InstrumentationScopeInterface
Return values
InstrumentationScopeInterfacegetInvalid()
Returns an invalid {@see SpanInterface} that is used when tracing is disabled, such s when there is no available SDK.
public
final static getInvalid() : SpanInterface
Tags
Return values
SpanInterfacegetKind()
public
getKind() : int
Tags
Return values
intgetName()
public
getName() : string
Tags
Return values
stringgetParentContext()
public
getParentContext() : SpanContextInterface
Return values
SpanContextInterfacegetResource()
public
getResource() : ResourceInfo
Return values
ResourceInfogetStartEpochNanos()
public
getStartEpochNanos() : int
Return values
intgetTotalRecordedEvents()
public
getTotalRecordedEvents() : int
Return values
intgetTotalRecordedLinks()
public
getTotalRecordedLinks() : int
Return values
inthasEnded()
public
hasEnded() : bool
Return values
boolisRecording()
public
isRecording() : bool
Tags
Return values
boolrecordException()
public
recordException(Throwable $exception[, iterable<string|int, mixed> $attributes = [] ][, int|null $timestamp = null ]) : self
Parameters
- $exception : Throwable
- $attributes : iterable<string|int, mixed> = []
- $timestamp : int|null = null
Tags
Return values
selfsetAttribute()
public
setAttribute(string $key, mixed $value) : self
Parameters
- $key : string
- $value : mixed
-
Note: arrays MUST be homogeneous, i.e. it MUST NOT contain values of different types.
Tags
Return values
selfsetAttributes()
public
setAttributes(iterable<string|int, mixed> $attributes) : self
Parameters
- $attributes : iterable<string|int, mixed>
Tags
Return values
selfsetStatus()
public
setStatus(string $code[, string|null $description = null ]) : self
Parameters
- $code : string
- $description : string|null = null
Tags
Return values
selfstoreInContext()
Returns a new {@see ContextInterface} created by setting `$this` into the provided [@see ContextInterface}.
public
final storeInContext(ContextInterface $context) : ContextInterface
Parameters
- $context : ContextInterface
Tags
Return values
ContextInterfacetoSpanData()
Returns an immutable representation of this instance.
public
toSpanData() : SpanDataInterface
Return values
SpanDataInterfaceupdateName()
public
updateName(string $name) : self
Parameters
- $name : string
Tags
Return values
selfwrap()
Returns a non-recording {@see SpanInterface} that hold the provided *$spanContext* but has no functionality.
public
final static wrap(SpanContextInterface $spanContext) : SpanInterface
Parameters
- $spanContext : SpanContextInterface
Tags
Return values
SpanInterfacelogDebug()
protected
static logDebug(string $message[, array<string|int, mixed> $context = [] ]) : void
Parameters
- $message : string
- $context : array<string|int, mixed> = []
logError()
protected
static logError(string $message[, array<string|int, mixed> $context = [] ]) : void
Parameters
- $message : string
- $context : array<string|int, mixed> = []
logInfo()
protected
static logInfo(string $message[, array<string|int, mixed> $context = [] ]) : void
Parameters
- $message : string
- $context : array<string|int, mixed> = []
logNotice()
protected
static logNotice(string $message[, array<string|int, mixed> $context = [] ]) : void
Parameters
- $message : string
- $context : array<string|int, mixed> = []
logWarning()
protected
static logWarning(string $message[, array<string|int, mixed> $context = [] ]) : void
Parameters
- $message : string
- $context : array<string|int, mixed> = []
__construct()
private
__construct(non-empty-string $name, SpanContextInterface $context, InstrumentationScopeInterface $instrumentationScope, int $kind, SpanContextInterface $parentSpanContext, SpanLimits $spanLimits, SpanProcessorInterface $spanProcessor, ResourceInfo $resource, AttributesBuilderInterface $attributesBuilder, array<int, LinkInterface> $links, int $totalRecordedLinks, int $startEpochNanos) : mixed
Parameters
- $name : non-empty-string
- $context : SpanContextInterface
- $instrumentationScope : InstrumentationScopeInterface
- $kind : int
- $parentSpanContext : SpanContextInterface
- $spanLimits : SpanLimits
- $spanProcessor : SpanProcessorInterface
- $resource : ResourceInfo
- $attributesBuilder : AttributesBuilderInterface
- $links : array<int, LinkInterface>
- $totalRecordedLinks : int
- $startEpochNanos : int
checkForDroppedElements()
private
checkForDroppedElements() : void
doLog()
private
static doLog(string $level, string $message, array<string|int, mixed> $context) : void
Parameters
- $level : string
- $message : string
- $context : array<string|int, mixed>
shouldLog()
private
static shouldLog(string $level) : bool
Parameters
- $level : string