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.

@codecov-commenter
Copy link

codecov-commenter commented Mar 20, 2024

Codecov Report

Attention: Patch coverage is 58.02469% with 34 lines in your changes missing coverage. Please review.

Project coverage is 78.16%. Comparing base (ef7200a) to head (42797df).

Files 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/fw_symfony4.c 0.00% 1 Missing ⚠️
agent/lib_doctrine2.c 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #866      +/-   ##
==========================================
+ Coverage   78.13%   78.16%   +0.03%     
==========================================
  Files         194      194              
  Lines       26857    26831      -26     
==========================================
- Hits        20984    20972      -12     
+ Misses       5873     5859      -14     
Flag Coverage Δ
agent-for-php-7.2 78.13% <100.00%> (+<0.01%) ⬆️
agent-for-php-7.3 78.15% <100.00%> (+<0.01%) ⬆️
agent-for-php-7.4 77.85% <100.00%> (+<0.01%) ⬆️
agent-for-php-8.0 77.90% <56.41%> (+0.01%) ⬆️
agent-for-php-8.1 77.88% <56.41%> (+0.01%) ⬆️
agent-for-php-8.2 77.48% <44.44%> (+0.02%) ⬆️
agent-for-php-8.3 77.48% <44.44%> (+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 5/7 passing
SOAK 52/56 passing

@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?

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