Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
90d4783
FEATURE: Make cache entries sortable
Sebobo Jul 16, 2026
e1c8375
FEATURE: Show messages from MessageCollector in additional metrics
Sebobo Jul 16, 2026
37a7ce0
FEATURE: Track ContentRepository.Search implementation queries
Sebobo Jul 26, 2026
36011f5
TASK: Introduce phpstan and fix all issues
Sebobo Jul 26, 2026
bb6bcbe
TASK: Move context context matrics into separate component
Sebobo Jul 26, 2026
6d1beaa
FEATURE: Allow using MessagesCollector statically
Sebobo Jul 26, 2026
f1fecb0
TASK: Extract MessagesMetrics into separarate component
Sebobo Jul 26, 2026
73688fa
TASK: Extract ResourceStreamRequests into separate component
Sebobo Jul 26, 2026
369e931
TASK: Extract thumbnail metrics into separate component
Sebobo Jul 26, 2026
4f25bb5
TASK: Extract Thumbnail generation metrics into separate component
Sebobo Jul 26, 2026
04d4eb5
TASK: Extract search query metrics into separate component
Sebobo Jul 26, 2026
995166e
TASK: Show method name in search query metrics
Sebobo Jul 26, 2026
e099b91
FEATURE: Show cummulative hits, miss and sets in cache metrics
Sebobo Jul 26, 2026
3d033f1
TASK: Bump JS dependencies
Sebobo Jul 26, 2026
671f5cf
TASK: Verify JS build in Github Action
Sebobo Jul 26, 2026
763242f
TASK: Update documentation
Sebobo Jul 27, 2026
8aeec87
TASK: Resolve phpstan warning
Sebobo Jul 27, 2026
cc7b531
FEATURE: Measure prototype rendering via meta attribute
Sebobo Aug 1, 2026
fbe2391
TASK: Don’t use MessagesCollector for created thumbnails
Sebobo Aug 1, 2026
f6c0fee
TASK: Resolve all available data collectors from reflection service
Sebobo Aug 1, 2026
09d3338
TASK: Disable debug attribute feature by default
Sebobo Aug 1, 2026
99cd109
TASK: Reduce debug attribute checking performance cost
Sebobo Aug 3, 2026
88d0097
BUGFIX: Only load content context metrics collector matching the acti…
Sebobo Aug 3, 2026
c75d9be
FEATURE: Implement content context / subgraph cache pool metrics for …
Sebobo Aug 3, 2026
8417b14
TASK: Add stubs to resolve PHPStan warnings
Sebobo Aug 3, 2026
9ff08b6
TASK: Adjust minimum stability for CI tests
Sebobo Aug 3, 2026
aa2afb6
fixup linting
Sebobo Aug 3, 2026
67fcc76
TASK: Rename ContentContextMetrics to NodeAccessMetrics
Sebobo Aug 3, 2026
4d7dbf8
TASK: Improve node access metrics table styling
Sebobo Aug 3, 2026
c76ec81
TASK: Update Metrics docs
Sebobo Aug 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
98 changes: 98 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: Tests

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest
name: Build JS bundle
steps:
- name: Checkout package
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: yarn

- name: Install dependencies
run: yarn install --immutable

- name: Build
run: yarn build

quality:
runs-on: ubuntu-latest

strategy:
matrix:
phpVersion:
- '8.3'
neosVersion:
- '8.3'
- '8.4'
- '9.1'

name: 'Quality - Neos ${{ matrix.neosVersion }}'

steps:
- name: Checkout package
uses: actions/checkout@v3
with:
path: package

- name: Checkout Neos base distribution
uses: actions/checkout@v3
with:
repository: neos/neos-base-distribution
ref: ${{ matrix.neosVersion }}
path: neos-base-distribution

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.phpVersion }}
tools: composer:v2, phpstan, phpunit

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-flow-${{ matrix.neosVersion }}-${{ hashFiles('neos-base-distribution/composer.json') }}
restore-keys: ${{ runner.os }}-composer-flow-${{ matrix.neosVersion }}-

- name: Copy package into distribution
run: |
mkdir -p neos-base-distribution/Packages/Plugins
cp -R "$GITHUB_WORKSPACE/package" neos-base-distribution/Packages/Plugins/Flowpack.Neos.Debug

- name: Install dependencies
working-directory: neos-base-distribution
run: |
composer config --no-plugins allow-plugins.neos/composer-plugin true
composer config minimum-stability dev
composer config prefer-stable true
composer install --no-interaction --no-progress

- name: Register package and regenerate autoloader
working-directory: neos-base-distribution
run: |
composer config --no-plugins repositories.shel-resource-import path Packages/Plugins/Flowpack.Neos.Debug
composer require --no-interaction --no-progress flowpack/neos-debug:@dev

- name: PHPStan analysis
working-directory: neos-base-distribution/Packages/Plugins/Flowpack.Neos.Debug
run: phpstan analyse -c phpstan.neon --no-progress

