Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a TYPO3 CMS integration #1538

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Add a TYPO3 CMS integration #1538

wants to merge 7 commits into from

Conversation

LiquidPL
Copy link

@LiquidPL LiquidPL commented Mar 9, 2022

Description

Resolves #1074.

This PR adds an integration for the TYPO3 CMS and its headless extension. It covers tracing for most common core framework methods, including cache, database, and templating.

Readiness checklist

  • (only for Members) Changelog has been added to the release document.
  • Tests added for this feature/bug.

Reviewer checklist

  • Appropriate labels assigned.
  • Milestone is set.
  • Changelog has been added to the release document. For community contributors the reviewer is in charge of this task.

@LiquidPL
Copy link
Author

LiquidPL commented Mar 9, 2022

One thing I'd like to ask about: is there a way to locally build a debian package, without going through CircleCI? I'd like to test the built extension against the copy of this integration we have internally, but I couldn't manage to build that package.

@krakjoe krakjoe added the 🎉 new-integration A new integration label Mar 10, 2022
* remove tracing for apc and wincache caching backends,
  which are deprecated
* remove tracing for null/transient memory cache backends, which are
  very fast and negligible for tracing purposes
Copy link
Member

@labbati labbati left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @LiquidPL for the work on this PR, I left some comments specific to the lines, plus I have to questions here.

Can we add some tests like we do for other frameworks? You can use Laravel's test suite as a reference https://github.com/DataDog/dd-trace-php/blob/master/tests/Integrations/Laravel/V8_x/CommonScenariosTest.php), no need to replicate all tests, only the ones in the file I linked to.

Can you remove tracing of methods that are expected to have a very high cardinality, if any. Just to give you an example, a method that is expected to be called hundreds of times, like a DTO hydrator or similar) should not be traced because of the added overhead.

ext/php5/integrations/integrations.h Outdated Show resolved Hide resolved
src/Integrations/Integrations/IntegrationsLoader.php Outdated Show resolved Hide resolved
src/Integrations/Integrations/TYPO3/TYPO3Integration.php Outdated Show resolved Hide resolved
\DDTrace\trace_method(\TYPO3\CMS\Extbase\Mvc\Dispatcher::class, 'dispatch', $setCommonValues);

\DDTrace\trace_method(\TYPO3\CMS\Extbase\Persistence\Generic\Query::class, 'execute', $setCommonValues);
\DDTrace\trace_method(\TYPO3\CMS\Extbase\Property\PropertyMapper::class, 'convert', $setCommonValues);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the expected cardinality of PropertyMapper::convert, I am not familiar with typo3 but it looks like this method might be potentially called hundreds of times? Int his case we should not trace it and trace maybe one layer above.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is called when processing properties passed in the request, shouldn't be called a lot, depending on the amount of properties passed.


\DDTrace\trace_method(
\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::class,
'acquireLock',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the expected cardinality of TypoScriptFrontendController:: acquireLock , I am not familiar with typo3 but it looks like this method might be potentially called hundreds of times? Int his case we should not trace it and trace maybe one layer above.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is mainly used for caching, and should generally only be used whenever a new page is saved into the cache, and is not called when a page is pulled from the cache. Optimistically it should only be called at most once per request (potentially more if a request fails and subsequently retries to render a page).

@labbati
Copy link
Member

labbati commented May 30, 2022

Hello @LiquidPL , I was just curious to know if you had a chance to review my feedback.

@LiquidPL
Copy link
Author

Yeah, I'm working my way through it. I should have fixes ready in 1-2 days.

@LiquidPL LiquidPL changed the title Add a TYPO3 CMS integration [WIP] Add a TYPO3 CMS integration May 31, 2022
@LiquidPL LiquidPL changed the title [WIP] Add a TYPO3 CMS integration Add a TYPO3 CMS integration May 31, 2022
@LiquidPL LiquidPL marked this pull request as draft May 31, 2022 22:48
@bwoebi
Copy link
Collaborator

bwoebi commented Jun 28, 2022

Hey @LiquidPL

Has there been any progress on this? :-) Given that it's still a draft?

@LiquidPL
Copy link
Author

I've cleaned up most of the C-side code as expected, currently I'm working on writing TYPO3 tests for the tracing, however it's going slower than I expected, since this I need to get the framework configured to run properly in the tests.

@bwoebi
Copy link
Collaborator

bwoebi commented Aug 29, 2022

Hey @LiquidPL,

May I ask you for another update on this? :-)

@LiquidPL
Copy link
Author

Hello,

Apologies for the long delays, I have provided tests for both TYPO3 v10, and the recently released TYPO3 v11.

