Download the PHP package golovanov/traceloom without Composer

On this page you can find all versions of the php package golovanov/traceloom. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package traceloom

Traceloom

A lightweight PHP library for recording structured event timelines grouped by trace ID.

Traceloom is for small PHP APIs, backend services, jobs, webhooks, and scripts where you want to reconstruct what happened during one logical process without running a full observability stack.

It is not a replacement for Monolog, OpenTelemetry, or a distributed tracing platform.

Installation

Quick Start

All events written through the same Trace object share the same trace_id.

The payload can be any PHP array. It is always written as a JSON object: an empty payload as {}, a list as {"0": ..., "1": ...}.

JSONL Output

Fields come in this order: timestamp, trace_id, parent_trace_id (only for a continued trace), event, sequence, elapsed_ms, data. The format is shared with the JS and Go implementations: a file written by one is read by the others.

A nested empty array is written as [], even where you meant an empty map: PHP does not distinguish the two. Only the top-level data is always an object.

Continue An Existing Trace

Invalid incoming IDs are replaced with a generated ID. Generated IDs are 32-character random hex strings.

An incoming ID is not trusted by default: it is recorded as parent_trace_id and a fresh ID is generated. Behind a gateway that sets the header itself, opt in to reusing it (see Trusting Incoming Trace IDs).

Finding A Trace

After installing Traceloom as a dependency, Composer exposes the bundled CLI through vendor/bin:

When working inside the Traceloom source repository itself, run the package binary directly:

Example output:

The MVP CLI intentionally includes only show. More commands such as tail or event search belong in a later phase.

Configuration

maxRecordBytes is clamped to maxFileBytes, and maxStringBytes to maxRecordBytes, so a single event can never overflow a shard.

Traceloom writes files by date and rotates into shards when the active file grows beyond maxFileBytes:

The active file handle is reused across events; the directory lock is taken only when a shard has to be selected or rotated.

File Permissions

Log directories are created 0750 and files 0640, so they are not world-readable. Both are configurable via directoryMode and fileMode.

Trace files hold request bodies, user identifiers, and (despite masking) potentially sensitive values. Keep the log directory outside your web root so it cannot be fetched over HTTP. Traceloom cannot enforce this for you.

Sensitive Data

Sensitive key masking is enabled by default and runs recursively. Keys are compared after folding case and removing everything but letters and digits, so api_key, apiKey, API-KEY all become apikey. Built-in keys: password, passwd, pwd, token, access_token, refresh_token, authorization, proxy_authorization, auth, bearer, jwt, cookie, set_cookie, api_key, x_api_key, access_key, secret_key, secret, client_secret, private_key, credentials, signature, session, session_id, csrf, csrf_token.

By default a key is also masked if it contains a secret fragment: password, passwd, secret, token, apikey, accesskey, privatekey, credential, authorization, cookie, session, bearer, jwt, signature. So user_password, stripe_secret and aws_access_key_id are caught. Set strictSensitiveKeys: true to require a whole-key match instead.

The JS implementation uses the same two lists.

Masked values are written as:

Custom keys are merged with the defaults through sensitiveKeys. To see what a configuration masks:

Masking is keyed on names, not values: a secret placed under an innocuous key (note, body) is not detected. Do not pass raw credentials under arbitrary keys.

Trusting Incoming Trace IDs

An inbound trace ID is not trusted by default. On a public endpoint the header is attacker-controlled, and a client that guesses or replays another request's ID could otherwise write its own events into that trace and corrupt an investigation. The incoming value is stored as parent_trace_id, and a fresh ID is generated:

Behind a gateway or service mesh that sets the header itself, opt in to reusing it so a single ID spans the whole call chain:

Payload Limits

Long strings are replaced with explicit truncation metadata (the preview is cut on a UTF-8 code-point boundary, never mid-character):

Supported payload values are arrays, strings, integers, floats, booleans, null, JsonSerializable, Throwable, and Stringable.

NAN, INF and -INF have no JSON form; they are written as the strings "NaN", "Infinity" and "-Infinity".

An exception is written as its type and message, with its previous exception as cause:

The stack trace, file, line and code are not written: the trace carries server paths and is large. Pass it explicitly if you need it. Each cause is one level deeper, so a long chain ends in [MAX_DEPTH_EXCEEDED]. An exception that implements JsonSerializable is written through jsonSerialize().

Other cases are replaced with an explicit marker rather than being allowed to break the write:

Marker Cause
{"_binary": true, ...} String is not valid UTF-8 (preview is hex)
[CIRCULAR_REFERENCE] Value refers back to itself
[MAX_DEPTH_EXCEEDED] Nesting deeper than maxDepth
[SERIALIZATION_FAILED: Class] A jsonSerialize()/__toString() threw
[UNSUPPORTED_TYPE: type] Value is a resource or other unsupported type
{"_omitted_items": N} Entries dropped past maxArrayItems or maxPayloadNodes

Two independent limits bound a payload. maxArrayItems caps each array on its own, so one long list cannot push its sibling fields out of the event; maxPayloadNodes caps the payload as a whole, which is what stops a wide or deeply nested input bomb.

Keys are bounded too. A key longer than maxKeyBytes is cut on a code-point boundary and given a digest of the original key, so that keys sharing a long prefix stay distinct instead of collapsing into one and overwriting each other:

The result is an ordinary string key — no JSONL consumer has to change — and the mapping is deterministic across processes, runs, and the PHP, JS and Go implementations alike. Masking is decided on the original key, so truncation cannot smuggle a secret past it.

