switon / langfuse
Langfuse OTLP export of LLM chat lifecycle events for Switon Framework
v1.0.0
2026-08-22 14:34 UTC
Requires
- php: >=8.3
- ext-json: *
- ext-mbstring: *
- psr/log: ^2.0|^3.0
- switon/ai: ^1.0
- switon/core: ^1.0
- switon/event: ^1.0
- switon/http-client: ^1.0
- switon/llm: ^1.0
- switon/sync: ^1.0
- switon/tooling: ^1.0
Requires (Dev)
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^2.0
- psr/event-dispatcher: ^1.0
- switon/di: ^1.0
- switon/testing: ^1.0
Suggests
- ext-swoole: Queues exports through one consumer coroutine so a trace's spans reach Langfuse in order; without it exports are sent inline.
Provides
None
Conflicts
None
Replaces
None
README
Langfuse OTLP export for Switon LLM traffic: conversation traces, per-call token usage, and tool spans, driven by the events the framework already dispatches.
Highlights
- No instrumentation calls: listeners map
CompletionResponded,CompletionFailed,ToolFinished, andTurnSuspended. - Trace identity from the domain: a turn id becomes the OTLP trace id; sub-agent threads share their host session.
- Usage that prices correctly: input, cache, output, and reasoning tokens go out as exclusive buckets.
- Off by default: nothing is exported until a Langfuse host is configured.
Installation
composer require switon/langfuse
Quick Start
Set the host and keys; the listener registers itself during boot.
# switon.yml Switon\Langfuse\ClientInterface: baseUrl: https://cloud.langfuse.com publicKey: pk-lf-... secretKey: sk-lf-...
Docs: https://github.com/switon-php/langfuse/blob/main/docs/README.md
License
MIT.