Skip to content

Commit c52f3c7

Browse files
committed
chore: update the wording again
1 parent d9d0119 commit c52f3c7

21 files changed

Lines changed: 42 additions & 37 deletions

receiver/postgresqlreceiver/README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,12 @@ to grant the user you are using `pg_monitor`. Take the example from `testdata/in
9494
GRANT pg_monitor TO otelu;
9595
```
9696
97-
Query sample events include the backend's `postgresql.state`. The `postgresql.backends` metric instead reports the
98-
total number of PostgreSQL backend processes associated with each database, including client connections in active,
99-
idle, and idle-in-transaction states, as reported by `pg_stat_activity`.
97+
The `postgresql.backends` metric reports the number of PostgreSQL backend processes associated with each database,
98+
as counted from `pg_stat_activity`. It applies no filter on connection state or backend type, so it counts active,
99+
idle, and idle-in-transaction client connections as well as non-client backends such as autovacuum workers and
100+
parallel query workers. Background processes that are not associated with a database (e.g. the background writer and
101+
WAL writer, which have a `NULL` `datname`) are not attributed to any database. This differs from query sample events,
102+
which include each backend's `postgresql.state`.
100103
101104
The following options are available:
102105
- `max_rows_per_query`: (optional, default=1000) The max number of rows would return from the query

receiver/postgresqlreceiver/client.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,10 @@ func (c *postgreSQLClient) getDatabaseLocks(ctx context.Context) ([]databaseLock
341341
return dl, multierr.Combine(errs...)
342342
}
343343

344-
// getBackends returns the total number of PostgreSQL backend processes associated with each database,
345-
// including client connections in active, idle, and idle-in-transaction states.
344+
// getBackends returns the number of backend processes for each database, counted from pg_stat_activity
345+
// across all connection states (active, idle, idle-in-transaction) and all backend types, including
346+
// non-client backends such as autovacuum and parallel workers. Backends with no associated database
347+
// (NULL datname, e.g. the background writer and WAL writer) are not attributed to any database.
346348
func (c *postgreSQLClient) getBackends(ctx context.Context, databases []string) (map[databaseName]int64, error) {
347349
query := filterQueryByDatabases("SELECT datname, count(*) as count from pg_stat_activity", databases, true)
348350
rows, err := c.client.QueryContext(ctx, query)

receiver/postgresqlreceiver/documentation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ metrics:
1414
1515
### postgresql.backends
1616
17-
The total number of PostgreSQL backend processes associated with this database, including client connections in active, idle, and idle-in-transaction states, as reported by `pg_stat_activity`.
17+
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.
1818

1919
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | Stability |
2020
| ---- | ----------- | ---------- | ----------------------- | --------- | --------- |

receiver/postgresqlreceiver/internal/metadata/generated_metrics.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

receiver/postgresqlreceiver/internal/metadata/generated_metrics_test.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

receiver/postgresqlreceiver/metadata.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ events:
262262
metrics:
263263
postgresql.backends:
264264
enabled: true
265-
description: The total number of PostgreSQL backend processes associated with this database, including client connections in active, idle, and idle-in-transaction states, as reported by `pg_stat_activity`.
265+
description: 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.
266266
stability: development
267267
unit: "1"
268268
sum:

receiver/postgresqlreceiver/testdata/integration/expected_all_db.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ resourceMetrics:
492492
stringValue: postgres
493493
scopeMetrics:
494494
- metrics:
495-
- description: The total number of PostgreSQL backend processes associated with this database, including client connections in active, idle, and idle-in-transaction states, as reported by `pg_stat_activity`.
495+
- description: 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.
496496
name: postgresql.backends
497497
sum:
498498
aggregationTemporality: 2

receiver/postgresqlreceiver/testdata/integration/expected_all_db_connpool.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ resourceMetrics:
66
stringValue: postgres
77
scopeMetrics:
88
- metrics:
9-
- description: The total number of PostgreSQL backend processes associated with this database, including client connections in active, idle, and idle-in-transaction states, as reported by `pg_stat_activity`.
9+
- description: 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.
1010
name: postgresql.backends
1111
sum:
1212
aggregationTemporality: 2
@@ -483,7 +483,7 @@ resourceMetrics:
483483
stringValue: otel
484484
scopeMetrics:
485485
- metrics:
486-
- description: The total number of PostgreSQL backend processes associated with this database, including client connections in active, idle, and idle-in-transaction states, as reported by `pg_stat_activity`.
486+
- description: 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.
487487
name: postgresql.backends
488488
sum:
489489
aggregationTemporality: 2
@@ -1028,7 +1028,7 @@ resourceMetrics:
10281028
stringValue: otel2
10291029
scopeMetrics:
10301030
- metrics:
1031-
- description: The total number of PostgreSQL backend processes associated with this database, including client connections in active, idle, and idle-in-transaction states, as reported by `pg_stat_activity`.
1031+
- description: 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.
10321032
name: postgresql.backends
10331033
sum:
10341034
aggregationTemporality: 2

receiver/postgresqlreceiver/testdata/integration/expected_all_db_schemaattr.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ resourceMetrics:
492492
stringValue: postgres
493493
scopeMetrics:
494494
- metrics:
495-
- description: The total number of PostgreSQL backend processes associated with this database, including client connections in active, idle, and idle-in-transaction states, as reported by `pg_stat_activity`.
495+
- description: 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.
496496
name: postgresql.backends
497497
sum:
498498
aggregationTemporality: 2

receiver/postgresqlreceiver/testdata/integration/expected_multi_db_connpool.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ resourceMetrics:
326326
stringValue: otel
327327
scopeMetrics:
328328
- metrics:
329-
- description: The total number of PostgreSQL backend processes associated with this database, including client connections in active, idle, and idle-in-transaction states, as reported by `pg_stat_activity`.
329+
- description: 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.
330330
name: postgresql.backends
331331
sum:
332332
aggregationTemporality: 2
@@ -871,7 +871,7 @@ resourceMetrics:
871871
stringValue: otel2
872872
scopeMetrics:
873873
- metrics:
874-
- description: The total number of PostgreSQL backend processes associated with this database, including client connections in active, idle, and idle-in-transaction states, as reported by `pg_stat_activity`.
874+
- description: 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.
875875
name: postgresql.backends
876876
sum:
877877
aggregationTemporality: 2

0 commit comments

Comments
 (0)