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

feat: add sqlcommenter comment to mysql2 queries #1523

Merged

Conversation

raphael-theriault-swi
Copy link
Contributor

@raphael-theriault-swi raphael-theriault-swi commented Jun 1, 2023

Which problem is this PR solving?

This PR adds support for inserting sqlcommenter comments in the mysql2 instrumentation the same way #1286 did for pg.

Short description of the changes

The common logic for detecting and writing SQL comments has been extracted to a sql-common package which is now depended on by both the mysql2 and pg instrumentations. I'm not super confident about the way new packages should be created (versioning, dependencies, etc etc) so let me know if anything there needs to be changed.

I'm also planning to also add support to the mysql instrumentation at some point after this is merged, and potentially improve the comment detection logic to reduce false positives.

The new config option essentially works the exact same way as the existing one for pg. It's not enabled for prepared queries for fairly obvious reasons.

I had to change some of the MySQL options used for the local and CI containers to be able to check the comments are successfully added by looking at the log. The CI variant feels a little dirty but GitHub apparently doesn't support passing arguments to service containers so it's the best way I could think of.

Copy link
Member

@haddasbronfman haddasbronfman left a comment

Choose a reason for hiding this comment

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

This LGTM. thank you for handling this.

packages/opentelemetry-sql-common/README.md Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Jun 9, 2023

Codecov Report

Merging #1523 (2b15aca) into main (476f3ce) will decrease coverage by 2.43%.
The diff coverage is 100.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1523      +/-   ##
==========================================
- Coverage   96.13%   93.70%   -2.43%     
==========================================
  Files          14       49      +35     
  Lines         906     2702    +1796     
  Branches      197      504     +307     
==========================================
+ Hits          871     2532    +1661     
- Misses         35      170     +135     
Impacted Files Coverage Δ
...node/opentelemetry-instrumentation-pg/src/utils.ts 96.96% <ø> (ø)
...etry-instrumentation-mysql2/src/instrumentation.ts 94.73% <100.00%> (ø)
...elemetry-instrumentation-pg/src/instrumentation.ts 91.21% <100.00%> (ø)

... and 32 files with indirect coverage changes

@raphael-theriault-swi
Copy link
Contributor Author

Is there anything blocking this PR at the moment given the coverage regressions aren't coming from the patch ?

@haddasbronfman
Copy link
Member

Yes. there is a conflict in .release-please-manifest.json. Can you take a look at this please?

@haddasbronfman haddasbronfman merged commit 856c252 into open-telemetry:main Jun 22, 2023
13 of 14 checks passed
@dyladan dyladan mentioned this pull request Jun 22, 2023
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.

None yet

7 participants