Skip to content

Commit d3dc319

Browse files
committed
feat: add usename label
Signed-off-by: rezaxd <r324r11@gmail.com>
1 parent 74cf90d commit d3dc319

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

collector/pg_process_idle.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,13 @@ func (PGProcessIdleCollector) Update(ctx context.Context, instance *instance, ch
8989

9090
var state sql.NullString
9191
var applicationName sql.NullString
92+
var usename sql.NullString
9293
var secondsSum sql.NullFloat64
9394
var secondsCount sql.NullInt64
9495
var seconds []float64
9596
var secondsBucket []int64
9697

97-
err := row.Scan(&state, &applicationName, &secondsSum, &secondsCount, pq.Array(&seconds), pq.Array(&secondsBucket))
98+
err := row.Scan(&state, &applicationName, &usename, &secondsSum, &secondsCount, pq.Array(&seconds), pq.Array(&secondsBucket))
9899
if err != nil {
99100
return err
100101
}
@@ -117,6 +118,11 @@ func (PGProcessIdleCollector) Update(ctx context.Context, instance *instance, ch
117118
applicationNameLabel = applicationName.String
118119
}
119120

121+
usenameLabel := "unknown"
122+
if usename.Valid {
123+
usenameLabel = usename.String
124+
}
125+
120126
var secondsCountMetric uint64
121127
if secondsCount.Valid {
122128
secondsCountMetric = uint64(secondsCount.Int64)
@@ -128,7 +134,7 @@ func (PGProcessIdleCollector) Update(ctx context.Context, instance *instance, ch
128134
ch <- prometheus.MustNewConstHistogram(
129135
pgProcessIdleSeconds,
130136
secondsCountMetric, secondsSumMetric, buckets,
131-
stateLabel, applicationNameLabel,
137+
stateLabel, applicationNameLabel, usenameLabel,
132138
)
133139
return nil
134140
}

0 commit comments

Comments
 (0)