OpenTelemetry PHP

Span extends Span
in package
implements ReadWriteSpanInterface uses LogsMessagesTrait

FinalYes

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

$endEpochNanos

private int $endEpochNanos = 0

$hasEnded

private bool $hasEnded = false

$invalidSpan

private static self|null $invalidSpan = null

$kind read-only

private int $kind
private array<string|int, mixed> $links

$name

private string $name

$startEpochNanos read-only

private int $startEpochNanos

$totalRecordedEvents

private int $totalRecordedEvents = 0
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
inheritDoc
Return values
ScopeInterface

addEvent()

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
inheritDoc
Return values
self

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
inheritDoc

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
codeCoverageIgnore
Return values
string

fromContext()

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
inheritDoc
Return values
SpanInterface

getAttribute()

Returns the value of the attribute with the provided *key*.

public getAttribute(string $key) : mixed
Parameters
$key : string
Tags
inheritDoc

getCurrent()

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
inheritDoc
Return values
SpanInterface

getDuration()

Returns the duration of the {@see API\SpanInterface} in nanoseconds.

public getDuration() : int
Tags
inheritDoc
Return values
int

getInvalid()

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
inheritDoc
Return values
SpanInterface

getKind()

public getKind() : int
Tags
inheritDoc
Return values
int

getName()

public getName() : string
Tags
inheritDoc
Return values
string

getStartEpochNanos()

public getStartEpochNanos() : int
Return values
int

getTotalRecordedEvents()

public getTotalRecordedEvents() : int
Return values
int
public getTotalRecordedLinks() : int
Return values
int

hasEnded()

public hasEnded() : bool
Return values
bool

isRecording()

public isRecording() : bool
Tags
inheritDoc
Return values
bool

recordException()

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
inheritDoc
Return values
self

setAttribute()

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
inheritDoc
Return values
self

setAttributes()

public setAttributes(iterable<string|int, mixed> $attributes) : self
Parameters
$attributes : iterable<string|int, mixed>
Tags
inheritDoc
Return values
self

setStatus()

public setStatus(string $code[, string|null $description = null ]) : self
Parameters
$code : string
$description : string|null = null
Tags
inheritDoc
Return values
self

updateName()

public updateName(string $name) : self
Parameters
$name : string
Tags
inheritDoc
Return values
self

logDebug()

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
Return values
bool

        
On this page

Search results