Skip to content

fix(instrumentation-mysql, instrumentation-mongodb)!: replace deprecated db.client.connections.usage with db.client.connection.count in mongodb and mysql - #3608

Merged
trentm merged 8 commits into
open-telemetry:mainfrom
Luffy-nani:fix/db-client-connection-count
Jul 22, 2026
Merged

fix(instrumentation-mysql, instrumentation-mongodb)!: replace deprecated db.client.connections.usage with db.client.connection.count in mongodb and mysql#3608
trentm merged 8 commits into
open-telemetry:mainfrom
Luffy-nani:fix/db-client-connection-count

Conversation

@Luffy-nani

@Luffy-nani Luffy-nani commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Which problem is this PR solving?

-db.client.connections.usage is deprecated in favor of db.client.connection.count. The MongoDB and MySQL instrumentations still emit only the deprecated metric, with no path to the replacement.

Fixes #3590

Short description of the changes

  • Replaced db.client.connections.usage with db.client.connection.count in both instrumentation-mongodb and instrumentation-mysql, emitted unconditionally — matching the pattern already used by instrumentation-pg (as confirmed in the discussion on feat!: only emit stable http, network and database attributes #3585).
  • Updated existing tests in both packages to assert the new metric name (no new test files added).
  • Updated both READMEs to document the new metric.

Related: #3585 (dependency, now merged)

@Luffy-nani
Luffy-nani requested a review from a team as a code owner July 7, 2026 20:50
@github-actions
github-actions Bot requested a review from onurtemizkan July 7, 2026 20:50
@github-actions github-actions Bot added pkg:instrumentation-mysql pkg:instrumentation-mongodb pkg-status:unmaintained This package is unmaintained. Only bugfixes may be acceped until a new owner has been found. labels Jul 7, 2026

@maryliag maryliag left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Added a few comments, mostly because you update the metric name, but not the attributes

Comment thread packages/instrumentation-mongodb/src/instrumentation.ts Outdated
Comment thread packages/instrumentation-mysql/src/instrumentation.ts Outdated
Comment thread packages/instrumentation-mysql/src/instrumentation.ts Outdated
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Jul 8, 2026

Copy link
Copy Markdown

Pull request dashboard status

Status last refreshed: 2026-07-22 20:10:32 UTC.

  • Status: Merged.

This automated status or its linked feedback items may be incorrect. If something looks wrong, please report it with the result you expected.

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

This package does not have an assigned component owner and is considered unmaintained. As such this package is in feature-freeze and this PR will be closed with 14 days unless a new owner or a sponsor (a member of @open-telemetry/javascript-approvers) for the feature is found. It is the responsibility of the author to find a sponsor for this feature.
Are you familiar with this package? Consider becoming a component owner.

@Luffy-nani

Copy link
Copy Markdown
Contributor Author

Hey @maryliag , pushed a fix for all the comments: both packages now import and use db.client.connection.pool.name and db.client.connection.state from semconv instead of raw strings, and renamed poolNameOld to poolName in mysql. Let me know if I missed anything!
One thing I noticed while in there is getPoolNameOld() in mysql's utils.ts has the same "old" naming leftover. Didn't touch it since you didn't flag it, but happy to rename that too if you'd like.

@Luffy-nani
Luffy-nani requested a review from maryliag July 8, 2026 09:47
Comment thread packages/instrumentation-mysql/src/instrumentation.ts Outdated
@Luffy-nani
Luffy-nani requested a review from maryliag July 8, 2026 17:06
@raphael-theriault-swi raphael-theriault-swi changed the title fix: replace deprecated db.client.connections.usage with db.client.connection.count in mongodb and mysql fix!: replace deprecated db.client.connections.usage with db.client.connection.count in mongodb and mysql Jul 16, 2026
@Luffy-nani Luffy-nani closed this Jul 17, 2026
@Luffy-nani Luffy-nani reopened this Jul 17, 2026
@Luffy-nani

Copy link
Copy Markdown
Contributor Author

Hi @maryliag ! Just a friendly follow-up on this PR 😊
I know you're probably busy, so no rush at all. Whenever you get a chance, I'd really appreciate another review. Thanks!

@maryliag maryliag left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

just a few nits (make sure you import the constant accordingly)

Comment thread packages/instrumentation-mongodb/src/semconv.ts
Comment thread packages/instrumentation-mongodb/test/mongodb-metrics-v4plus.test.ts Outdated
Comment thread packages/instrumentation-mongodb/test/mongodb-metrics-v4plus.test.ts Outdated
Comment thread packages/instrumentation-mysql/src/instrumentation.ts Outdated
Comment thread packages/instrumentation-mysql/src/instrumentation.ts Outdated
Comment thread packages/instrumentation-mysql/src/instrumentation.ts Outdated
Comment thread packages/instrumentation-mongodb/test/mongodb-metrics-v4plus.test.ts Outdated
Comment thread packages/instrumentation-mongodb/test/mongodb-metrics-v4plus.test.ts Outdated
Comment thread packages/instrumentation-mysql/src/instrumentation.ts Outdated
Comment thread packages/instrumentation-mysql/src/instrumentation.ts Outdated
@pichlermarc pichlermarc mentioned this pull request Jul 22, 2026
@pichlermarc

Copy link
Copy Markdown
Member

Looks like we need to merge this before releasing the semconv updates (ref #3596).
I'll address the nits to unblock this PR.

@trentm trentm changed the title fix!: replace deprecated db.client.connections.usage with db.client.connection.count in mongodb and mysql fix(instrumentation-mysql, instrumentation-mongodb)!: replace deprecated db.client.connections.usage with db.client.connection.count in mongodb and mysql Jul 22, 2026
@trentm trentm added the has:sponsor This package or feature has a sponsor that has volunteered to review PRs and respond to questions label Jul 22, 2026
@trentm
trentm merged commit 9fe5bd9 into open-telemetry:main Jul 22, 2026
35 of 36 checks passed
@otelbot

otelbot Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Thank you for your contribution @Luffy-nani! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey.

@Luffy-nani
Luffy-nani deleted the fix/db-client-connection-count branch July 23, 2026 02:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

has:sponsor This package or feature has a sponsor that has volunteered to review PRs and respond to questions pkg:instrumentation-mongodb pkg:instrumentation-mysql pkg-status:unmaintained:autoclose-scheduled 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.

remove metric db.client.connections.usage

5 participants