# - name: PHPUnit tests
# working-directory: neos-base-distribution/Packages/Plugins/Flowpack.Neos.Debug
# run: phpunit -c phpunit.xml
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules
/.yarn/install-state.gz
/.pnp.loader.mjs
/.pnp.cjs
/.phpstan-cache
944 changes: 944 additions & 0 deletions .yarn/releases/yarn-4.17.1.cjs

Large diffs are not rendered by default.

942 changes: 0 additions & 942 deletions .yarn/releases/yarn-4.9.2.cjs

This file was deleted.

4 changes: 2 additions & 2 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
compressionLevel: mixed
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.9.2.cjs
yarnPath: .yarn/releases/yarn-4.17.1.cjs
118 changes: 82 additions & 36 deletions Classes/Aspect/CollectDebugInformationAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,18 @@
*/

use Doctrine\ORM\EntityManagerInterface;
use Flowpack\Neos\Debug\DataCollector\CacheAccessCollector;
use Flowpack\Neos\Debug\DataCollector\ContentContextMetricsCollectorInterface;
use Flowpack\Neos\Debug\DataCollector\MessagesCollector;
use Flowpack\Neos\Debug\DataCollector\DataCollectorInterface;
use Flowpack\Neos\Debug\DataCollector\DebugAttributeCollector;
use Flowpack\Neos\Debug\Domain\Model\Dto\ResourceStreamRequest;
use Flowpack\Neos\Debug\Logging\DebugStack;
use Flowpack\Neos\Debug\Service\DebugService;
use GuzzleHttp\Psr7\Response;
use GuzzleHttp\Psr7\Utils;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Aop\JoinPointInterface;
use Neos\Flow\Core\Bootstrap;
use Neos\Flow\Exception;
use Neos\Flow\Reflection\ReflectionService;
use Neos\Flow\ResourceManagement\PersistentResource;
use Neos\Media\Domain\Model\AssetInterface;
use Neos\Media\Domain\Model\Thumbnail;
Expand All @@ -41,6 +43,12 @@ class CollectDebugInformationAspect
#[Flow\Inject]
protected DebugService $debugService;

#[Flow\Inject]
protected Bootstrap $bootstrap;

#[Flow\Inject]
protected ReflectionService $reflectionService;

protected DebugStack $sqlLoggingStack;

protected int $contentCacheHits = 0;
Expand All @@ -50,8 +58,16 @@ class CollectDebugInformationAspect
*/
protected array $contentCacheMisses = [];

/**
* List of resource stream requests that were made during rendering.
* @var ResourceStreamRequest[]
*/
protected array $resourceStreamRequests = [];

/**
* Map of resource sha1 to the names of generated thumbnails
* @var array<string, string[]>
*/
protected array $thumbnails = [];

#[Flow\InjectConfiguration('serverTimingHeader.enabled', 'Flowpack.Neos.Debug')]
Expand All @@ -61,34 +77,29 @@ class CollectDebugInformationAspect
protected ?bool $htmlOutputEnabled;

#[Flow\Inject]
protected MessagesCollector $messagesCollector;

#[Flow\Inject]
protected CacheAccessCollector $cacheAccessCollector;

#[Flow\Inject()]
protected ContentContextMetricsCollectorInterface $contentContextMetricsCollector;
protected DebugAttributeCollector $debugAttributeCollector;

#[Flow\Pointcut("setting(Flowpack.Neos.Debug.enabled)")]
public function debuggingActive(): void
{
}

