gosuperscript/axiom-tracing
Composer 安装命令:
composer require gosuperscript/axiom-tracing
包简介
Opt-in resolution tracing for gosuperscript/axiom
README 文档
README
Opt-in resolution tracing for gosuperscript/axiom. Decorates DelegatingResolver to build a tree-shaped trace that mirrors the recursive resolution call stack, capturing timing, outcomes, and resolver-contributed metadata on each node.
Installation
composer require gosuperscript/axiom-tracing
Requires gosuperscript/axiom ^0.4.0.
Usage
Conditional tracing with callback
use Superscript\Axiom\Context; use Superscript\Axiom\Resolvers\DelegatingResolver; use Superscript\Axiom\Tracing\Tracing; use Superscript\Axiom\Tracing\TracedResult; use Superscript\Axiom\Tracing\TracingResolver; $resolver = Tracing::wrap( new DelegatingResolver([...]), enabled: config('axiom.tracing', false), ); // Register a callback — fires on every top-level resolution if ($resolver instanceof TracingResolver) { $resolver->onTrace(function (TracedResult $traced) { Log::debug('Axiom resolution', ['trace' => $traced->dump()]); }); } // Calling code is unchanged — resolve takes a Source and a Context. $result = $resolver->resolve($source, new Context());
Tracing an Expression
use Superscript\Axiom\Expression; $expression = new Expression($source, $resolver); $result = $expression(['radius' => 5]); // fires the trace callback
Explicit trace retrieval
use Superscript\Axiom\Context; use Superscript\Axiom\Tracing\TracingResolver; $tracer = new TracingResolver($delegatingResolver); $traced = $tracer->traced($source); // optionally pass a Context with bindings/definitions $traced->result; // Result<Option<T>> $traced->trace; // ResolutionTrace tree $traced->dump(); // formatted string
Extracting metadata from a trace
// Collect all values for a key across the entire tree $httpExchanges = $traced->trace->collect('http_response'); // Walk the tree manually foreach ($traced->trace->children() as $child) { $child->getMetadata('http_response'); }
Production use (flat inspector, no tracing)
For extracting resolver metadata without full tracing overhead, pass a flat
inspector via the Context:
use Superscript\Axiom\Context; use Superscript\Axiom\Tracing\ResolutionContext; $inspector = new ResolutionContext(); $result = $resolver->resolve($source, new Context(inspector: $inspector)); $httpResponse = $inspector->get('http_response');
Components
| Component | Purpose |
|---|---|
ResolutionContext |
Flat key-value ResolutionInspector for production metadata extraction |
ResolutionTrace |
Tree node with children, metadata, and recursive collect() |
TracingResolutionInspector |
Tree-aware inspector routing annotations to the current trace node |
TracingResolver |
Decorator intercepting every resolve() call to build the trace tree |
TracedResult |
Pairs a Result with its ResolutionTrace tree |
TraceFormatter |
Renders trace trees as human-readable indented strings |
Tracing |
Factory with wrap() for conditional decoration |
Example output
TypeDefinition [NumberType] — ok, value: 150, 52ms
└── InfixExpression [*] — ok, value: 150, 51ms
├── SymbolSource [base_rate] — ok, value: 100, 3ms
│ └── StaticSource [static(int)] — ok, value: 100, 0.01ms
└── InfixExpression [+] — ok, value: 1.5, 45ms
├── StaticSource [static(float)] — ok, value: 0.5, 0.01ms
└── StaticSource [static(int)] — ok, value: 1, 0.01ms
Testing
composer install vendor/bin/phpunit
gosuperscript/axiom-tracing 适用场景与选型建议
gosuperscript/axiom-tracing 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 13.85k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 02 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 gosuperscript/axiom-tracing 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 gosuperscript/axiom-tracing 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 13.85k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 18
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-10