Skip to content

Commit 817175a

Browse files
author
Pierre SOUCHAY
committed
Document and report 0 value for PG_EXPORTER_COLLECTION_TIMEOUT
Signed-off-by: Pierre SOUCHAY <pierre.souchay@pelico.io>
1 parent 7888a6f commit 817175a

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ The following environment variables configure the exporter:
261261
It avoids connections stacking when the database answers too slowly
262262
(for instance if the database creates/drop a huge table and locks the tables)
263263
and will avoid exhausting the pool of connections of the database.
264+
Value of `0` or less than `1ms` is considered invalid and will report an error.
264265

265266
* `PG_EXPORTER_WEB_TELEMETRY_PATH`
266267
Path under which to expose metrics. Default is `/metrics`.

collector/collector.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@ func WithCollectionTimeout(s string) Option {
165165
if err != nil {
166166
return err
167167
}
168+
if duration < 1*time.Millisecond {
169+
return errors.New("timeout must be greater than 1ms")
170+
}
168171
e.CollectionTimeout = duration
169172
return nil
170173
}
@@ -192,6 +195,7 @@ func (p PostgresCollector) Collect(ch chan<- prometheus.Metric) {
192195
}
193196

194197
func (p PostgresCollector) collectFromConnection(inst *instance, ch chan<- prometheus.Metric) {
198+
// Eventually, connect this to the http scraping context
195199
ctx, cancel := context.WithTimeout(context.Background(), p.CollectionTimeout)
196200
defer cancel()
197201

0 commit comments

Comments
 (0)