Repository navigation
Add Custom Events panel to the dashboard - #10
Merged
Merged
Conversation
Lists each custom event type in the selected window with count, last seen and a sparkline, sorted by count. Clicking a type sets the existing custom_event_type filter. Uses the same request conditions and buckets as the other panels, so time range, hide-bots and request filters apply. Also switch LIKE filters to ESCAPE '!' so url, user_agent, custom_event_type and event value filters work on MySQL/MariaDB.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What / why
Adds a Custom events panel to the default dashboard. It automatically lists every custom event type an app fires through
apm.custom(for exampledocs.markdown_served), with no config. Before this, custom events were only visible inside a single request's details, or by guessing the type into the filter box.For each type in the selected window, the panel shows:
event_dt, shown with the sameformatTimestampand timezone picker as the rest of the dashboard),Types are sorted by count (descending, ties by name), capped at 20. Clicking a type sets the existing
custom_event_typefilter through the usualcaptureFilters()/loadData()path, so the URL becomes?custom_event_type=<type>, just like clicking a route or an error group. When there are no events the panel says "No custom events in this window."Query notes
customEventSummary()inPresenterAbstract, returned as a newcustomEventskey fromgetDashboardData()(adding a return key is allowed per AGENTS.md). Nothing in the public API changes.apm_custom_events etoapm_requests r ON r.id = e.request_idand reuserequestConditions('r', ...). That means the time range, customuntil, hide bots /is_bot, URL, route, host, user agent, error, event-data and the other request filters all apply exactly as they do on the other panels.bucketSql()andintervalSeconds(), bucketed onr.request_dt, and fills empty buckets on the same grid asbuildChart(). So the sparkline lines up with the latency chart.IN (...)list:PdoWrapperrewrites a singleIN(?)and splits string params on commas.Also fixed: LIKE filters on MySQL/MariaDB
requestConditions()usedLIKE ? ESCAPE '\'. MySQL reads'\'as an escaped quote, so theurl,user_agent,custom_event_typeand event-valuecontains/starts_with/ends_withfilters threw a syntax error (1064) on MySQL/MariaDB. That would also break this panel's click-through. They now useESCAPE '!', withescapeLike()escaping!,%and_. SQLite behaviour is unchanged.Migration notes
No migration added. The window filter goes through
apm_requests.request_dt(indexed by0006/0002), then intoapm_custom_eventsonrequest_id. That column is indexed on SQLite (idx_apm_custom_events_request_id) and on MySQL (the foreign-key index).(event_type, request_id)is also already indexed. Upgrading only needs a deploy.Tests
New
tests/CustomEventsPanelTest.phpcovers:last_seen, and that the trend sums to the count and is as long aschartData,until),exclude_bots,is_bot=0/1, and theurlfilter,custom_event_type,bot_onlyvsbotxonly,/a_bvs/axb).Each test runs on SQLite, and also on MySQL when
APM_TEST_MYSQL_DSN,APM_TEST_MYSQL_USERandAPM_TEST_MYSQL_PASSWORDare set (the database is wiped first, so use a throwaway schema).vendor/bin/phpunit --no-coverage→ 18 tests, 75 assertions, 6 skipped (the MySQL data sets).executionOrder="random".phpcs --standard=phpcs.xml: 0 errors or warnings inPresenterAbstract.phpand the new test. The repo-wide count is unchanged apart from those files.Click-through: headless Chrome via Playwright, against a seeded SQLite database served with
php -S ... dashboard/index.php. Checked:search.performedsets?custom_event_type=search.performed, fills the filter input and filters the stats (18 requests);exclude_bots=1drops the bot-only type and lowers the counts;Screenshot (not attached): a "Custom events" card under Error groups, one row per type showing the name, sparkline, last-seen time and a count badge.
Docs
Paired docs PR: flightphp/docs#54 (EN note in
content/v3/en/awesome-plugins/apm.md).