Skip to content

cURL instrumentation: support partially successful curl_setopt_array#316

Merged
brettmc merged 1 commit into
open-telemetry:mainfrom
vikmovcan:fix/curl_setopt_array-fallback
Nov 23, 2024
Merged

cURL instrumentation: support partially successful curl_setopt_array#316
brettmc merged 1 commit into
open-telemetry:mainfrom
vikmovcan:fix/curl_setopt_array-fallback

Conversation

@vikmovcan

@vikmovcan vikmovcan commented Nov 7, 2024

Copy link
Copy Markdown
Contributor

When curl_setopt_array is partially successful we end up not recording curl options which were set successfully.
In order to work around this, the fix tries to emulate the behaviour of how curl_setopt_array works, and iterates over the passed options using curl_opt, recording each valid one, until an invalid option is encountered (reference: https://github.com/php/php-src/blob/fb257ee83c405fecf449571bfcd1cc0fb4910336/ext/curl/interface.c#L2381).

@welcome

welcome Bot commented Nov 7, 2024

Copy link
Copy Markdown

Thanks for opening your first pull request! If you haven't yet signed our Contributor License Agreement (CLA), then please do so that we can accept your contribution. A link should appear shortly in this PR if you have not already signed one.

@linux-foundation-easycla

linux-foundation-easycla Bot commented Nov 7, 2024

Copy link
Copy Markdown

CLA Signed


The committers listed above are authorized under a signed CLA.

@vikmovcan
vikmovcan marked this pull request as ready for review November 7, 2024 18:39
@vikmovcan
vikmovcan requested a review from a team as a code owner November 7, 2024 18:39
if (curl_error($params[0])) {
foreach ($params[1] as $option => $value) {
if (!curl_setopt($params[0], $option, $value)) {
break;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If we continue here instead, would it permit setting the subsequent options too? (in case there is more than one error)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes it would, however I dont see a reason to do that since I think we should only be interested in recording options which would be used later (in the following curl handle execution).
trying to record all valid options might be useful (and could be done without continue too I think), but that is outside of scope of this PR.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think I agree with @vikmovcan here. We shouldn't set the options if curl itself wouldn't - so if curl_setopt_array wouldn't set them, neither should we.

@codecov

codecov Bot commented Nov 9, 2024

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.60%. Comparing base (799985e) to head (ae140b7).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main     #316      +/-   ##
============================================
- Coverage     83.14%   79.60%   -3.54%     
- Complexity      669      729      +60     
============================================
  Files            61       69       +8     
  Lines          2676     2952     +276     
============================================
+ Hits           2225     2350     +125     
- Misses          451      602     +151     
Flag Coverage Δ
Aws 85.55% <ø> (ø)
Instrumentation/CakePHP 20.00% <ø> (?)
Instrumentation/CodeIgniter 73.77% <ø> (?)
Instrumentation/Curl 90.66% <100.00%> (+0.37%) ⬆️
Instrumentation/Guzzle 69.51% <ø> (ø)
Instrumentation/HttpAsyncClient 81.25% <ø> (ø)
Instrumentation/IO 70.68% <ø> (ø)
Instrumentation/MongoDB 76.31% <ø> (ø)
Instrumentation/OpenAIPHP 87.31% <ø> (ø)
Instrumentation/PDO 89.95% <ø> (ø)
Instrumentation/Psr14 77.14% <ø> (ø)
Instrumentation/Psr15 93.82% <ø> (ø)
Instrumentation/Psr16 97.56% <ø> (ø)
Instrumentation/Psr18 81.15% <ø> (ø)
Instrumentation/Psr6 97.67% <ø> (ø)
Instrumentation/Slim 86.89% <ø> (ø)
Instrumentation/Symfony 88.70% <ø> (ø)
Instrumentation/Yii 77.68% <ø> (ø)
Propagation/ServerTiming 100.00% <ø> (ø)
Propagation/TraceResponse 100.00% <ø> (ø)
ResourceDetectors/Container 93.02% <ø> (ø)
Sampler/RuleBased 33.51% <ø> (ø)
Shims/OpenTracing 92.45% <ø> (ø)

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

Files with missing lines Coverage Δ
...c/Instrumentation/Curl/src/CurlInstrumentation.php 94.07% <100.00%> (+0.43%) ⬆️

... and 8 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 799985e...ae140b7. Read the comment docs.

---- 🚨 Try these New Features:

@vikmovcan vikmovcan changed the title Support partially successful curl_setopt_array cURL instrumentation: support partially successful curl_setopt_array Nov 11, 2024

@intuibase intuibase left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good, thanks for catching that.

@brettmc
brettmc merged commit f6a567b into open-telemetry:main Nov 23, 2024
@brettmc

brettmc commented Nov 23, 2024

Copy link
Copy Markdown
Contributor

released v0.0.2

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.

4 participants