#[Flow\Around("method(Neos\Neos\View\FusionView->render()) && Flowpack\Neos\Debug\Aspect\CollectDebugInformationAspect->debuggingActive")]
public function addDebugValuesToNeosFusionView(JoinPointInterface $joinPoint): string|ResponseInterface|StreamInterface
{
public function addDebugValuesToNeosFusionView(JoinPointInterface $joinPoint
): string|ResponseInterface|StreamInterface {
return $this->addDebugValues($joinPoint);
}

#[Flow\Around("method(Neos\Fusion\View\FusionView->render()) && Flowpack\Neos\Debug\Aspect\CollectDebugInformationAspect->debuggingActive")]
public function addDebugValuesToDefaultFusionView(JoinPointInterface $joinPoint): string|ResponseInterface|StreamInterface
{
public function addDebugValuesToDefaultFusionView(JoinPointInterface $joinPoint
): string|ResponseInterface|StreamInterface {
return $this->addDebugValues($joinPoint);
}

protected function addDebugValues(JoinPointInterface $joinPoint): string|ResponseInterface|StreamInterface
{
$startRenderAt = microtime(true) * 1000;
/** @var string|ResponseInterface|StreamInterface $response */
$response = $joinPoint->getAdviceChain()->proceed($joinPoint);
$endRenderAt = microtime(true) * 1000;

Expand All @@ -110,8 +121,17 @@ protected function addDebugValues(JoinPointInterface $joinPoint): string|Respons
}

if ($response instanceof ResponseInterface) {
$output = $response->getBody()?->getContents();
$response->getBody()?->rewind();
/**
* There are cases where the response is not a stream
* @var StreamInterface|null $responseBody
*/
$responseBody = $response->getBody();
if ($responseBody instanceof StreamInterface) {
$output = $responseBody->getContents();
$responseBody->rewind();
} else {
$output = '';
}

$contentType = $response->getHeaderLine('Content-Type');
if (!str_contains($contentType, 'text/html') && !str_contains($output, '<!DOCTYPE html')) {
Expand All @@ -123,6 +143,11 @@ protected function addDebugValues(JoinPointInterface $joinPoint): string|Respons

$groupedQueries = $this->groupQueries($this->sqlLoggingStack->queries);

$additionalMetrics = array_reduce($this->getDataCollectors(), static function (array $metrics, DataCollectorInterface $collector) {
$metrics[$collector->getName()] = $collector->collect();
return $metrics;
}, []);

// TODO: Introduce DTOs for the data
$data = [
'startRenderAt' => $startRenderAt,
Expand All @@ -141,12 +166,7 @@ protected function addDebugValues(JoinPointInterface $joinPoint): string|Respons
// Init as 0 as the actual number has to be resolved from the individual cache entries
'resourceStreamRequests' => $this->resourceStreamRequests,
'thumbnails' => $this->thumbnails,
'additionalMetrics' => [
// TODO: Iterate over all existing collectors
$this->messagesCollector->getName() => $this->messagesCollector->collect(),
$this->cacheAccessCollector->getName() => $this->cacheAccessCollector->collect(),
$this->contentContextMetricsCollector->getName() => $this->contentContextMetricsCollector->collect(),
]
'additionalMetrics' => $additionalMetrics,
];
$output = (string)$output;
$debugOutput = '<!--__NEOS_DEBUG__ ' . json_encode($data) . '-->';
Expand Down Expand Up @@ -202,16 +222,11 @@ public function addGeneratedThumbnails(JoinPointInterface $joinPoint): void
$asset = $joinPoint->getMethodArgument('asset');
$thumbnailOrOriginalAsset = $joinPoint->getResult();
if ($asset && $thumbnailOrOriginalAsset instanceof Thumbnail) {
if (!array_key_exists($asset->getResource()->getSha1(), $this->thumbnails)) {
$this->thumbnails[$asset->getResource()->getSha1()] = 1;
} else {
$this->thumbnails[$asset->getResource()->getSha1()]++;
$hash = $asset->getResource()->getSha1();
if (!array_key_exists($hash, $this->thumbnails)) {
$this->thumbnails[$hash] = [];
}

$this->messagesCollector->addMessage(
$asset->getResource()->getFilename() . ' (' . $asset->getResource()->getCollectionName() . ')',
'Thumbnail generated',
);
$this->thumbnails[$hash][] = $asset->getResource()->getFilename() . ' (' . $asset->getResource()->getCollectionName() . ')';
}
}

Expand All @@ -238,13 +253,19 @@ public function addCacheHit(JoinPointInterface $joinPoint): void

/**
* TODO: Move into a helper class
* @param array{sql: string, table: string, params: array, types: string, executionMS: int} $queries
* @param array<int, array{sql: string, table: string, params: array<string, mixed>|null, types: array<string, string>|null, executionMS: float}> $queries
* @return array<string, array{queries: array<string, array{executionTimeSum: float, count: int, params: array<string, int>}>, executionTimeSum: float, count: int}>
*/
protected function groupQueries(array $queries): array
{
return array_reduce($queries, static function ($carry, $queryData) {
['sql' => $sql, 'table' => $table, 'params' => $params, 'executionMS' => $executionMS] = $queryData;
$paramString = json_encode($params);
/** @var array<string, array{queries: array<string, array{executionTimeSum: float, count: int, params: array<string, int>}>, executionTimeSum: float, count: int}> $initial */
$initial = [];
return array_reduce($queries, static function (array $carry, array $queryData): array {
$sql = $queryData['sql'];
$table = $queryData['table'];
$params = $queryData['params'];
$executionMS = $queryData['executionMS'];
$paramString = (string)json_encode($params);

if (!array_key_exists($table, $carry)) {
$carry[$table] = [
Expand Down Expand Up @@ -274,6 +295,31 @@ protected function groupQueries(array $queries): array
}

return $carry;
}, []);
}, $initial);
}


/**
* @return DataCollectorInterface[]
* @throws Exception
*/
public function getDataCollectors(): array
{
$objectManager = $this->bootstrap->getObjectManager();
$dataCollectors = [];
$classNames = $this->reflectionService->getAllImplementationClassNamesForInterface(
DataCollectorInterface::class
);
foreach ($classNames as $className) {
$objectName = $objectManager->getObjectNameByClassName($className);
if (!$objectName || !$className::canBeLoaded()) {
continue;
}
$dataCollector = $objectManager->get($objectName);
if ($dataCollector instanceof DataCollectorInterface) {
$dataCollectors[] = $dataCollector;
}
}
return $dataCollectors;
}
}
Loading
Loading