php / php/php-src

Observer API: Correlated observer callbacks for a single invocation

オープン
#20,510 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Feature Status: Needs Triage
主要言語
C
スター
40.4k
フォーク
8.2k
平均マージ
2日 13時間
マージ済み PR(30日)
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:

  1. Adding a temporary to zend_execute_data (like op_array.reserved[] but per invocation) to be used for identification as developer sees fit
  2. Passing zend_execute_data (or the temporary at least) to other callbacks like zend_observer_error_cb

Use case examples:

  1. Associating runtime metrics like start time, end time, return value, exceptions together without having to retain them in memory until all infos are gathered.
  2. Associating infos gathered by means other than Observer API (e.g. hooking specific PDO functions, replacing other zif_handler handlers) 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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. 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
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。