Download the PHP package shyim/akari without Composer
On this page you can find all versions of the php package shyim/akari. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package akari
Short Description A high-performance PHP observability extension. Automatic OpenTelemetry tracing, sampling, and profiling - zero-config, near-zero overhead.
License MIT
Informations about the package akari
Akari — 灯
A high-performance PHP APM extension.
Automatic distributed tracing — exported as OpenTelemetry.
[!WARNING] This project is still a work in progress and is not yet ready for production use. APIs, configuration, and internals may change at any time.
Akari (灯, "light") is a PHP C extension that illuminates your application's behavior. It hooks into the Zend Engine via the official zend_observer API to capture database queries, HTTP requests, cache and messaging calls, framework internals, and exceptions — all exported as standard OpenTelemetry traces to any OTLP-compatible collector (Jaeger, Grafana Tempo, Honeycomb, etc.).
Key design goals:
- Zero-config for 90% of use cases — drop in, get traces
- Near-zero overhead — fire-and-forget UDP, frame deduplication, per-hook thresholds
- No vendor lock-in — standard OTLP protocol, use any collector
Architecture
Spans are serialized as compact msgpack and sent via UDP to a local Go forwarder, which batches and forwards them to your OTLP collector. Log records emitted with Akari\log() travel the same UDP path and are forwarded to the collector's /v1/logs endpoint (spans go to /v1/traces).
Quick Start
Install the extension (recommended)
Install Akari with PIE, the PHP Installer for Extensions:
Then enable it in your php.ini (see Configure below).
Run the forwarder (Docker)
The forwarder is available as a container image:
Build from source
1. Build the extension
Add
--enable-akari-debugto compile in the debug introspection functions (getSpansJson, etc.). This is for testing/debugging only — leave it off for production builds.
2. Build the forwarder
3. Configure
4. Start the forwarder
Then restart PHP-FPM or run your CLI app. Traces will appear in your collector within seconds.
Instrumentation Coverage
Database & Cache
| System | What's traced | Attributes |
|---|---|---|
| PDO | query, exec, prepare, beginTransaction, commit, rollback |
db.system, db.name, db.statement, db.user |
| SQLite3 | query, querySingle, exec, prepare, SQLite3Stmt::execute (SQL recovered from prepare) |
db.system=sqlite, db.statement |
| MySQLi | OOP + procedural, connect, prepare, execute, transactions |
db.system=mysql, SQL statement |
| OCI8 / Oracle | oci_parse, oci_execute, oci_connect, oci_commit, oci_rollback |
db.system=oracle |
| Redis / RedisCluster | 150+ commands with key extraction (phpredis + Relay) | db.system=redis, db.statement=GET key |
| Predis | Client::executeCommand |
db.system=redis, command + key |
| Memcached / Memcache | All get/set/delete/touch etc. |
db.system=memcached, SET key |
| Elasticsearch | v7, v8, OpenSearch clients | db.system=elasticsearch |
HTTP & RPC
| System | What's traced | Attributes |
|---|---|---|
| curl | curl_exec, curl_multi_*, curl_setopt, header injection |
url.full, http.method, http.status_code, server.address |
| HTTP streams | fopen, file_get_contents for http:// URLs |
Same HTTP attributes as curl |
| gRPC | Grpc\Call::__construct, startBatch |
db.system=grpc, method name |
| SOAP | SoapClient::__doRequest |
db.system=soap, endpoint + action |
Messaging
| System | What's traced | Attributes |
|---|---|---|
| AMQP / php-amqplib | publish, consume, connect |
messaging.system=rabbitmq, exchange/queue, traceparent propagation |
| rdkafka | Producer::produce, flush, poll, transactions |
db.system=kafka, topic |
| Pheanstalk (Beanstalkd) | dispatchCommand |
db.system=beanstalkd, command name |
Frameworks
| Framework | What's traced |
|---|---|
| Symfony | HttpKernel, EventDispatcher, HttpCache, Mailer, Messenger, Console |
| Laravel | Kernel, Queue worker, Events, Blade, Eloquent Builder |
| Shopware 6 | Kernel, DAL (EntityRepository), Cache, Events, Storefront |
| Doctrine ORM | EntityManager::flush |
| Twig | Template render, block render, wrapper |
| GraphQL | executeQuery, Parser, Executor (webonyx/graphql-php) |
Built-in PHP Functions
Functions that can introduce latency are traced with configurable thresholds:
| Category | Functions | Threshold |
|---|---|---|
| PCRE / Regex | preg_match, preg_replace, etc. |
1ms (only slow patterns traced) |
| Filesystem | fopen, fread, fwrite, copy, rename, mkdir, stat, etc. (30+) |
1ms |
| Password | password_hash (always), password_verify |
1ms |
| APCu | apcu_fetch, apcu_store, apcu_delete, etc. |
0.5ms |
| Session | session_start, session_write_close |
1ms |
| DNS | gethostbyname, dns_get_record, checkdnsrr, getmxrr |
Always |
| Shell | exec, shell_exec, system, proc_open, popen |
Always |
mail, mb_send_mail |
Always | |
| Sleep | sleep, usleep, time_nanosleep |
Always |
Engine-Level
| Hook | Purpose | INI Gate |
|---|---|---|
| Exception hook | Catches ALL exceptions at Zend Engine level, marks spans as ERROR | Always on |
| Compile file | Profiles zend_compile_file time per file |
akari.trace_compile |
| GC cycles | Profiles gc_collect_cycles duration |
akari.trace_gc |
| Stack trace capture | Captures full PHP backtrace onto spans on demand | API |
INI Settings
| Setting | Default | Description |
|---|---|---|
akari.enable |
0 |
Enable tracing |
akari.service_name |
(empty) | OTel service name. When unset, falls back to the OTEL_SERVICE_NAME env var, then to php |
akari.max_depth |
64 |
Max call stack depth (1–256, clamped) |
akari.min_duration_ms |
0 |
Drop spans shorter than this (global threshold) |
akari.event_dispatch_min_duration_ms |
1 |
Drop fast Symfony/Shopware event dispatch spans while preserving other instrumentation |
akari.udp_host |
127.0.0.1 |
Forwarder UDP host |
akari.udp_port |
4319 |
Forwarder UDP port |
akari.trace_compile |
0 |
Profile file compilation time |
akari.trace_gc |
0 |
Profile GC collect cycles time |
akari.trace_cli |
1 |
Auto-create a root span for CLI runs, named after the command (e.g. php console asset:install, using the script basename). The full command line (PHP executable + arguments) is recorded as the process.command_line attribute. Disable to skip the entry span unless markAsWebTransaction() is called |
akari.flush_threshold |
4096 |
Completed spans buffered before a mid-request flush |
akari.traces_sampler |
(empty) | Trace sampler with standard OTEL_TRACES_SAMPLER values (always_on, always_off, traceidratio, parentbased_always_on, parentbased_always_off, parentbased_traceidratio). When unset, falls back to the OTEL_TRACES_SAMPLER env var, then to parentbased_always_on. Parent context comes from the traceparent header (web) or the TRACEPARENT env var (CLI); unsampled requests are dropped before any instrumentation runs |
akari.traces_sampler_arg |
(empty) | Ratio for the traceidratio samplers (0.0–1.0). When unset, falls back to OTEL_TRACES_SAMPLER_ARG, then to 1.0 |
Akari only creates spans for the function calls covered by its built-in instrumentation hooks (databases, HTTP clients, caches, messaging, frameworks) plus the per-request root span. There is no "trace every function" or sampling profiler mode — instrumentation is targeted, APM-style.
Recommended Configurations
Production (minimum overhead):
Development (more detail):
PHP Userland API
Debug introspection (debug builds only)
These functions are compiled in only when the extension is built with
--enable-akari-debug. They are used by the test suite and for local
debugging, and are absent from production builds:
Forwarder Configuration
| Env Variable | Default | Description |
|---|---|---|
OTEL_EXPORTER_OTLP_ENDPOINT |
http://localhost:4318 |
Collector endpoint |
OTEL_EXPORTER_OTLP_HEADERS |
(none) | Comma-separated key=value headers added to every request (e.g. api-key=secret); values are percent-decoded |
OTEL_FORWARDER_LISTEN |
127.0.0.1:4319 |
UDP listen address |
OTEL_FORWARDER_BUFFER_SIZE |
16384 |
Max queued payloads |
OTEL_FORWARDER_BATCH_SIZE |
64 |
Payloads per flush |
OTEL_FORWARDER_FLUSH_INTERVAL |
100ms |
Max batching window |
Production Readiness
| Area | Status |
|---|---|
| Memory safety | ASAN-verified, no leaks, bounded allocations |
| Overhead when off | Minimal — callbacks check activation; cURL header bookkeeping remains active for manual enable |
| Exception tracking | Engine-level hook catches all exceptions, even caught ones |
| Extensibility conflicts | Uses official zend_observer API — compatible with Xdebug, OPcache |
| Cross-platform | macOS (kqueue) + Linux (timer_create / SIGEV_THREAD_ID) |
| Thread safety (ZTS) | Full ZTS support via ZEND_MODULE_GLOBALS |
| Span limit | 256K spans max per request (overflow → warning + drop) |
| Frame limit | 64K deduplicated frames max |
| Stack depth | Clamped to 256, defaults to 64 |
| SQL normalization | Query fingerprinting for grouping in dashboards |
Span Examples
Database
HTTP
Cache
Messaging
Exceptions
Project Structure
Testing
Performance benchmarks for PHP tracing and the Go forwarder run through CodSpeed. See the benchmark guide for workloads, local commands, and CI setup.
CI runs automatically on every push and PR via GitHub Actions:
Requirements
- PHP 8.2+
- macOS or Linux
- Go 1.26+ (for the forwarder)
License
MIT