There's two things to consider:

  • the testing Docker images need to be updated to use Composer 2 (I don't know if this is already done for the CI images, but at least locally the v11 tests failed because of that).
circleci(buster):~/app$ make test_web_typo3_11x 
COMPOSER_MEMORY_LIMIT=-1 composer --no-interaction --working-dir=./tests update
Loading composer repositories with package information
Warning from https://repo.packagist.org: Support for Composer 1 is deprecated and some packages will not be available. You should upgrade to Composer 2. See https://blog.packagist.com/deprecating-composer-1-support/
Info from https://repo.packagist.org: #StandWithUkraine
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
27 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
Create scenario 'elasticsearch1'.
Create scenario 'elasticsearch7'.
Create scenario 'guzzle5'.
Create scenario 'guzzle6'.
Create scenario 'mongodb1'.
Create scenario 'opentracing_beta5'.
Create scenario 'opentracing_beta6'.
Create scenario 'opentracing10'.
Create scenario 'predis1'.
Create scenario 'phpredis3'.
Create scenario 'phpredis4'.
Create scenario 'phpredis5'.
COMPOSER_MEMORY_LIMIT=-1 composer --no-interaction --working-dir=tests/Frameworks/TYPO3/Version_11_x update
Loading composer repositories with package information
Warning from https://repo.packagist.org: Support for Composer 1 is deprecated and some packages will not be available. You should upgrade to Composer 2. See https://blog.packagist.com/deprecating-composer-1-support/
Info from https://repo.packagist.org: #StandWithUkraine
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - typo3/cms-core v11.5.17 requires composer-runtime-api ^2.1 -> no matching package found.
    - typo3/cms-core v11.5.9 requires composer-runtime-api ^2.1 -> no matching package found.
    - typo3/cms-core v11.5.8 requires composer-runtime-api ^2.1 -> no matching package found.
    - typo3/cms-core v11.5.7 requires composer-runtime-api ^2.1 -> no matching package found.
    - typo3/cms-core v11.5.6 requires composer-runtime-api ^2.1 -> no matching package found.
    - typo3/cms-core v11.5.5 requires composer-runtime-api ^2.1 -> no matching package found.
    - typo3/cms-core v11.5.4 requires composer-runtime-api ^2.1 -> no matching package found.
    - typo3/cms-core v11.5.3 requires composer-runtime-api ^2.1 -> no matching package found.
    - typo3/cms-core v11.5.2 requires composer-runtime-api ^2.1 -> no matching package found.
    - typo3/cms-core v11.5.17 requires composer-runtime-api ^2.1 -> no matching package found.
    - typo3/cms-core v11.5.16 requires composer-runtime-api ^2.1 -> no matching package found.
    - typo3/cms-core v11.5.15 requires composer-runtime-api ^2.1 -> no matching package found.
    - typo3/cms-core v11.5.14 requires composer-runtime-api ^2.1 -> no matching package found.
    - typo3/cms-core v11.5.13 requires composer-runtime-api ^2.1 -> no matching package found.
    - typo3/cms-core v11.5.12 requires composer-runtime-api ^2.1 -> no matching package found.
    - typo3/cms-core v11.5.11 requires composer-runtime-api ^2.1 -> no matching package found.
    - typo3/cms-core v11.5.10 requires composer-runtime-api ^2.1 -> no matching package found.
    - typo3/cms-core v11.5.1 requires composer-runtime-api ^2.1 -> no matching package found.
    - typo3/cms-core v11.5.0 requires composer-runtime-api ^2.1 -> no matching package found.
    - Installation request for typo3/cms-core ^11.5.0 -> satisfiable by typo3/cms-core[v11.5.0, v11.5.1, v11.5.10, v11.5.11, v11.5.12, v11.5.13, v11.5.14, v11.5.15, v11.5.16, v11.5.17, v11.5.2, v11.5.3, v11.5.4, v11.5.5, v11.5.6, v11.5.7, v11.5.8, v11.5.9].

Potential causes:
 - This package is not installable via Composer 1.x, see <https://blog.packagist.com/deprecating-composer-1-support/>
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.
 - It's a private package and you forgot to add a custom repository to find it

Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.
make: *** [Makefile:961: test_web_typo3_11x] Error 2
circleci(buster):~/app$
  • there seems to be a problem with the SpanChecker, where some of the spans traced from TYPO3 are so short they get reported as having 0 duration, causing it to fail.
circleci(buster):~/app$ make test_web_typo3_11x 
COMPOSER_MEMORY_LIMIT=-1 composer --no-interaction --working-dir=./tests update
Loading composer repositories with package information
Updating dependencies
Nothing to modify in lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Generating autoload files
27 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
Create scenario 'elasticsearch1'.
Create scenario 'elasticsearch7'.
Create scenario 'guzzle5'.
Create scenario 'guzzle6'.
Create scenario 'mongodb1'.
Create scenario 'opentracing_beta5'.
Create scenario 'opentracing_beta6'.
Create scenario 'opentracing10'.
Create scenario 'predis1'.
Create scenario 'phpredis3'.
Create scenario 'phpredis4'.
Create scenario 'phpredis5'.
No security vulnerability advisories found
COMPOSER_MEMORY_LIMIT=-1 composer --no-interaction --working-dir=tests/Frameworks/TYPO3/Version_11_x update
Loading composer repositories with package information
Updating dependencies
Nothing to modify in lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Generating autoload files
> typo3cms install:fixfolderstructure
No action performed!
46 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
No security vulnerability advisories found
php tests/Frameworks/TYPO3/Version_11_x/vendor/bin/typo3cms cache:flush --group=system
php tests/Frameworks/TYPO3/Version_11_x/vendor/bin/typo3cms cache:flush --group=di
DD_AUTOLOAD_NO_COMPILE=true DD_TRACE_CLI_ENABLED=true php  -d ddtrace.request_init_hook=/home/circleci/app/bridge/dd_wrap_autoloader.php ./tests/vendor/bin/phpunit  --config=./tests/phpunit.xml tests/Integrations/TYPO3/V11_x --filter=.
PHPUnit 9.5.25 #StandWithUkraine

Runtime:       PHP 8.0.17
Configuration: ./tests/phpunit.xml
Warning:       Your XML configuration validates against a deprecated schema.
Suggestion:    Migrate your XML configuration using "--migrate-configuration"!

F.F.                                                                                                                                                                                            4 / 4 (100%)

Time: 00:43.475, Memory: 14.00 MB

There were 2 failures:

1) DDTrace\Tests\Integration\TYPO3\V11_x\CommonScenariosTest::testScenario with data set "A simple GET request returning a string" (DDTrace\Tests\Frameworks\Util\Request\GetSpec Object (...), array(DDTrace\Tests\Common\SpanAssertion Object (...)))
Failed asserting that 0 is greater than 0.
parent operation/resource: TYPO3\CMS\Core\TypoScript\TemplateService.generateConfig/
parent operation/resource: TYPO3\CMS\Core\TypoScript\TemplateService.start/
parent operation/resource: TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController.getConfigArray/
parent operation/resource: typo3.Application.run/
parent operation/resource: web.request/GET /simple

