Observer API: Correlated observer callbacks for a single invocation
还没有人认领这个 Issue。
- 主要语言
- C
- 星标
- 40.4k
- 派生
- 8.1k
- 平均合并
- 2 天 13 小时
- 30 天内合并 PR
- 96
描述
Description
Note:
I’ve already asked and explained part of this in another issue , but this is a broader feature request with example use cases.
Brief:
Observer API replacing zend_execute_ex hook provides notable benefits and one caveat (as it seems to me): there is no stable, per-invocation identifier that can be seen consistently across all observer callbacks.
Observer API callbacks are much like event handlers fired at the certain point of the lifecycle of an invocation, but they do not provide a means of identification of the invocation.
By being able to identify the invocation, information gathered in different events can be easily linked together for a meaningful “observation”.
Request:
- Adding a temporary to
zend_execute_data(likeop_array.reserved[]but per invocation) to be used for identification as developer sees fit - Passing
zend_execute_data(or the temporary at least) to other callbacks likezend_observer_error_cb
Use case examples:
- Associating runtime metrics like
start time,end time,return value,exceptionstogether without having to retain them in memory until all infos are gathered. - Associating infos gathered by means other than Observer API (e.g. hooking specific
PDOfunctions, replacing otherzif_handlerhandlers) with infos from callbacks.
It’s true that some of the infos named in 1st example can be easily linked together by a simple stack structure or HashTable (as pointed out in the above linked issue) but some others require more complex rules AFAICT and unnecessary bookkeeping.
zend_execute_data is already per-invocation, so I think it is cleaner and more straightforward to use that instead of each extension building and maintaining its own mapping.
P.S.: Please forgive me if there’s anything wrong with my thinking or writing; I’m not that experienced.
Cc: @bwoebi @ndossche
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先阅读 issue 中提到的 Observer API 入口点:zend_execute_ex、zend_observer_error_cb 和 zend_execute_data,以及 op_array.reserved[] 和 zif_handler 的使用方式。对比 issue 20336 中的相关讨论。当调用关联设计和 callback 数据要求达成一致并完成实现,且具有适当的覆盖率时,即视为完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- c, php
- 领域
- backend-api-design, compilers
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 25/100