Skip to content

[receiver/postgresql] clarify postgresql.backends metric semantics - #49201

Open
kartikgola wants to merge 16 commits into
open-telemetry:mainfrom
kartikgola:postgresqlreceiver-clarify-backends-semantics
Open

[receiver/postgresql] clarify postgresql.backends metric semantics#49201
kartikgola wants to merge 16 commits into
open-telemetry:mainfrom
kartikgola:postgresqlreceiver-clarify-backends-semantics

Conversation

@kartikgola

@kartikgola kartikgola commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Description

  • Updated the README, metadata, documentation to correct the intent of the metric.
  • Updated the function comment in client.go file
  • Renamed internal activityMap to backendCountByDB to make the intention clear since it has references where it's being used as if activeConnections, ok := r.activityMap[dbName]; – assuming that activityMap always contains active connections which might not be the case.

Link to tracking issue

Testing

make test

Documentation

Updated receiver/postgresqlreceiver documentation with the new definition.

Authorship

  • I, a human, wrote this pull request description myself.

@github-actions github-actions Bot added the first-time contributor PRs made by new contributors label Jun 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Welcome, contributor! Thank you for your contribution to opentelemetry-collector-contrib.

Important reminders:

  • Read our Contributing Guidelines.
  • Sign the CLA if you haven't already.
  • First-time contributors should have at most one PR not marked as draft until their first PR is merged.
  • If your change isn't one of our priority components, reviews may take more time.
  • Give reviewers at least a few days before pinging them for feedback.
  • If you need help or struggle to move your PR forward:

@kartikgola kartikgola changed the title [chore] [receiver/postgresql] clarify backends metric semantics [chore] [receiver/postgresql] clarify postgresql.backends metric semantics Jun 21, 2026
@kartikgola
kartikgola marked this pull request as ready for review June 21, 2026 12:20
@kartikgola
kartikgola requested a review from a team as a code owner June 21, 2026 12:20
@kartikgola
kartikgola requested a review from TylerHelmuth June 21, 2026 12:20
@kartikgola kartikgola changed the title [chore] [receiver/postgresql] clarify postgresql.backends metric semantics receiver/postgresql] clarify postgresql.backends metric semantics Jun 22, 2026
@kartikgola kartikgola changed the title receiver/postgresql] clarify postgresql.backends metric semantics [receiver/postgresql] clarify postgresql.backends metric semantics Jun 22, 2026
@antonblock

Copy link
Copy Markdown
Contributor

@kartikgola I think this is a helpful docs change, we can probably add the Skip Changelog for it

@TylerHelmuth TylerHelmuth added the Skip Changelog PRs that do not require a CHANGELOG.md entry label Jul 15, 2026
Resolve conflicts from main's OTel semconv feature-gate and query-conflicts
work: keep the backendCountByDB rename alongside main's dbConflictStats
field, and regenerate mdatagen output (metadata.yaml already merged
cleanly) instead of hand-resolving the generated test file.

Assisted-by: Claude Fable 5
### postgresql.backends

The number of backends.
The number of backend processes associated with each database, as reported by `pg_stat_activity`. Counts backends across all connection states (active, idle, idle-in-transaction) and all backend types, including non-client backends such as autovacuum and parallel workers.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I try to follow the rule of not disclosing the underlying datasoruce in documentation. How about:

"The number of backend processes associated with each database. Counts backends across all connection states (active, idle, idle-in-transaction) and all backend types, including non-client backends such as autovacuum and parallel workers." - {in all relevant places in the MR}

Comment thread receiver/postgresqlreceiver/README.md Outdated
GRANT pg_monitor TO otelu;
```

The `postgresql.backends` metric reports the number of PostgreSQL backend processes associated with each database,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The README paragraph is more of an extended explanation for users, and while it's debatable there, I'd still lean toward removing the explicit pg_stat_activity reference from the README too, since the review guidelines are clear about this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed. The only reason it was added here was because of the presence of pg_stat_activity. It makes sense to remove it from here since its an internal detail.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Heads up — the generated files (generated_package_test.go, generated_logs.go, generated_logs_test.go, generated_metrics.go, generated_resource_test.go) have import reordering where standard library packages ended up below third-party imports, which can cause CI lint failures.

What I do is run make generate from within receiver/postgresqlreceiver/ — that runs mdatagen and then applies gofumpt, goimports, and gci to fix import ordering automatically. If you only ran go generate ./... or make mdatagen, those formatting steps get skipped.

douglascamata and others added 2 commits July 18, 2026 16:39
…#47853)

Co-authored-by: Evan Bradley <11745660+evan-bradley@users.noreply.github.com>
Signed-off-by: Douglas Camata <159076+douglascamata@users.noreply.github.com>
Local mdatagen regeneration used a different import-grouping convention
than the repo's pinned gci config; restore the standard grouping with
no functional change.
@kartikgola
kartikgola requested a review from ebrdarSplunk July 18, 2026 13:38
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Jul 18, 2026

Copy link
Copy Markdown

Pull request dashboard status

Status last refreshed: 2026-07-27 15:22:19 UTC.

  • Waiting on: Reviewers
  • Next step: Review the latest changes.

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

@kartikgola

Copy link
Copy Markdown
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

postgresql.backends metric is described only as The number of backends which looks ambiguous

6 participants