open-telemetry / open-telemetry/opentelemetry-python-contrib

sqlalchemy: modernize`db.client.connection.count` metric

Open
#5,060 3 comments 0 reactions 1 assignee View on GitHub

@ahmed5145 is already working on this.

Since Sep 17, 2026.

feature-request metrics
Dominant language
Python
Stars
1.1k
Forks
1.1k
Avg merge
4d 15h
Merged PRs (30d)
16

Description

What problem do you want to solve?
UPDATED description

SQLAlchemy instrumentor is not emitting metric connection count. It is instead emitting deprecated metric usage.

Original description
Click here to expand Noted in https://github.com/open-telemetry/opentelemetry-python-contrib/issues/1158#issuecomment-5623559405:

One concrete starting point: SQLAlchemy already reports connection usage, but under the deprecated db.client.connections.usage name (connections_usage) rather than the current db.client.connection.count. Migrating that to connection.count with state=idle/used, then adding the other pool metrics SQLAlchemy can see from its pool events, is a well-scoped first task.

It would be consistent if support of current/stable metric connection count (away from deprecated metric usage) was also an opt-in with OTEL_SEMCONV_STABILITY_OPT_IN like the span attributes, introduced in https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4110.

Describe the solution you'd like

Update opentelemetry-instrumentation-sqlalchemy to emit db.client.connection.count, replacing db.client.connections.usage.

Describe alternatives you've considered

We considered doing an opt-in but upon discussion agreed that the opt-in env var for span attribute migration is not appropriate for this -- see comment.

Additional Context

No response

Would you like to implement a fix?

No response

Tip

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.