Skip to content

Conversation

HeenaBansal20
Copy link
Contributor

This PR adds auto instrumentation hooks for session_start() and session_destroy().

@HeenaBansal20 HeenaBansal20 requested a review from a team as a code owner August 27, 2025 02:02
Copy link

codecov bot commented Aug 27, 2025

Codecov Report

❌ Patch coverage is 94.52055% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.53%. Comparing base (21c82d2) to head (66efcf7).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
...entation/Session/src/PhpSessionInstrumentation.php 94.52% 4 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main     #433      +/-   ##
============================================
- Coverage     83.12%   82.53%   -0.59%     
- Complexity     1396     1983     +587     
============================================
  Files            97      137      +40     
  Lines          5599     8084    +2485     
============================================
+ Hits           4654     6672    +2018     
- Misses          945     1412     +467     
Flag Coverage Δ
Aws 93.41% <ø> (+0.82%) ⬆️
Context/Swoole 0.00% <ø> (ø)
Exporter/Instana 49.42% <ø> (ø)
Instrumentation/AwsSdk 81.13% <ø> (ø)
Instrumentation/CakePHP 20.40% <ø> (ø)
Instrumentation/CodeIgniter 73.98% <ø> (ø)
Instrumentation/Curl 87.66% <ø> (ø)
Instrumentation/Doctrine 92.92% <ø> (ø)
Instrumentation/ExtAmqp 88.48% <ø> (ø)
Instrumentation/ExtRdKafka 86.11% <ø> (ø)
Instrumentation/Guzzle 75.58% <ø> (ø)
Instrumentation/HttpAsyncClient 78.04% <ø> (ø)
Instrumentation/IO 70.68% <ø> (ø)
Instrumentation/Laravel 70.97% <ø> (?)
Instrumentation/MySqli 95.81% <ø> (ø)
Instrumentation/OpenAIPHP 87.21% <ø> (ø)
Instrumentation/PDO 94.21% <ø> (ø)
Instrumentation/PostgreSql 93.54% <ø> (ø)
Instrumentation/Psr14 76.47% <ø> (ø)
Instrumentation/Psr15 89.15% <ø> (ø)
Instrumentation/Psr16 97.50% <ø> (ø)
Instrumentation/Psr18 77.46% <ø> (ø)
Instrumentation/Psr3 67.01% <ø> (ø)
Instrumentation/Psr6 97.61% <ø> (ø)
Instrumentation/ReactPHP 99.45% <ø> (ø)
Instrumentation/Session 94.52% <94.52%> (?)
Instrumentation/Slim 86.11% <ø> (ø)
Instrumentation/Symfony 84.88% <ø> (ø)
Instrumentation/Yii 77.86% <ø> (ø)
Logs/Monolog 100.00% <ø> (ø)
Propagation/CloudTrace 89.77% <ø> (ø)
Propagation/Instana 98.11% <ø> (ø)
Propagation/ServerTiming 100.00% <ø> (ø)
Propagation/TraceResponse 100.00% <ø> (ø)
ResourceDetectors/Azure 91.66% <ø> (ø)
ResourceDetectors/Container 93.02% <ø> (ø)
ResourceDetectors/DigitalOcean 100.00% <ø> (ø)
Sampler/RuleBased 33.51% <ø> (ø)
Sampler/Xray 78.23% <ø> (?)
Shims/OpenTracing 92.45% <ø> (ø)
Utils/Test 87.53% <ø> (?)

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

Files with missing lines Coverage Δ
...entation/Session/src/PhpSessionInstrumentation.php 94.52% <94.52%> (ø)

... and 38 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 da45e60...66efcf7. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@brettmc
Copy link
Contributor

brettmc commented Aug 27, 2025

This PR looks ok to me. I don't have a strong opinion, but it's quite specific - have you considered whether there are any similar functions that could also be incorporated? I think it's good to consider that now, since it could mean changing the name?

@HeenaBansal20
Copy link
Contributor Author

HeenaBansal20 commented Aug 27, 2025

ink it's good to consider that now, since it could mean changing the name?

@brettmc Yes sure , I agree that there is scope of adding more functions in the list,

However seeing the list of functions I dont feel like adding hooks for these since I don't feel these will add any value in trace. for example session_gc , session_reset , session_save_path , session_get_cookie_params, session_cache_expire

However current list can be expanded to session_write_close , session_unset .

Do you have any suggestions/feedback ?

@brettmc
Copy link
Contributor

brettmc commented Aug 27, 2025

Do you have any suggestions/feedback ?

I was thinking along the lines of non-session functions. The functions you've mentioned are still session, and adding them later if needed is fine and doesn't change the theme of the package.

So the question is: is a package just for sessions ok, or could its scope be expanded to include some other core functions? Perhaps things like setcookie, ob_start etc? I'm not saying you have to do this, just asking if you've thought about it.

@HeenaBansal20
Copy link
Contributor Author

Do you have any suggestions/feedback ?

I was thinking along the lines of non-session functions. The functions you've mentioned are still session, and adding them later if needed is fine and doesn't change the theme of the package.

So the question is: is a package just for sessions ok, or could its scope be expanded to include some other core functions? Perhaps things like setcookie, ob_start etc? I'm not saying you have to do this, just asking if you've thought about it.

I see , I haven't thought about adding other php internal functions in this .. I think since session is PHP extension we can keep this as separate from other php global functions ob_start looks more to me a IO candidate than this one.
similarly setcookie is also candidate from network type functions. Like we have for IO , we can generalize categories for most commonly used PHP functions and instrument accordingly .
What do you think ?

@brettmc
Copy link
Contributor

brettmc commented Aug 27, 2025

What do you think ?

That makes sense. Covering just the session module is ok.

@HeenaBansal20
Copy link
Contributor Author

@brettmc , Thanks for reviewing it.
DO you mind doing final check on this PR. I appreciate your time and efforts on reviewing this PR patiently .
Thank you.

@HeenaBansal20
Copy link
Contributor Author

@brettmc , Thank your for patiently reviewing this PR. I will appreciate if you can take a look again after my newer commit on requested changes.

$cookieKeys = [];
ksort($cookieParams);
foreach ($cookieParams as $key => $value) {
if (is_scalar($value)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why this check, if you're storing the keys? what's special about non-scalar values that makes you not want to store the associated key?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree ... my bad , this can be removed since now w e just storing the keys , no check is required on value.

@HeenaBansal20
Copy link
Contributor Author

@brettmc , I would really appreciate if you can spend some time to review.
Thanks.

@brettmc brettmc merged commit 1e2fa80 into open-telemetry:main Sep 9, 2025
158 of 167 checks passed
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.

2 participants