Skip to content

feat(agent): add support for Yii v2 #848

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

Merged
merged 9 commits into from
Apr 19, 2024
Merged

Conversation

lavarou
Copy link
Member

@lavarou lavarou commented Mar 11, 2024

Implement Yii v2 instrumentation for auto transaction naming.

Original work by @razvanphp in #823. Fixes #821.

@codecov-commenter
Copy link

codecov-commenter commented Mar 11, 2024

Codecov Report

Attention: Patch coverage is 55.10204% with 22 lines in your changes are missing coverage. Please review.

Project coverage is 78.73%. Comparing base (eecccd5) to head (0b892a6).

Files Patch % Lines
agent/fw_yii.c 55.10% 22 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #848      +/-   ##
==========================================
- Coverage   78.76%   78.73%   -0.04%     
==========================================
  Files         193      193              
  Lines       27129    27175      +46     
==========================================
+ Hits        21369    21396      +27     
- Misses       5760     5779      +19     
Flag Coverage Δ
agent-for-php-7.0 77.79% <53.33%> (-0.04%) ⬇️
agent-for-php-7.1 77.54% <48.83%> (-0.04%) ⬇️
agent-for-php-7.2 78.11% <48.83%> (-0.04%) ⬇️
agent-for-php-7.3 78.13% <48.83%> (-0.04%) ⬇️
agent-for-php-7.4 77.84% <48.83%> (-0.04%) ⬇️
agent-for-php-8.0 77.90% <68.96%> (-0.01%) ⬇️
agent-for-php-8.1 77.88% <68.96%> (-0.01%) ⬇️
agent-for-php-8.2 77.48% <68.96%> (-0.01%) ⬇️
agent-for-php-8.3 77.48% <68.96%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


/*EXPECT_ERROR_EVENTS null */

/* WordPress mock app */
Copy link
Contributor

Choose a reason for hiding this comment

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

This should've been Yii 🙂 but no bigie, thanks for adding the tests for me!

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch!

Copy link
Member Author

Choose a reason for hiding this comment

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

Addressed with d059d1c.

agent/fw_yii.c Outdated
/*
* Enable Yii2 instrumentation.
*/
void nr_yii2_enable(TSRMLS_D) {
NRPRG(framework_version) = 2;
Copy link
Contributor

Choose a reason for hiding this comment

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

is this still useful?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not after c4172d8.

@razvanphp
Copy link
Contributor

One more question: should the error catching be tested too?

@lavarou
Copy link
Member Author

lavarou commented Mar 11, 2024

One more question: should the error catching be tested too?

It should be tested and is tested, just with a tool different than integration tests. That tool is using the actual framework, not the mock. I'll think some more about adding a mock to test error handling in integration tests.

@lavarou lavarou modified the milestone: next-release Mar 12, 2024
@lavarou
Copy link
Member Author

lavarou commented Mar 13, 2024

One more question: should the error catching be tested too?

It should be tested and is tested, just with a tool different than integration tests. That tool is using the actual framework, not the mock. I'll think some more about adding a mock to test error handling in integration tests.

Further testing uncovered some issues with exception handling when Yii's Exception Handler is disabled. This requires further investigation.

@lavarou lavarou changed the title feat(agent): add support for Yii v2 [WIP]: feat(agent): add support for Yii v2 Mar 13, 2024
@lavarou lavarou marked this pull request as draft March 13, 2024 14:33
@lavarou lavarou force-pushed the feat/agent/add-support-for-yii2 branch from dc5fa2c to 25c800e Compare March 15, 2024 01:19
@lavarou lavarou force-pushed the feat/agent/add-support-for-yii2 branch from 25c800e to 3bddfdf Compare April 11, 2024 15:53
@newrelic-php-agent-bot
Copy link

newrelic-php-agent-bot commented Apr 11, 2024

Test Suite Status Result
Multiverse 9/9 passing
SOAK 49/51 passing

@razvanphp
Copy link
Contributor

Further testing uncovered some issues with exception handling when Yii's Exception Handler is disabled. This requires further investigation.

Can you elaborate on this? I tried it and default PHP error handler was used and errors were catched by the default newrelic implementation.

@lavarou lavarou force-pushed the feat/agent/add-support-for-yii2 branch from 3bddfdf to 3d90b20 Compare April 12, 2024 17:13
@lavarou lavarou changed the base branch from dev to fix/agent/oapi-exception-handler-instrumentation April 12, 2024 17:14
lavarou referenced this pull request Apr 12, 2024
Agent for PHPs 8.0+ uses observer API to hook into Zend Engine, which allows
offers better out-of-the-box instrumentation of user exception handler. When
observer API is used, there's no need to wrap exception handlers to record
errors.
Base automatically changed from fix/agent/oapi-exception-handler-instrumentation to dev April 19, 2024 13:19
razvanphp and others added 3 commits April 19, 2024 09:22
Yii 1.x and Yii 2.x are detected as two distinct frameworks and therefore
need their own values in nrframework_t enum. This helps with tracking
framework usage through supportability metrics. This approach obsoletes
the need to store framework_version.
lavarou added 4 commits April 19, 2024 09:22
Agent for PHPs 8.0+ uses observer API to hook into Zend Engine, which allows
offers better out-of-the-box instrumentation of user exception handler. When
observer API is used, there's no need to wrap exception handlers to record
errors.
@lavarou lavarou force-pushed the feat/agent/add-support-for-yii2 branch from 3d90b20 to cb19ba7 Compare April 19, 2024 13:22
@lavarou lavarou marked this pull request as ready for review April 19, 2024 13:22
@lavarou lavarou changed the title [WIP]: feat(agent): add support for Yii v2 feat(agent): add support for Yii v2 Apr 19, 2024
* nr_php_is_zval_valid_object already checks for NULL
* NR_PHP_WRAPPER_END already ensures NR_PHP_WRAPPER_CALL is called and there's
  no need to call it earlier
@lavarou
Copy link
Member Author

lavarou commented Apr 19, 2024

Further testing uncovered some issues with exception handling when Yii's Exception Handler is disabled. This requires further investigation.

Can you elaborate on this? I tried it and default PHP error handler was used and errors were catched by the default newrelic implementation.

There were two problems which caused the default newrelic implementation not to record errors correctly. One has been resolved with #851 and another with #877.

@lavarou lavarou merged commit 539dd4f into dev Apr 19, 2024
62 checks passed
@lavarou lavarou deleted the feat/agent/add-support-for-yii2 branch April 19, 2024 16:41
@lavarou lavarou added this to the next-release milestone Apr 19, 2024
@lavarou lavarou linked an issue Apr 19, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for PHP Framework Yii2
6 participants