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

Auto instrumentation for mysqli #318

Merged
merged 12 commits into from
Jan 13, 2025

Conversation

intuibase
Copy link
Contributor

@intuibase intuibase commented Dec 4, 2024

Example view in Kibana

Copy link

codecov bot commented Dec 4, 2024

Codecov Report

Attention: Patch coverage is 96.10778% with 26 lines in your changes missing coverage. Please review.

Project coverage is 86.02%. Comparing base (f6a567b) to head (d6194b5).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
...strumentation/MySqli/src/MySqliInstrumentation.php 96.64% 19 Missing ⚠️
src/Instrumentation/MySqli/src/MySqliTracker.php 93.06% 7 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main     #318      +/-   ##
============================================
+ Coverage     79.60%   86.02%   +6.41%     
- Complexity      729     1070     +341     
============================================
  Files            69       73       +4     
  Lines          2952     4450    +1498     
============================================
+ Hits           2350     3828    +1478     
- Misses          602      622      +20     
Flag Coverage Δ
Aws ?
Instrumentation/CakePHP 20.00% <ø> (ø)
Instrumentation/CodeIgniter 73.77% <ø> (ø)
Instrumentation/Curl 90.66% <ø> (ø)
Instrumentation/Guzzle 69.51% <ø> (ø)
Instrumentation/HttpAsyncClient 81.25% <ø> (ø)
Instrumentation/IO 70.68% <ø> (ø)
Instrumentation/MongoDB 76.31% <ø> (ø)
Instrumentation/MySqli 96.10% <96.10%> (?)
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 ?
Shims/OpenTracing 92.45% <ø> (ø)
Symfony 87.81% <ø> (?)

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

Files with missing lines Coverage Δ
src/Instrumentation/MySqli/src/MySqliTracker.php 93.06% <93.06%> (ø)
...strumentation/MySqli/src/MySqliInstrumentation.php 96.64% <96.64%> (ø)

... and 46 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 f6a567b...d6194b5. Read the comment docs.

@intuibase intuibase marked this pull request as ready for review December 6, 2024 14:20
@intuibase intuibase requested a review from a team as a code owner December 6, 2024 14:20
$attributes = $tracker->getMySqliAttributes($mysqli);

if ($transactionName) {
$attributes['db.transaction.name'] = $transactionName;
Copy link
Contributor Author

@intuibase intuibase Dec 13, 2024

Choose a reason for hiding this comment

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

In reference to the discussion on SIG and the custom attribute db.transaction.name, I looked into it and found that there is no corresponding entity in sem-conv. I started digging deeper into the topic and discovered that this is typical for the MySQLi extension in PHP. PDO does not allow setting a transaction name.

I checked the code of mysqlnd (the base driver for MySQLi and PDO), and it seems that there is no such concept as a transaction name. In mysqlnd, this is implemented by setting a comment in the SQL code—it is not interpreted by the database itself as a name but is treated as a regular comment.

Therefore, I suspect it will not be possible to add this entity to the semantic conventions, as it is specific to this particular driver.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Discussed this in SIG, and we decided that transaction name is useful telemetry metadata and should be added. Since this instrumentation is unstable, the spec says we can add additional telemetry: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/telemetry-stability.md#unstable-instrumentations

It would be worth pursuing having db.transaction.name or something like it added to semconv.

@brettmc
Copy link
Collaborator

brettmc commented Jan 9, 2025

@intuibase are you happy for me to merge this and get a 0.0.1 version out?

@intuibase
Copy link
Contributor Author

intuibase commented Jan 9, 2025

@intuibase are you happy for me to merge this and get a 0.0.1 version out?

Yes, please :)

@intuibase
Copy link
Contributor Author

@ChrisLightfootWild thanks, I've improved parser a bit, now it should work with semicolons inside quotes.

@brettmc brettmc merged commit f892be9 into open-telemetry:main Jan 13, 2025
93 of 122 checks passed
@brettmc
Copy link
Collaborator

brettmc commented Jan 14, 2025

@intuibase intuibase deleted the mysqli_auto_instrumentation branch January 14, 2025 19:28
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