onematrix/tracing-sdk
A lightweight tracing SDK for Laravel and PHP applications. Instrument requests, jobs, and custom spans to capture timing and context, then export traces to your observability backend. Simple APIs help you add distributed tracing without heavy dependencies.
Architecture fit
onematrix/tracing-sdk is not a Laravel package in the conventional sense — it is a framework-agnostic PHP client with a single, narrow responsibility: take a payload, canonicalize it (RFC 8785 JCS for JSON, W3C C14N for XML), hash it with Keccak-256, and POST the resulting record to an external Indexer service. Architecturally that makes it an outbound adapter, not a service layer. It slots in cleanly as an anti-corruption layer at the edge of a bounded context: your domain emits data, the SDK normalizes and fingerprints it, the Indexer stores it.
The fit is good if — and only if — you have a genuine data-integrity / tamper-evidence / provenance requirement (audit trails, regulatory attestation, chain-of-custody, document notarization). It is a poor fit as a general observability or tracing tool despite the name; there is no span model, no sampling, no context propagation. The package name is misleading and will cause scope confusion in stakeholder conversations — flag this early.
Secondary fit consideration: the SDK implies a hard runtime dependency on a separately operated Indexer. You are not adopting a library, you are adopting a two-party system. That is a product decision, not just a technical one.
Integration feasibility
Mechanically straightforward: composer require, construct a client with an endpoint + credentials, call a record-emitting method. Small surface area, low learning curve. The real feasibility questions are dependency and contract:
| Area | Assessment |
|---|---|
| PHP version | Needs verification; assume 8.1+ given modern typing and hash usage |
| Keccak-256 | Highest-risk dependency. PHP's hash('sha3-256') is not Keccak-256 (SHA-3 was standardized with different padding). Expect a polyfill dependency (kornrunner/keccak) requiring GMP or pure-PHP fallback — a material CPU cost |
| XML C14N | Low risk — PHP's DOMNode::C14N() is native and well-tested |
| JSON JCS (RFC 8785) | Moderate risk — requires ECMAScript-compatible number serialization and UTF-16 code-unit key sorting. PHP's json_encode float handling diverges. Verify with the RFC's reference test vectors |
| HTTP transport | Verify whether it uses Guzzle, Symfony HttpClient, or raw cURL; affects version-conflict surface and whether Laravel's Http facade / fakes can be used in tests |
| Laravel integration | No service provider, facade, or publishable config expected — you will write ~150 lines of glue |
Technical risk
Key questions for the maintainer
Stack fit
Laravel 9–11 / PHP 8.1+. Because the package is framework-agnostic, conflict risk with existing dependencies is low except for the HTTP client and Keccak polyfill. Recommended placement:
Domain event / model observer
↓
IntegrityRecordBuilder (your code — owns payload shape)
↓
onematrix/tracing-sdk (canonicalize + hash)
↓
Queued Job (retries, backoff, DLQ)
↓
IndexerClient (wraps SDK transport, adds correlation IDs + metrics)
Wrap the SDK. Never call it from controllers, models, or Eloquent events directly. Bind it in a dedicated service provider with config from config/integrity.php and credentials in the secret store.
Migration path
Additive — there is nothing to migrate away from. Two caveats:
Compatibility
ext-gmp (or ext-bcmath) availability across your fleet and CI images — this is the most likely deployment surprise.Sequencing
| Phase | Scope | Gate to proceed |
|---|---|---|
| 1. Spike (1–2 days) | Install in a scratch app; hash 20 representative payloads; verify against an independent implementation (Node canonicalize + ethereum-cryptography) |
Independent verifier reproduces every hash |
| 2. Contract review (2–3 days) | Read the source end to end; confirm transport, error handling, timeout behavior; document the Indexer API contract | No blocking calls, error semantics understood |
| 3. Wrapper + queue (1 sprint) | Service provider, config, DTO, queued job, retries, DLQ, metrics, Http::fake-style test double |
100% test coverage on the wrapper; failure injection passes |
| 4. Pilot (2–4 weeks) | One bounded, low-volume use case behind a feature flag; measure p99 overhead and Indexer error rate | Overhead < 5ms CPU per record; error rate within SLO |
| 5. GA | Expand use cases; add runbook, alerting, on-call ownership | Runbook reviewed; owner named |
Do not skip Phase 1. The cost of discovering a canonicalization divergence in production is a full audit-record re-issuance, not a bug fix.
Maintenance
You are taking on ownership of a dependency nobody else uses. Budget for: quarterly review of upstream commits (there may be none), a vendored fork if the maintainer disappears, and internal documentation of the canonicalization contract because upstream docs are likely thin. Realistically, plan for the possibility that you will own this code within 12 months — factor that into the build-vs-buy comparison. The SDK's actual logic is a few hundred lines; a first-party implementation is a credible alternative and removes the supply-chain question entirely.
Support
No community, no SLA, no Stack Overflow corpus, no CVE history (nothing to have CVEs in yet — which is not the same as being secure). Support is entirely internal. Name a technical owner before Phase 3, not after.
Scaling
Cost is dominated by two things: canonicalization CPU (JSON tree rebuild + sort; XML DOM parse) and Keccak throughput. Pure-PHP Keccak is roughly an order of magnitude slower than the C extension. Model it:
Failure modes
| Failure | Symptom | Mitigation |
|---|---|---|
| Indexer 5xx / timeout | Records dropped or requests slow | Async queue, exponential backoff, DLQ, circuit breaker |
| Indexer accepts but does not persist | Silent record loss | Require and store a receipt/sequence ID; reconcile on a schedule |
| Canonicalization divergence | Hashes fail external verification | Conformance tests in CI against reference vectors + independent verifier |
| Non-deterministic float/Unicode serialization | Same logical payload → different hash | Restrict payload schema to strings/ints; ban floats in integrity-bearing fields |
Missing ext-gmp in a new environment |
Fatal error at first record | Add extension to CI image, Dockerfile, and deploy checklist |
| Payload contains PII | Compliance exposure | Redact/allowlist fields before handing to the SDK; log payload size only, never content |
| Duplicate emission (queue retry) | Duplicate records in Indexer | Deterministic idempotency key = the hash itself; confirm Indexer dedupes on it |
| Payload too large | 413 from Indexer | Size cap enforced client-side with a metric and alert |
Ramp-up
Low for the API — a mid-level engineer is productive in half a day. Moderate for the semantics: engineers must understand why canonicalization exists, why Keccak ≠ SHA-3, why you cannot change the payload shape without invalidating history, and why the hash must never be computed on data that has already been transformed. That is a 1-hour team session plus a short ADR, and it should be mandatory before anyone touches the emit path.
Bottom line for a go/no-go: the technical integration is cheap; the trust investment is not. Gate on Phase 1 hash verification and a named owner. If either fails, build the ~300 lines in-house — you will get equivalent function, no supply-chain exposure, and full control over the one thing that actually matters here: the canonicalization contract.
How can I help you explore Laravel packages today?