OpenTelemetry PHP

Context
in package
implements ContextInterface

FinalYes
Tags
see
https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/context/README.md#context

Table of Contents

Interfaces

ContextInterface
Immutable execution scoped propagation mechanism.

Constants

OTEL_PHP_DEBUG_SCOPES_DISABLED  = 'OTEL_PHP_DEBUG_SCOPES_DISABLED'

Properties

$context  : array<int, mixed>
$contextKeys  : array<int, ContextKeyInterface>
$span  : object|null
$spanContextKey  : ContextKeyInterface
$storage  : ContextStorageInterface|ExecutionContextAwareInterface

Methods

activate()  : ScopeInterface
Attaches this context as active context.
createKey()  : ContextKeyInterface
Creates a new context key.
get()  : T|null
Returns the value assigned to the given key.
getCurrent()  : ContextInterface
Returns the current context.
setStorage()  : void
storage()  : ContextStorageInterface|ExecutionContextAwareInterface
with()  : ContextInterface
Returns a context with the given key set to the given value.
withContextValue()  : ContextInterface
Returns a context with the given value set.
__construct()  : mixed
debugScopesDisabled()  : bool

Constants

OTEL_PHP_DEBUG_SCOPES_DISABLED

private mixed OTEL_PHP_DEBUG_SCOPES_DISABLED = 'OTEL_PHP_DEBUG_SCOPES_DISABLED'

Properties

$context

private array<int, mixed> $context = []

$span

private object|null $span = null

Methods

activate()

Attaches this context as active context.

public activate() : ScopeInterface

The returned scope has to be ed. In most cases this should be done using a try-finally statement:

$scope = $context->activate();
try {
    // ...
} finally {
    $scope->detach();
}
Return values
ScopeInterface

scope to detach the context and restore the previous context

get()

Returns the value assigned to the given key.

public get(ContextKeyInterface $key) : T|null
Parameters
$key : ContextKeyInterface

key to get

Return values
T|null

value assigned to $key, or null if no such value exists

__construct()

private __construct() : mixed

debugScopesDisabled()

private static debugScopesDisabled() : bool
Return values
bool

        
On this page

Search results