A key that is not valid UTF-8 (a cp1251 form field, ?%E8%EC%FF=1) gets the same treatment: each invalid byte becomes U+FFFD, then the key is bounded by maxKeyBytes, and the digest of the original bytes is appended, so two such keys, or such a key and a real one spelled with U+FFFD, never overwrite each other:

Masking is decided on the original key here too. The cross-implementation guarantee above covers valid UTF-8 keys only: for invalid ones the PHP mapping is fixed, but the JS and Go implementations do not yet produce the same key.

If a whole event still cannot be encoded, its data is replaced with {"_encoding_error": "..."} so the event stays in the timeline instead of vanishing. That is a real loss of data, so it is counted — see Error Handling.

Reserved Keys

_truncated, _binary, _encoding_error and _omitted_items belong to the sanitizer. A payload key that spells one of them gains a leading underscore (_truncated → __truncated), so a record cannot claim to be sanitizer output when it is not, and a genuine marker can never overwrite a field of yours. The escape is itself escaped, so the mapping back is unambiguous.

HTTP Integration

For new integrations, prefer X-Trace-Id:

The header is quarantined as parent_trace_id unless you opt in (see Trusting Incoming Trace IDs).

If your system already uses X-Request-Id for request correlation, it is fine to continue that trace:

Minimal request flow:

Framework adapters for PSR-7, Laravel, Symfony, or custom frameworks are intentionally outside the MVP core.

Error Handling

Tracing is fail-safe by default: write errors should not break the main application.

Use failOnError: true when you want tracing failures thrown instead of passed to onError, usually in tests or strict local development. A failure goes to one of the two, never both.

Configuration errors always throw. An empty event name always throws too — it is a programming error, not a runtime failure — regardless of failOnError.

Even in fail-safe mode data can be lost, in two different ways, and neither is silent:

An event is dropped when the write fails (a full disk, a permission error). It is degraded when its payload could not be encoded or exceeded maxRecordBytes: the record survives with data replaced by {"_encoding_error": "..."}, because an event with a placeholder is worth more than a hole in the timeline. A dropped event is passed to onError, or thrown instead with failOnError. A degraded event is always passed to onError and never thrown, even with failOnError: it was written.

A dropped event leaves a gap in sequence. That gap is deliberate: the counters above live in the process's memory and die with it, while the log file outlives both, so the gap is the only signal to whoever reads the JSONL later that the timeline is incomplete.

What each call guarantees once it returns:

Call Guarantee
$trace->event() the record is handed to the OS: it survives a crash of the process
$tracer->flush() the file is synced (fsync): it survives a crash of the OS or a power loss
$tracer->close() flush(), then the file is released; terminal and idempotent

After close(), events are rejected and counted as dropped rather than reopening the file, and flush() does nothing. A failed flush() or close() is passed to onError, or thrown instead with failOnError; it is not counted as a dropped event.

When the tracer is destroyed, the file handle is released without a sync. Call close() at the end of a job if its trace must survive a power loss.

Writing To Your Own Destination

Tracer::fromConfiguration() writes JSONL files. To write elsewhere, implement Golovanov\Traceloom\Writer\WriterInterface and pass it to the constructor:

write(TraceEvent $event): ?string reports what happened to the event:

flush() and close() carry the guarantees from the table above; an exception they throw is passed to onError, or rethrown with failOnError, without counting a dropped event. close() is terminal: a write() after it must throw. The tracer keeps the counters and calls onError or throws, so a writer does neither.

$event->toArray() gives the record in field order, with data as a \stdClass; the payload as an array is $event->data. The built-in writer encodes the record with JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_THROW_ON_ERROR; a bare json_encode() escapes / and non-ASCII characters, which is valid JSON but not byte-for-byte the same line. When the payload cannot be written (it fails to encode, or is too large for your destination), write $event->toDegradedArray($reason) instead, which keeps the event with data replaced by {"_encoding_error": $reason}, and return $reason.

Checking That Traces Can Be Written

A health check can ask whether this process can write today's trace, without writing one:

writeProblem() returns the first problem it finds, or null if it finds none. It checks that the log directory is writable (a missing one counts when its nearest existing parent is, since the writer creates it), and that the lock file and today's current shard are writable if they exist. It creates no file and changes no permission.

This is a permission check, not a guarantee: null does not promise that the next write succeeds (a full disk, an ACL the check cannot see), and a reported problem does not always mean it fails. Treat it as a signal for a health check, and keep watching droppedEventCount().

Run the check in the process that writes the traces, as the same user. A check from a CLI command or cron job under another user can pass while PHP-FPM drops events.

Pass the configuration your tracer uses: the current shard depends on maxFileBytes. Tracer::fromDirectory($dir) is the same as Tracer::fromConfiguration(Configuration::create(logDirectory: $dir)), so for such a tracer pass Configuration::create(logDirectory: $dir).

"Today" is the UTC date, as for the shard names, taken from the system clock. Pass a second argument only if you built the tracer with new Tracer(...) and your own clock: give the same Golovanov\Traceloom\Clock\ClockInterface instance.

When Not To Use Traceloom

Use Monolog if you need a general-purpose logging framework.

Use OpenTelemetry if you need industry-standard distributed tracing.

Use a log platform or observability stack if you need aggregation, dashboards, alerting, retention policy, or cross-service querying.

Traceloom is intentionally small: local structured timeline tracing without external infrastructure.


All versions of traceloom with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package golovanov/traceloom contains the following files

Loading the files please wait ...