ttrss/vendor/open-telemetry/context
Andrew Dolgov cdd7ad020e
jaeger-client -> opentelemetry
2023-10-20 21:13:39 +03:00
..
Propagation jaeger-client -> opentelemetry 2023-10-20 21:13:39 +03:00
fiber jaeger-client -> opentelemetry 2023-10-20 21:13:39 +03:00
Context.php jaeger-client -> opentelemetry 2023-10-20 21:13:39 +03:00
ContextInterface.php jaeger-client -> opentelemetry 2023-10-20 21:13:39 +03:00
ContextKey.php jaeger-client -> opentelemetry 2023-10-20 21:13:39 +03:00
ContextKeyInterface.php jaeger-client -> opentelemetry 2023-10-20 21:13:39 +03:00
ContextKeys.php jaeger-client -> opentelemetry 2023-10-20 21:13:39 +03:00
ContextStorage.php jaeger-client -> opentelemetry 2023-10-20 21:13:39 +03:00
ContextStorageHead.php jaeger-client -> opentelemetry 2023-10-20 21:13:39 +03:00
ContextStorageInterface.php jaeger-client -> opentelemetry 2023-10-20 21:13:39 +03:00
ContextStorageNode.php jaeger-client -> opentelemetry 2023-10-20 21:13:39 +03:00
ContextStorageScopeInterface.php jaeger-client -> opentelemetry 2023-10-20 21:13:39 +03:00
DebugScope.php jaeger-client -> opentelemetry 2023-10-20 21:13:39 +03:00
ExecutionContextAwareInterface.php jaeger-client -> opentelemetry 2023-10-20 21:13:39 +03:00
FiberBoundContextStorage.php jaeger-client -> opentelemetry 2023-10-20 21:13:39 +03:00
FiberBoundContextStorageScope.php jaeger-client -> opentelemetry 2023-10-20 21:13:39 +03:00
ImplicitContextKeyedInterface.php jaeger-client -> opentelemetry 2023-10-20 21:13:39 +03:00
README.md jaeger-client -> opentelemetry 2023-10-20 21:13:39 +03:00
ScopeInterface.php jaeger-client -> opentelemetry 2023-10-20 21:13:39 +03:00
ZendObserverFiber.php jaeger-client -> opentelemetry 2023-10-20 21:13:39 +03:00
composer.json jaeger-client -> opentelemetry 2023-10-20 21:13:39 +03:00

README.md

Releases Source Mirror Latest Version Stable

OpenTelemetry Context

Immutable execution scoped propagation mechanism, for further details see opentelemetry-specification.

Installation

composer require open-telemetry/context

Usage

Implicit propagation

$context = Context::getCurrent();
// modify context
$scope = $context->activate();
try {
    // run within new context
} finally {
    $scope->detach();
}

It is recommended to use a try-finally statement after ::activate() to ensure that the created scope is properly ::detach()ed.

Async applications

Fiber support

Requires PHP >= 8.1, an NTS build, ext-ffi, and setting the environment variable OTEL_PHP_FIBERS_ENABLED to a truthy value. Additionally vendor/autoload.php has to be preloaded for non-CLI SAPIs if ffi.enable is set to preload.

Event loops

Event loops have to restore the original context on callback execution. A basic implementation could look like the following, though implementations should avoid keeping unnecessary references to arguments if possible:

function bindContext(Closure $closure): Closure {
    $context = Context::getCurrent();
    return static function (mixed ...$args) use ($closure, $context): mixed {
        $scope = $context->activate();
        try {
            return $closure(...$args);
        } finally {
            $scope->detach();
        }
    };
}

Contributing

This repository is a read-only git subtree split. To contribute, please see the main OpenTelemetry PHP monorepo.