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

refactor(agent): remove oapi 'clean' callback #866

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

ZNeumann
Copy link
Contributor

The "clean" callback is not needed. In order to get rid of it, we can just call the "after" callback instead, simplifying the API and future wrappers. To achieve this removal from our current code, some auditing is required. Every single use of zval *func_return_value must be first checked for NULL. Furthermore, in wrappers that used to have a "clean" callback, it must be ensured that the logic that was present in the "clean" callback is still executed in the "after" callback, even when the return value is NULL.

@ZNeumann ZNeumann requested review from zsistla and lavarou March 20, 2024 20:56
@codecov-commenter
Copy link

codecov-commenter commented Mar 20, 2024

Codecov Report

Attention: Patch coverage is 59.25926% with 33 lines in your changes missing coverage. Please review.

Project coverage is 78.57%. Comparing base (f30642f) to head (8b2ec4b).
Report is 1 commits behind head on dev.

Files with missing lines Patch % Lines
agent/lib_mongodb.c 0.00% 16 Missing ⚠️
agent/fw_laravel.c 20.00% 4 Missing ⚠️
agent/fw_drupal.c 80.00% 3 Missing ⚠️
agent/fw_slim.c 0.00% 3 Missing ⚠️
agent/fw_yii.c 50.00% 2 Missing ⚠️
agent/php_wrapper.c 81.81% 2 Missing ⚠️
agent/fw_cakephp.c 0.00% 1 Missing ⚠️
agent/fw_lumen.c 0.00% 1 Missing ⚠️
agent/lib_doctrine2.c 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #866      +/-   ##
==========================================
+ Coverage   78.54%   78.57%   +0.03%     
==========================================
  Files         196      196              
  Lines       27103    27077      -26     
==========================================
- Hits        21287    21275      -12     
+ Misses       5816     5802      -14     
Flag Coverage Δ
agent-for-php-7.2 78.55% <100.00%> (+<0.01%) ⬆️
agent-for-php-7.3 78.57% <100.00%> (+<0.01%) ⬆️
agent-for-php-7.4 78.27% <100.00%> (+<0.01%) ⬆️
agent-for-php-8.0 78.31% <57.69%> (+0.01%) ⬆️
agent-for-php-8.1 78.29% <57.69%> (+0.01%) ⬆️
agent-for-php-8.2 77.89% <45.67%> (+0.02%) ⬆️
agent-for-php-8.3 77.89% <45.67%> (+0.02%) ⬆️

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.

@@ -327,16 +327,6 @@ NR_PHP_WRAPPER(nr_drupal_http_request_after) {
}
NR_PHP_WRAPPER_END

NR_PHP_WRAPPER(nr_drupal_http_request_clean) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

With this removal, it is failing some drupal integration tests, because the tests were changed for PHP 8.0+ to not create an external segment after an exception. A simple if can be added to the "after" instrumentation if this behavior is still desired. Or do we want to go back to what the agent was seemingly previously doing?

(Also, this old "clean" function was leaving a dangling segment on the transaction. Not a memory leak because the transaction handles its own segment memory, but scary nonetheless)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Although the tests do raise an interesting point. There are some tests that test for "bad" parameters; these cause an exception. But because our "after" code isn't perfectly checking arguments, it crashes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 9081863

@newrelic-php-agent-bot
Copy link

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

Test Suite Status Result
Multiverse 7/7 passing
SOAK 56/56 passing

@ZNeumann ZNeumann force-pushed the zjn/oapi/remove-clean branch from 88de064 to 7923273 Compare May 15, 2024 19:30
@zsistla
Copy link
Contributor

zsistla commented Jun 21, 2024

@ZNeumann , this looks close to ready.
Could you please
1)rebase
2)update any new before_after_cleans that were added since the PR was last updated

Comment on lines -28 to +38
[{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]],
[{"name": "Supportability/Logging/Metrics/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]],
[{"name":"Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]],
[{"name":"Errors/OtherTransaction/php__FILE__"}, [1, 0, 0, 0, 0, 0]],
[{"name":"Errors/all"}, [1, 0, 0, 0, 0, 0]],
[{"name":"Errors/allOther"}, [1, 0, 0, 0, 0, 0]],
[{"name":"OtherTransaction/all"}, [1, "??", "??", "??", "??", "??"]],
[{"name":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]],
[{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]],
[{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]],
[{"name":"Supportability/framework/Drupal/forced"}, [1, 0, 0, 0, 0, 0]]
[{"name":"Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]],
[{"name":"Supportability/Logging/Metrics/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]],
[{"name":"Errors/OtherTransaction/php__FILE__"}, [1, 0, 0, 0, 0, 0]],
[{"name":"Errors/all"}, [1, 0, 0, 0, 0, 0]],
[{"name":"Errors/allOther"}, [1, 0, 0, 0, 0, 0]],
[{"name":"OtherTransaction/all"}, [1, "??", "??", "??", "??", "??"]],
[{"name":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]],
[{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]],
[{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]],
[{"name":"Supportability/framework/Drupal/forced"}, [1, 0, 0, 0, 0, 0]],
[{"name":"Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]]
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these expectations changed at all or are the elements just reordered?

@lavarou lavarou force-pushed the zjn/oapi/remove-clean branch from 7923273 to 42797df Compare July 31, 2024 15:22
@lavarou lavarou force-pushed the zjn/oapi/remove-clean branch from 42797df to 8b2ec4b Compare November 6, 2024 15:13
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.

5 participants