Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Context Laravel Package

open-telemetry/context

OpenTelemetry Context for PHP: immutable, execution-scoped context propagation for tracing and telemetry. Activate/detach scopes for implicit propagation, with debug warnings for scope leaks. Supports async apps with fiber-based propagation and event loop binding.

View on GitHub
Deep Wiki
Context7

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.

Debug scopes

By default, scopes created by ::activate() warn on invalid and missing calls to ::detach() in non-production environments. This feature can be disabled by setting the environment variable OTEL_PHP_DEBUG_SCOPES_DISABLED to a truthy value. Disabling is only recommended for applications using exit / die to prevent unavoidable notices.

Async applications

Fiber support - automatic context propagation to newly created fibers

Requires 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.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope