Search by

ctxflow / otel-prism

OscarRoLlo

ctxflow for Laravel/Prism: GenAI spans for the text and structured calls of Laravel Prism, exported to ctxflow by ctxflow/otel.

v0.2.5 2026-12-02 21:34 UTC

This package is auto-updated.

Last update: 2026-12-02 21:34:47 UTC


README

Read-only mirror of packages/otel-prism in ctxflow-sh/ctxflow-edge. Open issues and pull requests there.

ctxflow/otel-prism

ctxflow for Laravel/Prism: GenAI spans for the calls of Laravel Prism (prism-php/prism 0.103.x), exported to ctxflow by ctxflow/otel, which it requires. Needs PHP 8.2+ and Laravel 12 or 13 (illuminate/support).

composer require ctxflow/otel-prism

Call Ctxflow\Otel\Ctxflow::init() once. Laravel's package discovery registers CtxflowPrismServiceProvider, which decorates the container's PrismManager; every Prism::text() and Prism::structured() call, with any Prism provider, then gets a chat <model> span (CLIENT) per LLM call: provider, request and response model, response id, token usage (cache reads and writes included in gen_ai.usage.input_tokens, and given apart), input and output messages, finish reason, and on a failure error.type and the error status. A tool loop (several steps in one Prism call) leaves one sibling span per step under the current span. Wrap an agent turn in Ctxflow\Otel\agentTurn(). Without discovery, call PrismInstrumentation::install($app) from your own service provider.

Hook choice, limits (streams, embeddings, images and audio are not traced; the timing of the steps of a tool loop is the call's wall time split equally; instanceof on a provider sees the decorator) and the details: Laravel Prism. Example: examples/php/prism/. Apache-2.0.

Development

composer install
vendor/bin/phpstan analyse && vendor/bin/php-cs-fixer fix --dry-run --diff

Tier 2 is the prism-openai-chat scenario, played by the PHP driver of the repository (uv run python conformance/harness.py compare php).