Telescope
Telescope for plain PHP
Drive the Telescope recorder yourself from any PHP application, worker or framework.
Without Laravel or Symfony, start and finish units of work yourself.
use Inverge\Nexus\Config;
use Inverge\Nexus\NexusClient;
$nexus = new NexusClient(new Config(apiKey: 'nxs_live_xxx'));
$t = $nexus->telescope(['service' => 'orders-api']);
$t->start('request', ['method' => 'GET', 'uri' => '/orders/7'], [
'traceparent' => $_SERVER['HTTP_TRACEPARENT'] ?? null, // join an incoming trace
]);
$t->query('select * from orders where id = ?', [7], 1.8, 'mysql');
$quote = $t->span('price lookup', fn () => $pricing->quote($order));
$t->user(['id' => (string) $user->id, 'email' => $user->email]);
$t->log('info', 'order loaded', ['id' => 7]);
$t->finish(['responseStatus' => 200], '200'); // delivered here (or at shutdown)API
| Method | Purpose |
|---|---|
start($type, $content, $context) | Begin a unit of work (request, job, command, schedule). Nested starts stack — a sync job inside a request is its own batch in the same trace. |
finish($content, $status, $name) / finishAll() | End the current (or every open) unit of work and deliver it. |
record($type, $content, $opts) | Any entry type. |
span($name, $fn) · openSpan() / closeSpan() | Timed spans; entries inside nest under them. |
query($sql, $bindings, $ms, $connection) | A query. |
exception($e, $handled) · log($level, $message) | Filed in Errors / Logs as well. |
user([...]) · tag(...$tags) | Attribute and tag the journey. |
traceparent() · propagation() | Headers / payload fields to carry the trace to an HTTP call or a queued job. |
flush() | Deliver now. |
A shutdown hook records fatal errors (including timeouts) on the open journey before the process exits.
Carrying the trace
// Outgoing HTTP
$headers = ['traceparent' => $t->traceparent()];
// Queue producer → consumer
$payload = ['order' => 7, 'nexusTelescope' => $t->propagation()]; // {traceId, parentSpanId}
// … in the worker
$t->start('job', ['name' => 'SendInvoice'], $payload['nexusTelescope'] ?? []);