/home/circleci/app/tests/Common/SpanChecker.php:343
/home/circleci/app/tests/Common/SpanChecker.php:56
/home/circleci/app/tests/Common/SpanChecker.php:89
/home/circleci/app/tests/Common/SpanChecker.php:89
/home/circleci/app/tests/Common/SpanChecker.php:89
/home/circleci/app/tests/Common/SpanChecker.php:89
/home/circleci/app/tests/Common/SpanChecker.php:89
/home/circleci/app/tests/Common/SpanChecker.php:45
/home/circleci/app/tests/Common/SpanAssertionTrait.php:29
/home/circleci/app/tests/Integrations/TYPO3/V11_x/CommonScenariosTest.php:42

2) DDTrace\Tests\Integration\TYPO3\V11_x\CommonScenariosTest::testScenario with data set "A GET request with an exception" (DDTrace\Tests\Frameworks\Util\Request\GetSpec Object (...), array(DDTrace\Tests\Common\SpanAssertion Object (...)))
Failed asserting that 0 is greater than 0.
parent operation/resource: TYPO3\CMS\Core\TypoScript\TemplateService.generateConfig/
parent operation/resource: TYPO3\CMS\Core\TypoScript\TemplateService.start/
parent operation/resource: TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController.getConfigArray/
parent operation/resource: typo3.Application.run/
parent operation/resource: web.request/GET /error

/home/circleci/app/tests/Common/SpanChecker.php:343
/home/circleci/app/tests/Common/SpanChecker.php:56
/home/circleci/app/tests/Common/SpanChecker.php:89
/home/circleci/app/tests/Common/SpanChecker.php:89
/home/circleci/app/tests/Common/SpanChecker.php:89
/home/circleci/app/tests/Common/SpanChecker.php:89
/home/circleci/app/tests/Common/SpanChecker.php:89
/home/circleci/app/tests/Common/SpanChecker.php:45
/home/circleci/app/tests/Common/SpanAssertionTrait.php:29
/home/circleci/app/tests/Integrations/TYPO3/V11_x/CommonScenariosTest.php:42

FAILURES!
Tests: 4, Assertions: 6071, Failures: 2.
make: *** [Makefile:964: test_web_typo3_11x] Error 1
circleci(buster):~/app$

@LiquidPL LiquidPL marked this pull request as ready for review October 24, 2022 11:15
@LiquidPL LiquidPL requested a review from a team as a code owner October 24, 2022 11:15
@LiquidPL
Copy link
Author

Hello, can we take another look at this PR?

@LiquidPL LiquidPL requested a review from labbati April 5, 2023 10:07
@tmotyl
Copy link

tmotyl commented Jun 29, 2023

@labbati @bwoebi can you please take a look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎉 new-integration A new integration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Support for TYPO3 CMS instrumentation
5 participants