wintercms / wintercms/wn-debugbar-plugin

Improve quality of event performance tracking

Open
#8 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

help wanted Type: Enhancement
Dominant language
PHP
Stars
11
Forks
8
PR merge metrics
No merged PRs in 30d

Description

Remake of https://github.com/rainlab/debugbar-plugin/issues/42 by @LukeTowers.

Right now performance / timing tracking on events uses the difference between when the last event was fired to when the current event was fired to say how long a given event took to process. This is obviously wildly inaccurate and unhelpful, so it would be better if we could instead implement our own event data collector that actually tracked how long a given event was taking to execute by hooking one wildcard listener as the highest priority listener (with PHP_INT_MAX) and another wildcard listener as the lowest priority listener (with PHP_INT_MIN) and then recording the timing difference between those two listeners being fired.

This would require a change being made to the October core as currently wildcard listeners don't support subscribing to events with priority, and even if they did you'd still have to ensure that they were added to the priority stream of the non-wildcard listeners correctly.

Something roughly like the following:

$events->listen('*', [$this, 'onWildcardEventStart'], PHP_INT_MAX);
    $events->listen('*', [$this, 'onWildcardEventEnd'], PHP_INT_MIN);
}

protected $timings = [];

public function onWildCardEventStart($name = null, $data = [])
{
    if (empty($name)) { return; }
    $this->timings[$name] = microtime(true);
}
public function onWildCardEventEnd($name = null, $data = [])
{
    if (empty($name)) { return; }
    $this->addMeasure($name, $this->timings[$name], microtime(true), $this->prepareParams($data));
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the event data collector and the October core wildcard-listener implementation described in the issue. Check how listener priorities are ordered, then verify that measurements span the complete event execution and that the collected timing data is recorded for each event.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
observability, performance
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.