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

fix: missing telemetry in mysql2 when importing only promise API #2662

Merged
merged 5 commits into from
Jan 21, 2025

Conversation

macno
Copy link
Contributor

@macno macno commented Jan 17, 2025

Which problem is this PR solving?

See #2590

Short description of the changes

Patch lib/connection.js that is always imported

@macno macno requested a review from a team as a code owner January 17, 2025 04:46
@github-actions github-actions bot added pkg:instrumentation-mysql2 pkg-status:unmaintained This package is unmaintained. Only bugfixes may be acceped until a new owner has been found. labels Jan 17, 2025
@macno macno changed the title Fix missing telemetry in mysql2 when importing only promise API fix: missing telemetry in mysql2 when importing only promise API Jan 17, 2025
Copy link

codecov bot commented Jan 17, 2025

Codecov Report

Attention: Patch coverage is 90.32258% with 3 lines in your changes missing coverage. Please review.

Project coverage is 90.96%. Comparing base (5f214eb) to head (7182d08).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...etry-instrumentation-mysql2/src/instrumentation.ts 93.10% 2 Missing ⚠️
.../opentelemetry-instrumentation-mysql2/src/utils.ts 50.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2662   +/-   ##
=======================================
  Coverage   90.95%   90.96%           
=======================================
  Files         172      172           
  Lines        8119     8137   +18     
  Branches     1646     1649    +3     
=======================================
+ Hits         7385     7402   +17     
- Misses        734      735    +1     
Files with missing lines Coverage Δ
.../opentelemetry-instrumentation-mysql2/src/utils.ts 91.30% <50.00%> (-1.88%) ⬇️
...etry-instrumentation-mysql2/src/instrumentation.ts 95.60% <93.10%> (+0.93%) ⬆️

@macno macno force-pushed the fix-otel-js-contrib-2590 branch from 268adf4 to 74b7ea9 Compare January 17, 2025 05:59
@macno macno force-pushed the fix-otel-js-contrib-2590 branch from 74b7ea9 to b9093ae Compare January 17, 2025 06:05

This comment was marked as outdated.

@pichlermarc pichlermarc added bug Something isn't working and removed pkg-status:unmaintained This package is unmaintained. Only bugfixes may be acceped until a new owner has been found. pkg-status:unmaintained:autoclose-scheduled labels Jan 17, 2025
Copy link
Member

@pichlermarc pichlermarc left a comment

Choose a reason for hiding this comment

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

Overall looks good, thanks for chasing this down. 🙌
Just one comment nit and one blocker around addSpanProcessor.

Due to the re-format and change in nesting, the diff here initially looked more daunting than it actually was 🙂

@macno
Copy link
Contributor Author

macno commented Jan 20, 2025

Overall looks good, thanks for chasing this down. 🙌 Just one comment nit and one blocker around addSpanProcessor.

Due to the re-format and change in nesting, the diff here initially looked more daunting than it actually was 🙂

yeah, sorry about that, but I had to find a way to use different before/after blocks.

I'll take care of the suggestions, thank you!

@github-actions github-actions bot added the pkg-status:unmaintained This package is unmaintained. Only bugfixes may be acceped until a new owner has been found. label Jan 20, 2025
@macno macno force-pushed the fix-otel-js-contrib-2590 branch from 7a44323 to 1f82b74 Compare January 20, 2025 15:46
@macno macno requested a review from pichlermarc January 20, 2025 15:48
instrumentation.enable();
instrumentation.disable();

mysqlTypesPromReload = await import('mysql2/promise');
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: by importing the types at the top of the file you can avoid loading twice the module which may improve perf (although not noticeable) and avoid any possible odd scenario. Actually I found quite misfortunate to name mysqlTypes and mysqlTypesProm the imported modules. The types in the names is quite misleading since it's the actual module object

…improve readability

Update plugins/node/opentelemetry-instrumentation-mysql2/test/mysql.test.ts
@macno macno force-pushed the fix-otel-js-contrib-2590 branch from ac6eed1 to 56bd9dd Compare January 21, 2025 13:03
@david-luna david-luna merged commit c67a8c3 into open-telemetry:main Jan 21, 2025
25 checks passed
@dyladan dyladan mentioned this pull request Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pkg:instrumentation-mysql2 pkg-status:unmaintained This package is unmaintained. Only bugfixes may be acceped until a new owner has been found.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants